1
$\begingroup$

I've normal-tumor human FASTQ file(s). Currently, I work with only one sample (both normal and tumor fastq R1 and R2), only.
I have alignment gatk mark duplicates, setupnmdtags, applybqsr, recalibrate steps before calling mutect2.

My input files are:
tiny_tumor_R1.fastq.gz
tiny_tumor_R2.fastq.gz
tiny_normal_R1.fastq.gz
tiny_normal_R2.fastq.gz

The expected output from the mutect2 is tiny.mutect2out.vcf that is ${sample_name}".mutect2out.vcf"

I split tiny_normal using nextflow split and take first element of the split array, that is tiny.

However, I get error as:

Caused by: Missing value declared as output parameter: sample_name

I understand that the variable was defined in the script step. How do I retrieve at the output level?

Below is code of the mutect2_process.nf

process mutect2 {

        maxForks 3
        debug true

 memory '15 GB'

        input:
        tuple val(sample_id_tumor),path(bqsrbam_tumor)
        tuple val(sample_id_normal),path(bqsrbam_normal)
        
        output:
        tuple val(sample_name),path(${sample_name}".mutect2out.vcf")
        

        script:
        def avail_mem = task.memory ? task.memory.toGiga() : 0
                def java_options = [
        avail_mem ? "-Xmx${avail_mem}G" : "",
        "-XX:+UseSerialGC",
    ]
        def sample_name=sample_id_normal.split('_normal')[0]

        """
                
        ml gatk/4.1.3.0
gatk --java-options "${java_options.join(' ')}" Mutect2 -L $params.target -I ${bqsrbam_tumor} -I ${bqsrbam_normal} -normal ${sample_name} -tumor ${sample_name} --output ${sample_name}".mutect2out.vcf" -R $params.hg38genome

        """
        }
$\endgroup$
0

1 Answer 1

1
$\begingroup$

You would like to use the sample_name variable outside the script block, but the def keyword defines a variable locally. All you'd need to do is remove the def keyword to make it work, but usually what you'd want to do is to define your sample_name variable outside of your process block in your workflow block like in my previous answer. I would also call this variable something else like pair_id, donor_name, case or patient perhaps. I would say you actually have two sample names here: one tumor sample (i.e. tiny_tumor) and one normal sample (i.e. tiny_normal) from the same patient/donor/case.

You may also run into issues if both of your input channels are queue channels. You may not notice any issues if you're testing only a single pair of samples. Try just copying your tiny files a couple of times and giving your workflow a try, for example:

for i in tiny_{tumor,normal}_R{1,2}.fastq.gz ; do
    for j in foo bar baz; do
        cp "${i}" "${j}_${i#*_}"
    done
done

Most of the time what you'll want is one queue channel and one or more value channels when you require multiple input channels.

$\endgroup$
5
  • $\begingroup$ Thank you. I removed def and it worked. My apologies I didn't quite understand: but usually what you'd want to do is to define your sample_name variable outside of your process block in your workflow block like What do I do? the example you shared is too difficult. $\endgroup$ Commented Jul 14, 2023 at 19:25
  • $\begingroup$ I have seen your reply few times on my posts as well on others, I don't quite follow queue channels, values channels link. What do I use when and for what? Sorry this is complicated then I can understand or/and follow. $\endgroup$ Commented Jul 14, 2023 at 19:26
  • 1
    $\begingroup$ @DeathMetal A better way, I think, would be to pass your sample_name variable (or pair_id or whatever) down to your mutect2 process. It's likely you'll need this variable later in your workflow, so defining it in your workflow block likely makes more sense. $\endgroup$
    – Steve
    Commented Jul 15, 2023 at 4:41
  • 1
    $\begingroup$ @DeathMetal I might be starting to sound like a broken record, but understanding how queue channels and value channels work should make writing workflows much easier. Queue channels can be consumed, but value channels can be read an unlimited number of times. In your example above, the intervals (targets) file and reference file should be passed in using value channels like in my previous answer. Note that value channels are implicitly created when a process is invoked with a simple value, like a file object. $\endgroup$
    – Steve
    Commented Jul 15, 2023 at 4:45
  • $\begingroup$ Hi @Steve - can you please assist me on post bioinformatics.stackexchange.com/questions/21338/…. $\endgroup$ Commented Jul 19, 2023 at 21:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.