Hi everyone,
I am trying to learn making workflows using Nextflow. I want to make an ATAC Seq workflow. I have 2 set of paired end ATAC Seq data.
First i perform adapter trimming using trimgalore. The ouputs of trimGalore consist of the two trimmed fqs for each set.
Then i want those trimmed fqs to be used as input in bowtie2, but i havent found a way of transforming pairedTrimmedCh to paired file channel in order to run the alignment proccess.
Any help?
Thanks in advance!
#!/usr/bin/env nextflow
params.reads = "./*{1,2}.fastq"
params.outdir = "bams"
params.INDEX = "path_to_index"
params.cpus = 10
log.info """\
A T A C S E Q - N F P I P E L I N E
===================================
Genome: ${params.INDEX}
reads : ${params.reads}
outdir : ${params.outdir}
"""
.stripIndent(true)
process trimReads {
publishDir "$params.outdir/", mode: 'copy'
input:
tuple val(sampleid), path(reads)
output:
path "./trimmed/"
script:
"""
TrimGalore-0.6.7/trim_galore --cores 7 --paired --no_report_file ${reads[0]} ${reads[1]} -o ./trimmed/
"""
}
process alignment {
publishDir "$params.outdir/", mode: 'copy'
input:
tuple val(sampleid), path(reads)
output:
path "${sampleid}.mm10.sorted.bam", emit: bams
path "${sampleid}.mm10.sorted.bam.bai"
script:
"""
bowtie2 --local -X 2000 -p ${params.cpus} -x ${params.INDEX} -1 ${trimmed_reads[0]} -2 ${trimmed_reads[1]} | samtools view -b -h -S -q 10 -f 0x2 | samtools sort -@ ${params.cpus} > ${sampleid}.mm10.sorted.bam
samtools index ${sampleid}.mm10.sorted.bam
"""
}
workflow {
// Create a channel with fastqs. If paired-end, use .fromFilePairs
Channel
.fromFilePairs(params.reads, checkIfExists: true)
.set { read_ch }
pairedTrimmedCh = trimReads(read_ch).groupTuple()
align_ch = alignment(pairedTrimmedCh)
}
The way you provide the index will cause a problem, see for a solution bowtie2 Mapping Using Pre-built Index in Nextflow
I am aware of it. I provide the index as a variable such as
and then
That is not going to work I assume. You cannot stage basenames. You can stage the folder with the index files, but then need some trick to find the files in it, as I described in that other thread.
It works! :)