Invalid method invocation call with arguments

I wrote a workflow to process unclassified sequences from centrifuge output, the code is as the following:

#!/usr/bin/env nextflow

process Unclassified_check {
    publishDir "${params.outdir}/Unclassified_check", mode: "copy"

    input:
    tuple val(bc), path(cenout), path(filteredfq)

    output:
    path "${bc}_blast_result.tsv", emit: blast_result

    script:
    """
    csvtk grep -t -f seqID -p unclassified ${cenout} | csvtk cut -t -f 1 | csvtk del-header | csvtk sample -p 0.001 -o ${bc}_unmappedReadIDs.txt
    seqkit grep -f ${bc}_unmappedReadIDs.txt ${filteredfq} | seqkit fq2fa -o ${bc}_unclassified_reads.fasta
    """
}

workflow {

    Channel
        .fromPath('Analysis/centrifuge/*_cenout.tsv', checkIfExists: true)
        .map { file -> tuple(file.baseName.split('_')[0], file) }
        .set { cenout_ch }

    Channel
        .fromPath('Analysis/outfq/*.fastq.gz', checkIfExists: true)
        .map { file -> tuple(file.baseName.split('_')[0], file) }
        .set { filteredfq_ch }

    cenout_ch
        .join(filteredfq_ch)
        .map { tuple1, tuple2 -> tuple(tuple1[0], tuple1[1], tuple2[1]) }
        .set { matched_files }

    Unclassified_check(matched_files)
}

When executing this code, I got the error message as the following:

ERROR ~ Invalid method invocation call with arguments: [barcode02, /tmp/Run/Analysis/centrifuge/barcode02_reads_without_host_cenout.csv, /tmp/Run/Analysis/outfq/barcode02_reads_without_host.fastq.gz] (java.util.ArrayList) on _closure11 type

From the error message it seems the input channels cenout_ch and filteredfq_ch are created by reading files from the specified paths and splitting the filenames to extract the barcode (bc ). The cenout_ch and filteredfq_ch channels are then joined on the barcode (bc ) and mapped to create tuples of the format tuple(bc, cenout, filteredfq). I am not sure what went wrong, can someone help to solve the problem. Thanks

If you run step by step (commenting later sections of the code), do you know exactly where is the problem? Can you share the channel content immediately before that?

I added .view() in each channel and ran the script one by one

workflow {

    Channel
        .fromPath('Analysis/centrifuge/*_cenout.tsv', checkIfExists: true)
        .map { file -> tuple(file.baseName.split('_')[0], file) }
        .set { cenout_ch }
    cenout_ch.view()

    Channel
        .fromPath('Analysis/outfq/*.fastq.gz', checkIfExists: true)
        .map { file -> tuple(file.baseName.split('_')[0], file) }
        .set { filteredfq_ch }
   //filteredfq_ch.view()

    //cenout_ch
        //.join(filteredfq_ch)
        //.map { tuple1, tuple2 -> tuple(tuple1[0], tuple1[1], tuple2[1]) }
        //.set { matched_files }

    //matched_files.view()

    //Unclassified_check(matched_files)
}

The first cenout_ch returned correctly

[barcode15, /tmp/Run/Analysis/centrifuge/barcode15_reads_without_host_cenout.tsv]

[barcode01, /tmp/Run/Analysis/centrifuge/barcode01_reads_without_host_cenout.tsv]

[barcode09, /tmp/Run/Analysis/centrifuge/barcode09_reads_without_host_cenout.tsv]

[barcode06, /tmp/Run/Analysis/centrifuge/barcode06_reads_without_host_cenout.tsv]

[barcode03, /tmp/Run/Analysis/centrifuge/barcode03_reads_without_host_cenout.tsv]

[barcode05, /tmp/Run/Analysis/centrifuge/barcode05_reads_without_host_cenout.tsv]

[barcode02, /tmp/Run/Analysis/centrifuge/barcode02_reads_without_host_cenout.tsv]

[barcode12, /tmp/Run/Analysis/centrifuge/barcode12_reads_without_host_cenout.tsv]

[barcode14, /tmp/Run/Analysis/centrifuge/barcode14_reads_without_host_cenout.tsv]

[barcode08, /tmp/Run/Analysis/centrifuge/barcode08_reads_without_host_cenout.tsv]

[barcode10, /tmp/Run/Analysis/centrifuge/barcode10_reads_without_host_cenout.tsv]

[barcode13, /tmp/Run/Analysis/centrifuge/barcode13_reads_without_host_cenout.tsv]

[barcode07, /tmp/Run/Analysis/centrifuge/barcode07_reads_without_host_cenout.tsv]

[barcode11, /tmp/Run/Analysis/centrifuge/barcode11_reads_without_host_cenout.tsv]

[barcode04, /tmp/Run/Analysis/centrifuge/barcode04_reads_without_host_cenout.tsv]

The filteredfq_ch returned correctly as well:

[barcode02, /tmp/Run/Analysis/outfq/barcode02_reads_without_host.fastq.gz]

[barcode04, /tmp/Run/Analysis/outfq/barcode04_reads_without_host.fastq.gz]

[barcode09, /tmp/Run/Analysis/outfq/barcode09_reads_without_host.fastq.gz]

[barcode11, /tmp/Run/Analysis/outfq/barcode11_reads_without_host.fastq.gz]

[barcode10, /tmp/Run/Analysis/outfq/barcode10_reads_without_host.fastq.gz]

[barcode13, /tmp/Run/Analysis/outfq/barcode13_reads_without_host.fastq.gz]

[barcode07, /tmp/Run/Analysis/outfq/barcode07_reads_without_host.fastq.gz]

[barcode15, /tmp/Run/Analysis/outfq/barcode15_reads_without_host.fastq.gz]

[barcode08, /tmp/Run/Analysis/outfq/barcode08_reads_without_host.fastq.gz]

[barcode14, /tmp/Run/Analysis/outfq/barcode14_reads_without_host.fastq.gz]

[barcode12, /tmp/Run/Analysis/outfq/barcode12_reads_without_host.fastq.gz]

[barcode03, /tmp/Run/Analysis/outfq/barcode03_reads_without_host.fastq.gz]

[barcode06, /tmp/Run/Analysis/outfq/barcode06_reads_without_host.fastq.gz]

[barcode05, /tmp/Run/Analysis/outfq/barcode05_reads_without_host.fastq.gz]

[barcode01, /tmp/Run/Analysis/outfq/barcode01_reads_without_host.fastq.gz]

Moving on to the join channel, the same error message showed again, so I marked the .map{} and it worked

workflow {

    Channel
        .fromPath('Analysis/centrifuge/*_cenout.tsv', checkIfExists: true)
        .map { file -> tuple(file.baseName.split('_')[0], file) }
        .set { cenout_ch }
    //cenout_ch.view()

    Channel
        .fromPath('Analysis/outfq/*.fastq.gz', checkIfExists: true)
        .map { file -> tuple(file.baseName.split('_')[0], file) }
        .set { filteredfq_ch }
   //filteredfq_ch.view()

    cenout_ch
        .join(filteredfq_ch)
        //.map { tuple1, tuple2 -> tuple(tuple1[0], tuple1[1], tuple2[1]) }
        .set { matched_files }

    matched_files.view()

    //Unclassified_check(matched_files)
}

[barcode09, /tmp/Run/Analysis/centrifuge/barcode09_reads_without_host_cenout.tsv, /tmp/Run/Analysis/outfq/barcode09_reads_without_host.fastq.gz]

[barcode02, /tmp/Run/Analysis/centrifuge/barcode02_reads_without_host_cenout.tsv, /tmp/Run/Analysis/outfq/barcode02_reads_without_host.fastq.gz]

[barcode15, /tmp/Run/Analysis/centrifuge/barcode15_reads_without_host_cenout.tsv, /tmp/Run/Analysis/outfq/barcode15_reads_without_host.fastq.gz]

[barcode08, /tmp/Run/Analysis/centrifuge/barcode08_reads_without_host_cenout.tsv, /tmp/Run/Analysis/outfq/barcode08_reads_without_host.fastq.gz]

[barcode10, /tmp/Run/Analysis/centrifuge/barcode10_reads_without_host_cenout.tsv, /tmp/Run/Analysis/outfq/barcode10_reads_without_host.fastq.gz]

[barcode14, /tmp/Run/Analysis/centrifuge/barcode14_reads_without_host_cenout.tsv, /tmp/Run/Analysis/outfq/barcode14_reads_without_host.fastq.gz]

[barcode13, /tmp/Run/Analysis/centrifuge/barcode13_reads_without_host_cenout.tsv, /tmp/Run/Analysis/outfq/barcode13_reads_without_host.fastq.gz]

[barcode12, /tmp/Run/Analysis/centrifuge/barcode12_reads_without_host_cenout.tsv, /tmp/Run/Analysis/outfq/barcode12_reads_without_host.fastq.gz]

[barcode07, /tmp/Run/Analysis/centrifuge/barcode07_reads_without_host_cenout.tsv, /tmp/Run/Analysis/outfq/barcode07_reads_without_host.fastq.gz]

[barcode03, /tmp/Run/Analysis/centrifuge/barcode03_reads_without_host_cenout.tsv, /tmp/Run/Analysis/outfq/barcode03_reads_without_host.fastq.gz]

[barcode11, /tmp/Run/Analysis/centrifuge/barcode11_reads_without_host_cenout.tsv, /tmp/Run/Analysis/outfq/barcode11_reads_without_host.fastq.gz]

[barcode06, /tmp/Run/Analysis/centrifuge/barcode06_reads_without_host_cenout.tsv, /tmp/Run/Analysis/outfq/barcode06_reads_without_host.fastq.gz]

[barcode04, /tmp/Run/Analysis/centrifuge/barcode04_reads_without_host_cenout.tsv, /tmp/Run/Analysis/outfq/barcode04_reads_without_host.fastq.gz]

[barcode05, /tmp/Run/Analysis/centrifuge/barcode05_reads_without_host_cenout.tsv, /tmp/Run/Analysis/outfq/barcode05_reads_without_host.fastq.gz]

[barcode01, /tmp/Run/Analysis/centrifuge/barcode01_reads_without_host_cenout.tsv, /tmp/Run/Analysis/outfq/barcode01_reads_without_host.fastq.gz]

So the question is what went wrong with .map{} and how can I make sure that the 1st path of the joined tuple is from cenout_ch and the 2nd path is from the filteredfq_ch?

As you showed in your last message, each element of your joined channel is a three item element. But when you use the map operator, you say there are two items, tuple1 and tuple2. It’s not clear to me what you’re trying to do here with the map operator.

As for the order of the items, it should respect the order of the joined elements.

I see, thank you for the reply.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.