This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Nextflow process fails with “Invalid method invocation call” despite correct tuple

I have a process to calculate FRiP per sample like this:

process FRIP_CALC {
label 'process_medium'
conda 'envs/bedtools_env.yml'
publishDir params.outdir, mode: "copy", pattern: '*.txt'

input:
tuple val(run), path(filtered_bam), path (peaks_bed)

output:
path("${run}_frip.txt")

script:
"""
total_reads=\$(samtools view -c ${filtered_bam})
in_peaks=\$(bedtools intersect -u -a ${filtered_bam} -b ${peaks_bed} | wc -l)
frip=\$(echo "scale=4; \$in_peaks / \$total_reads" | bc)

echo -e "run,frip" > ${run}_frip.txt
echo -e "${run},\$frip" >> ${run}_frip.txt
"""
}

I generate input tuples like this:

frip_ch = BOWTIE2_ALIGN.out.filtered_bam.map { t -> tuple(t[0], t[6]) }
peaks_ch = CALL_PEAKS.out.map { t -> tuple(t[0], t[6]) }

frip_input = frip_ch.join(peaks_ch)

frip_results = frip_input.map { bam_tuple, peaks_tuple ->
    tuple(
        bam_tuple[0],      // run
        bam_tuple[1],      // filtered BAM
        peaks_tuple[1]     // peaks BED
    )
}

When I run:

FRIP_CALC(frip_results)

I get the error:

Invalid method invocation `call` with arguments: [SRR28895186, /path/to/SRR28895186.filtered.bam, /path/to/SRR28895186_peaks.narrowPeak] (java.util.ArrayList) on _closure8 type. 

The printed tuple looks correct, and I’ve confirmed the tuple has exactly 3 elements. Why does Nextflow treat the tuple as an ArrayList?

nextflow frip

Why does Nextflow treat the tuple as an ArrayList?

I don't think there is a difference between a 'tupe' and an 'ArrayList'. You could try

frip_results = frip_input.map { bam_tuple, peaks_tuple ->
    [
        bam_tuple[0],      // run
        bam_tuple[1],      // filtered BAM
        peaks_tuple[1]     // peaks BED
    ]
}

but there should be no difference (?)

This is the same thing that I did in the OP. I just went with another way of passing the input tuple to the process in the OP.

0 answers

No answers yet.

Log in to answer this question.