#!/usr/bin/env nextflow // Path to an input file, or a pattern for multiple inputs // Note - $baseDir is the location of this workflow file main.nf // Define Input variables params.fastq = "$baseDir/../test_data/*.fastq.gz" params.designFile = "$baseDir/../test_data/design.csv" params.genome = '/project/apps_database/cellranger/refdata-cellranger-GRCh38-1.2.0' params.expectCells = 10000 params.forceCells = 0 params.version = '3.0.2' // Define regular variables designLocation = Channel .fromPath(params.designFile) .ifEmpty { exit 1, "design file not found: ${params.designFile}" } fastqList = Channel .fromPath(params.fastq) .flatten() .map { file -> [ file.getFileName().toString(), file.toString() ].join("\t") } .collectFile(name: 'fileList.tsv', newLine: true) refLocation = Channel .fromPath(params.genome) .ifEmpty { exit 1, "referene not found: ${params.genome}" } expectCells = params.expectCells forceCells = params.forceCells version = params.version process checkDesignFile { publishDir "$baseDir/output", mode: 'copy' input: file designLocation file fastqList output: file("design.checked.csv") into designPaths script: """ python3 $baseDir/scripts/check_design.py -d $designLocation -f $fastqList """ } // Parse design file samples = designPaths .splitCsv (sep: ',', header: true) .map { row -> [ row.Sample, file(row.fastq_R1), file(row.fastq_R2) ] } .groupTuple() //.subscribe { println it } // Duplicate variables samples.into { samples211 samples301 samples302 } refLocation.into { refLocation211 refLocation301 refLocation302 } expectCells211 = expectCells expectCells301 = expectCells expectCells302 = expectCells forceCells211 = forceCells forceCells301 = forceCells forceCells302 = forceCells process count211 { tag "count211-$sample" publishDir "$baseDir/output", mode: 'copy' input: set sample, file("${sample}_S1_L00?_R1_001.fastq.gz"), file("${sample}_S1_L00?_R2_001.fastq.gz") from samples211 file ref from refLocation211.first() expectCells211 forceCells211 output: file("**/outs/**") into outPaths211 when: version == '2.1.1' script: if (forceCells211 == 0){ """ cellranger count --id="$sample" --transcriptome="./$ref" --fastqs=. --sample="$sample" --expect-cells=$expectCells211 """ } else { """ cellranger count --id="$sample" --transcriptome="./$ref" --fastqs=. --sample="$sample" --force-cells=$forceCells211 """ } } process count301 { tag "count301-$sample" publishDir "$baseDir/output", mode: 'copy' input: set sample, file("${sample}_S1_L00?_R1_001.fastq.gz"), file("${sample}_S1_L00?_R2_001.fastq.gz") from samples301 file ref from refLocation301.first() expectCells301 forceCells301 output: file("**/outs/**") into outPaths301 when: version == '3.0.1' script: if (forceCells301 == 0){ """ cellranger count --id="$sample" --transcriptome="./$ref" --fastqs=. --sample="$sample" --expect-cells=$expectCells301 """ } else { """ cellranger count --id="$sample" --transcriptome="./$ref" --fastqs=. --sample="$sample" --force-cells=$forceCells301 """ } } process count302 { tag "count302-$sample" publishDir "$baseDir/output", mode: 'copy' input: set sample, file("${sample}_S1_L00?_R1_001.fastq.gz"), file("${sample}_S1_L00?_R2_001.fastq.gz") from samples302 file ref from refLocation302.first() expectCells302 forceCells302 output: file("**/outs/**") into outPaths302 when: version == '3.0.2' script: if (forceCells302 == 0){ """ cellranger count --id="$sample" --transcriptome="./$ref" --fastqs=. --sample="$sample" --expect-cells=$expectCells302 """ } else { """ cellranger count --id="$sample" --transcriptome="./$ref" --fastqs=. --sample="$sample" --force-cells=$forceCells302 """ } }