【问题标题】:Nextflow Channel create with conditionNextflow 通道创建条件
【发布时间】:2020-12-23 10:58:36
【问题描述】:
[Kasumi_H3K36, Kasumi_IgG, /mnt/Data/cut_and_tag/work/d0/3db2bde9eb1bdb0578073fb128bc4c/Kasumi_H3K36.no0.bedgraph]
[Kasumi_JMJD1C, Kasumi_IgG, /mnt/Data/cut_and_tag/work/b1/dffe2120acda5b05860e1a3bb0c1bf/Kasumi_JMJD1C.no0.bedgraph]
[Kasumi_NCOR1, Kasumi_IgG, /mnt/Data/cut_and_tag/work/9f/7c3680a1ff0ae0a5a27f42e1a27225/Kasumi_NCOR1.no0.bedgraph]
[Kasumi_IgG, Kasumi_IgG, /mnt/Data/cut_and_tag/work/21/1038cd4ecbc5b3f88da23ad1ee3147/Kasumi_IgG.no0.bedgraph]
[Kasumi_H4K5, Kasumi_IgG, /mnt/Data/cut_and_tag/work/3d/7b5239ab9dc83b00f992fea8926630/Kasumi_H4K5.no0.bedgraph]

这是我的频道视图之一。当第一个和第二个 ID 相同时,我正在尝试创建一个新的控制通道,其余的作为示例通道。

【问题讨论】:

    标签: nextflow


    【解决方案1】:

    这是使用branch 运算符的一种方法。我对应该命名的字段做了一些假设,但希望该模式与您正在寻找的模式接近:

    nextflow.enable.dsl=2
    
    Channel
        .of(
            ['Kasumi_H3K36', 'Kasumi_IgG', file('/mnt/Data/cut_and_tag/work/d0/3db2bde9eb1bdb0578073fb128bc4c/Kasumi_H3K36.no0.bedgraph')],
            ['Kasumi_JMJD1C', 'Kasumi_IgG', file('/mnt/Data/cut_and_tag/work/b1/dffe2120acda5b05860e1a3bb0c1bf/Kasumi_JMJD1C.no0.bedgraph')],
            ['Kasumi_NCOR1', 'Kasumi_IgG', file('/mnt/Data/cut_and_tag/work/9f/7c3680a1ff0ae0a5a27f42e1a27225/Kasumi_NCOR1.no0.bedgraph')],
            ['Kasumi_IgG', 'Kasumi_IgG', file('/mnt/Data/cut_and_tag/work/21/1038cd4ecbc5b3f88da23ad1ee3147/Kasumi_IgG.no0.bedgraph')],
            ['Kasumi_H4K5', 'Kasumi_IgG', file('/mnt/Data/cut_and_tag/work/3d/7b5239ab9dc83b00f992fea8926630/Kasumi_H4K5.no0.bedgraph')],
        ) \
        .branch { sample1, sample2, bedgraph ->
            controls: sample1 == sample2
                return tuple( sample1, sample2, bedgraph )
            others: true
                return tuple( sample1, sample2, bedgraph )
        } \
        .set { inputs } 
    
    inputs.controls.view { "controls: $it" } 
    inputs.others.view { "others: $it" }
    

    结果:

    others: [Kasumi_H3K36, Kasumi_IgG, /mnt/Data/cut_and_tag/work/d0/3db2bde9eb1bdb0578073fb128bc4c/Kasumi_H3K36.no0.bedgraph]
    controls: [Kasumi_IgG, Kasumi_IgG, /mnt/Data/cut_and_tag/work/21/1038cd4ecbc5b3f88da23ad1ee3147/Kasumi_IgG.no0.bedgraph]
    others: [Kasumi_JMJD1C, Kasumi_IgG, /mnt/Data/cut_and_tag/work/b1/dffe2120acda5b05860e1a3bb0c1bf/Kasumi_JMJD1C.no0.bedgraph]
    others: [Kasumi_NCOR1, Kasumi_IgG, /mnt/Data/cut_and_tag/work/9f/7c3680a1ff0ae0a5a27f42e1a27225/Kasumi_NCOR1.no0.bedgraph]
    others: [Kasumi_H4K5, Kasumi_IgG, /mnt/Data/cut_and_tag/work/3d/7b5239ab9dc83b00f992fea8926630/Kasumi_H4K5.no0.bedgraph]
    

    来自 cmets 的更新:

    Channel
        .of(
            ['Kasumi_H3K36', 'Kasumi_IgG', file('/path/to/Kasumi_H3K36.no0.bedgraph')],
            ['Kasumi_JMJD1C', 'Kasumi_IgG', file('/path/to/Kasumi_JMJD1C.no0.bedgraph')],
            ['Kasumi_NCOR1', 'Kasumi_IgG', file('/path/to/Kasumi_NCOR1.no0.bedgraph')],
            ['Kasumi_IgG', 'Kasumi_IgG', file('/path/to/Kasumi_IgG.no0.bedgraph')],
            ['Kasumi_H4K5', 'Kasumi_IgG', file('/path/to/Kasumi_H4K5.no0.bedgraph')],
            ['NB4_H3K36', 'NB4_IgG', file('/path/to/NB4_H3K36.no0.bedgraph')],
            ['NB4_JMJD1C', 'NB4_IgG', file('/path/to/NB4_JMJD1C.no0.bedgraph')],
            ['NB4_NCOR1', 'NB4_IgG', file('/path/to/NB4_NCOR1.no0.bedgraph')],
            ['NB4_IgG', 'NB4_IgG', file('/path/to/NB4_IgG.no0.bedgraph')],
            ['NB4_H4K5', 'NB4_IgG', file('/path/to/NB4_H4K5.no0.bedgraph')],
        ) \
        .branch { test_sample, control_sample, bedgraph ->
            control_samples: test_sample == control_sample
                return tuple( control_sample, tuple( test_sample, bedgraph ) )
            test_samples: true
                return tuple( control_sample, tuple( test_sample, bedgraph ) )
        } \
        .set { inputs }
    
    inputs.test_samples
        .combine( inputs.control_samples, by: 0 ) \
        .map { group, test_tuple, control_tuple ->
            tuple( *test_tuple, *control_tuple )
        } \
        .view()
    

    结果:

    [Kasumi_H3K36, /path/to/Kasumi_H3K36.no0.bedgraph, Kasumi_IgG, /path/to/Kasumi_IgG.no0.bedgraph]
    [Kasumi_JMJD1C, /path/to/Kasumi_JMJD1C.no0.bedgraph, Kasumi_IgG, /path/to/Kasumi_IgG.no0.bedgraph]
    [Kasumi_NCOR1, /path/to/Kasumi_NCOR1.no0.bedgraph, Kasumi_IgG, /path/to/Kasumi_IgG.no0.bedgraph]
    [Kasumi_H4K5, /path/to/Kasumi_H4K5.no0.bedgraph, Kasumi_IgG, /path/to/Kasumi_IgG.no0.bedgraph]
    [NB4_H3K36, /path/to/NB4_H3K36.no0.bedgraph, NB4_IgG, /path/to/NB4_IgG.no0.bedgraph]
    [NB4_JMJD1C, /path/to/NB4_JMJD1C.no0.bedgraph, NB4_IgG, /path/to/NB4_IgG.no0.bedgraph]
    [NB4_NCOR1, /path/to/NB4_NCOR1.no0.bedgraph, NB4_IgG, /path/to/NB4_IgG.no0.bedgraph]
    [NB4_H4K5, /path/to/NB4_H4K5.no0.bedgraph, NB4_IgG, /path/to/NB4_IgG.no0.bedgraph]
    

    【讨论】:

    • 非常感谢!
    • 今天我创建了一个新的 conda 环境来做我的管道。该代码昨天使用基本环境通过,但今天使用新环境出现错误。错误:[warm up] executor > local ERROR ~ No signature of method: groovyx.gpars.dataflow.DataflowQueue.branch() 适用于参数类型:(_nf_script_a5c6c25c$_run_closure11) 值:[_nf_script_a5c6c25c$_run_closure11@20f6f88c] 可能的解决方案: each(groovy.lang.Closure), mean(), print(), any(), bind(java.lang.Object), any(groovy.lang.Closure)
    • @Shikan:别担心,你用的是什么版本的Nextflow?分支需要19.08.0-edge 或更高版本。
    • Nextflow 版本为 19.01.0
    • @Shikan:是的,您需要更新版本才能使用分支运算符。试试nextflow self-update
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-06-30
    • 1970-01-01
    • 1970-01-01
    • 2021-07-31
    • 2022-11-11
    • 1970-01-01
    • 2021-12-03
    相关资源
    最近更新 更多