Skip to content

Instantly share code, notes, and snippets.

@smartgamer
Forked from mikelove/Snakefile
Created October 17, 2020 16:18
Show Gist options
  • Select an option

  • Save smartgamer/a359ee22e4e418c5e0200e47b574b79e to your computer and use it in GitHub Desktop.

Select an option

Save smartgamer/a359ee22e4e418c5e0200e47b574b79e to your computer and use it in GitHub Desktop.
my Salmon Snakemake file
scratch <- "/pine/scr/m/i/milove"
# see https://gist.github.com/mikelove/f539631f9e187a8931d34779436a1c01 for accession2url() definition
source("https://gist.github.com/mikelove/f539631f9e187a8931d34779436a1c01/raw/6e6633aa5123358b70390ab738be1eef03a3df31/accession2url.R")
for (i in 1:nrow(x)) {
print(paste("---",i,"---"))
run <- x$Run[i]
for (read in 1:2) {
file <- paste0(run,"_",read,".fastq.gz")
url <- file.path(accession2url(run), file)
dest <- file.path(scratch, file)
if (!file.exists(dest))
download.file(url, dest)
}
}
#!/bin/bash
#
#SBATCH --job-name=snake
#SBATCH --time=240
#SBATCH --mem=1000
module load python
snakemake -j 4 --latency-wait 30 --cluster "sbatch -n 8 -N 1 --mem=10000 --time 60"
RUNS, = glob_wildcards("/pine/scr/m/i/milove/{run}_1.fastq.gz")
SALMON = "/proj/milovelab/bin/salmon-1.3.0_linux_x86_64/bin/salmon"
ANNO = "/proj/milovelab/anno"
rule all:
input: expand("quants/{run}/quant.sf", run=RUNS)
rule salmon_index:
input: "{ANNO}/gencode.vXYZ.transcripts.fa.gz"
output: directory("{ANNO}/gencode.vXYZ-salmon_1.3.0")
shell: "{SALMON} index --gencode -p 8 -t {input} -i {output}"
rule salmon_quant:
input:
r1 = "/pine/scr/m/i/milove/{sample}_1.fastq.gz",
r2 = "/pine/scr/m/i/milove/{sample}_2.fastq.gz",
index = "/proj/milovelab/anno/gencode.vXYZ-salmon_1.3.0"
output:
"quants/{sample}/quant.sf"
params:
dir = "quants/{sample}"
shell:
"{SALMON} quant -i {input.index} -l A -p 8 --gcBias "
"--numGibbsSamples 30 --thinningFactor 100 "
"-o {params.dir} -1 {input.r1} -2 {input.r2}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment