How to call a process of a workflow after two workflows output are complete?

Hello there,

I’ve multiple workflows and each workflow has different processes.

After I’m through with two workflows I’m interested in integrating output from different steps of these workflows.

I’d like to have a workflow, say named as integrate. In this integrate I’d like to put different processes such as combine_p1_p2, combine_p3_p4.

I’ve main.nf as:


include { rna  } from './workflows/rna'
include { wes } from './workflows/wes'
include { integrate_RNA_WES} from './workflows/integrate'

workflow {

    if (params.analysis=="both"){
        wes()
        rna()

        wes.out.parsed_cnv.view()
        rna.out.merged_rdata.view()
 
    }
}

In integrate workflow, I’d like to put few processes. These are mostly custom scripts.

In integrate workflow I’ve:


include {integrate_parsed_CNV_merged_RNA } from '../modules/integrate/processes_integrate.nf'
workflow integrate_RNA_WES {

integrate_parsed_CNV_merged_RNA()

}

I’ve processes_integrate.nf as:

process integrate_parsed_CNV_merged_RNA  {

input:
output:
script:
"""
"""

}

process integrate_files_diff {
input:
output:
script:

"""
"""
}

How do I call integrate_parsed_CNV_merged_RNA of integrate.nf once I’ve output from wes’s parsed_CNV and rna’s merged_feature?

Sorry this may seem complicated and confusing.

I’m sorry, I don’t understand where this question is coming from. If you have a process or a workflow that depends on something, it will start when this something is available. It doesn’t matter if it’s a subworkflow or a process, you just tell what your subworkflow or process needs, and Nextflow will make sure to spin it up when what it needs is available.

There are multiple famous nf-core pipelines that do exactly that. Many modules and subworkflows working together. Have a look at nf-core/rnaseq here, for example.

@mribeirodantas
Thank you for your response.

Yes, how do I call/execute it?

Is there a way to call a particular workflow’s process, say:

integrate.integrate_parsed_CNV_merged_RNA(     wes.out.parsed_cnv,        rna.out.merged_rdata)

Does it make sense now?

You can learn more about how subworkflow works, with examples, in the official documentation here and in the fundamentals Nextflow training here. Besides, I really like checking nf-core pipelines source code to see how skilled Nextflow developers do thing. I highly recommend you reading this material and checking the source code of these pipelines. Otherwise, it’ll be very hard for you to progress on your Nextfllow journey.