This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Fastqc in nextflow run only one pair of fastq.gz file and not on all Fastq files

Hi Everyone!!

I a new to nextflow and was trying to make a FASTQC workflow script. The script run fine on a Pair of FASTQ files, however, it doesn't loop over all the FASTQ files. What could be possibly wrong.

## I ran using the following command
nextflow run 01_fastqc.nf --raw 'data/*R{1,2}_001.fastq.gz'

01_fastqc.nf contains

nextflow.enable.dsl=2
params.raw = "data/*{1,2}.fastq.gz"
params.outdir="results/01_rawfastqc"
process FASTQC {
    publishDir "$params.outdir"
    input:
    tuple val(sample_id), path(reads)
    output:
    tuple val(sample_id), path("fastqc_out")
    script:
    """
    mkdir fastqc_out
    fastqc -t 10 -o fastqc_out ${reads[0]} ${reads[1]}
    multiqc -f fastqc_out -o fastqc_out/
    """
}

reads_ch = Channel.fromFilePairs(params.raw, checkIfExists: true )

workflow {
  FASTQC(reads_ch)
}
nextflow fastqc

1 answer

Use:

output:
    path("fastqc_out/*")

I think the issue is that the declared output: is only the folder itself but not any files so the wildcard will add that the files get published, but don't ask me why without the wildcard one of two samples makes it into the output folder. The Nextflow gurus might know. Not sure if wildcard alone is bad practice as I did it. You could more strictly use fastqc_out/${sample_id}*, that works as well.

I made some amends. I am still skeptical as to what changed but the following code works now. I think fastqc directory was getting overwrite again and again.

nextflow.enable.dsl=2
params.raw = "data/*{1,2}.fastq.gz"
params.outdir="results/01_rawfastqc"
process FASTQC {
        publishDir "$params.outdir"
        input:
        tuple val(sample_id), path(reads)
        output:
        file("*.{html,zip}")
        script:
        """
        fastqc -t 10 ${reads[0]} ${reads[1]}
        """
}


reads_ch = Channel.fromFilePairs(params.raw, checkIfExists: true )

workflow {
  FASTQC(reads_ch)
}

Ah, yes overwriting issue, good catch!

Log in to answer this question.