Last active
January 17, 2022 08:37
-
-
Save onertipaday/8c6740d112a8243b4f7f025c2262a8c2 to your computer and use it in GitHub Desktop.
nextflow pipeline for aligning RNA-seq samples to Vitis vinifera transcriptome
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env nextflow | |
params.db = "/nfs3/sonegop/references/PN40024.v4_11_05_21/gene_set/bowtie2_idx/PN40024.v4.1.complete.all.bowtie2" | |
db = file(params.db) | |
params.inputDir = "results/fastq" | |
pairedEndRegex = params.inputDir + "/*_{1,2}.fastq.gz" | |
/*SERegex = params.inputDir + "/*[!12].fastq.gz"*/ | |
SERegex = params.inputDir + "/*.fastq.gz" | |
pairFiles = Channel.fromFilePairs(pairedEndRegex) | |
singleFiles = Channel.fromFilePairs(SERegex, size: 1){ file -> file.baseName.replaceAll(/.fastq/,"") } | |
singleFiles.mix(pairFiles) | |
.set { fastqChannel } | |
indexChannel = Channel | |
.fromPath(params.db) | |
.ifEmpty { exit 1, "bowtie2 index not found: ${params.db}" } | |
process alignBowtie2 { | |
publishDir 'results/sam', mode: 'copy', overwrite: false | |
tag { lane } | |
input: | |
set val(lane), file(reads) from fastqChannel | |
file index from indexChannel.first() | |
output: | |
file ("${lane}.sam") into samChannel | |
file ("${lane}.stats") into statsChannel | |
shell: | |
def single = reads instanceof Path | |
if (!single) | |
''' | |
bowtie2 -p !{task.cpus} --local --sensitive-local -x !{db} -1 !{reads[0]} -2 !{reads[1]} -S !{lane}.sam 2> !{lane}.stats | |
''' | |
else | |
''' | |
bowtie2 -p !{task.cpus} --local --sensitive-local -x !{db} -U !{reads} -S !{lane}.sam 2> !{lane}.stats | |
''' | |
} | |
process getCounts { | |
publishDir 'results/counts/raw', mode: 'copy', overwrite: false | |
input: | |
file input from samChannel | |
output: | |
file "${input.baseName}.counts" into countsChannel | |
script: | |
"cut -f 3 $input | sort | uniq -c > ${input.baseName}.counts" | |
} | |
process sanitizeCounts { | |
publishDir 'results/counts/sanitized', mode: 'copy', overwrite: false | |
input: | |
file input from countsChannel | |
output: | |
file "${input.baseName}.counts.sanitized" into sanitizedChannel | |
script: | |
template 'sanitize.sh' | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
process { | |
container = '/nfs3/sonegop/images/bowtie2.4.4.simg' | |
executor = 'sge' | |
penv = 'smp' | |
queue = 'global.q' | |
clusterOptions = "-S /bin/bash -cwd -l mf=8G" | |
cpus = 6 | |
} | |
docker { | |
enabled = false | |
} | |
singularity { | |
enabled = true | |
autoMounts = true | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SRR1631879 | |
SRR1631880 | |
SRR1631881 | |
SRR1631882 | |
SRR1631883 | |
SRR1631884 | |
SRR1631885 | |
SRR1631886 | |
SRR1631887 | |
SRR1631888 | |
SRR1631889 | |
SRR1631890 | |
SRR1631891 | |
SRR1631892 | |
SRR1631893 | |
SRR1631894 | |
SRR1631895 | |
SRR1631896 | |
SRR1631897 | |
SRR1631898 | |
SRR1631899 | |
SRR1631900 | |
SRR1631901 | |
SRR1631902 | |
SRR1631903 | |
SRR1631904 | |
SRR1631905 | |
SRR1631906 | |
SRR1631907 | |
SRR1631908 | |
SRR1631909 | |
SRR1631910 | |
SRR1631911 | |
SRR1631912 | |
SRR1631913 | |
SRR1631914 | |
SRR1631915 | |
SRR1631916 | |
SRR1631917 | |
SRR1631918 | |
SRR1631919 | |
SRR1631920 | |
SRR1631921 | |
SRR1631922 | |
SRR1631923 | |
SRR1631924 | |
SRR1631925 | |
SRR1631926 | |
SRR1631927 | |
SRR1631928 | |
SRR1631929 | |
SRR1631930 | |
SRR1631931 | |
SRR1631932 | |
SRR1631933 | |
SRR1631934 | |
SRR1631935 | |
SRR1631936 | |
SRR1631937 | |
SRR1631938 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment