You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Nextflow子工作流仅处理成对样本中一个的问题求助

Nextflow工作流异常排查:subworkflow_B仅处理第一个样本

核心问题

构建的双生子工作流中,subworkflow_A正常输出两个样本的修剪后reads,但subworkflow_B仅处理第一个样本test_sample1,未处理test_sample2。


排查与修复方案

1. 变量名笔误(显性错误)

查看main工作流代码:

ch_trimmed_reads = subworkflow_A.out.trimmed_reads
subworkflow_B(ch_processed_reads, ch_db, ch_nodes, ch_names)

这里定义的有效通道是ch_trimmed_reads,但传给subworkflow_B的是未定义的ch_processed_reads。虽然用户描述中subworkflow_B运行了第一个样本,大概率是输入时的笔误,但必须先修正为:

subworkflow_B(ch_trimmed_reads, ch_db, ch_nodes, ch_names)

2. 单元素通道未广播(核心原因)

subworkflow_B的db、nodes、names通道是通过Channel.fromPath()创建的单元素通道(每个通道仅包含一个文件路径)。Nextflow默认的通道绑定逻辑是一对一匹配:单元素通道的唯一元素会与多元素通道(ch_trimmed_reads含2个样本)的第一个元素配对,之后单元素通道直接耗尽,第二个样本因无对应资源无法触发处理。

修复方式二选一:

  • 方式一:创建通道时添加broadcast(),让静态资源对所有样本可见
    ch_db = Channel.fromPath("$params.kaiju_db", checkIfExists: true).broadcast()
    ch_nodes = Channel.fromPath("$params.kaiju_nodes", checkIfExists: true).broadcast()
    ch_names = Channel.fromPath("$params.kaiju_names", checkIfExists: true).broadcast()
    
  • 方式二:在subworkflow_B的输入声明中标记广播属性
    workflow subworkflow_B {
      take:
        reads                                      // channel: [ val(sample), [ reads ] ]
        db broadcast            // 标记为广播通道
        nodes broadcast         // 标记为广播通道
        names broadcast         // 标记为广播通道
      // 其余代码不变
    }
    

3. subworkflow_A输出通道定义错误(隐性问题)

subworkflow_A的emit部分存在流程名错误:

emit:
  trimmed_reads = process2.out.reads

代码中未定义process2流程,正确应指向trim_reads的输出:

workflow subworkflow_A {
  take:
    reads                                      // channel: [ val(sample), [ reads ] ]
  main:
    count_reads(reads)
    trimmed_result = trim_reads(reads)
  emit:
    trimmed_reads = trimmed_result.out.reads
}

内容的提问来源于stack exchange,提问作者spitfiredd

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 07:45:37