Multiple inputs with same meta map

Hello!

I have a module in my workflow which parses upstream results for each sample.

workflow test{
PARSE(
    TBLG.out.txt,
    KRAKEN2_KRAKEN2.out.report,
    QUALIMAP_BAMQC.out.results,
)
}

The inputs for this module are channels with meta() and then the result. The meta() should actually be the same for all three inputs, because each run is on one sample.

    input:
    tuple val(meta), path(tblg)
    tuple val(meta2), path(kraken)
    tuple val(meta3), path(bamqc)

However, when I run this, I get the results from samples mixed up. It will be the tblg result from sample1, and the kraken from sample2, which is not ideal. I don’t know why this happens.

I tried:

    input:
    tuple val(meta), path(tblg)
    tuple val(meta), path(kraken)
    tuple val(meta), path(bamqc)

But this doesn’t seem to work, either.
Would the solution be to join the channels? Ex:

input:
tuple val(meta), path(tblg), path(kraken), path(bamqc)

Any insight into what’s going on will be much appreciated!

You’re absolutely right! The join operator will join items that share a key (the first element in the tuple by default), so you can:

workflow {
  // some things

  TBLG.out.txt
  | join(KRAKEN2_KRAKEN2.out.report)
  | join(QUALIMAP_BAMQC.out.results)
  | MyNextProcess
}

process MyNextProcess {
  input: tuple val(meta), path(tblg), path(kraken), path(bamqc)
  // ... rest of the process

Give it a go and let me know how you get on!

1 Like

See the docs on caching and resuming for more details about why the inputs get mixed up incorrectly. It gives the same solution that Rob gave, using the join operator to combine the inputs into a single channel

1 Like

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