Hi, I'm trying to use the `clair3` module for vari...
# nostupidquestions
i
Hi, I'm trying to use the
clair3
module for variant calling on several files but I'm struggling with getting it to run for each of my input file sets. I have a feeling it is about value vs queue channels but I'm not sure which of my inputs is the issue. Could someone point me in the right direction? I'll include details in the thread.
✅ 1
This is how I'm running
clair3
:
Copy code
result = CLAIR3(
            ch_input_clair3,    
            fasta,              
            fai.fai        
        )
The first two entries of
ch_input_clair3
look like this:
Copy code
[[id:boss_8_bc15_hschr22], boss_8_bc15_hschr22.bam, boss_8_bc15_hschr22.bam.bai, r1041_e82_400bps_hac_v500, [], ont]
[[id:boss_8_bc30_hschr12], boss_8_bc30_hschr12.bam, boss_8_bc30_hschr12.bam.bai, r1041_e82_400bps_hac_v500, [], ont]
fasta
looks like this:
Copy code
[[id:Homo_sapiens], Homo_sapiens.GRCh38.fa]
and
fai.fai
looks like this:
Copy code
[[id:Homo_sapiens], Homo_sapiens.GRCh38.fa.fai]
What do I need to do so clair3 runs for each of my input file sets? Thank you in advance
n
The easiest would maybe be to put all inputs into one channel, and then
multiMap
to create the inputs:
Copy code
clair3_in = all_inputs.multiMap {
meta, bam, bai, readmode, ont, fasta, fai -> 
    sample: [meta, bam, bai, readmode, [], ont]
    fasta: [[id: "Hs"], fasta]
    fai: [[id: "Hs"], fai]
}
CLAIR3(clair3_in.sample, clair3_in.fasta, clair3_in.fai)
i
That's a great suggestion, thank you. I'll try it and see if that fixes it
Do I put all inputs into one channel by using a combine operator?
n
That is probably easiest
gratitude thank you 1
I am not sure where your ref comes from, maybe you can also use
"${params.something}"
in the closure, to avoid combining
Maybe that is not super clear, what I mean is:
Copy code
clair3_in = all_inputs.multiMap {
meta, bam, bai, readmode, ont -> 
    sample: [meta, bam, bai, readmode, [], ont]
    fasta: [[id: "Hs"], "${params.reference_fa}"]
    fai: [[id: "Hs"], "${params.reference_index}"]
}
CLAIR3(clair3_in.sample, clair3_in.fasta, clair3_in.fai)
a
Are you seeing any errors? I use this module in my own pipeline and there shouldn't be any problems if it's receiving the right input shape.
I would personally go for using
collect()
on your reference channels to ensure a single-value channel rather than the multimap approach (I know others like this but it feels very janky to me and I don't trust it)
n
Is your distrust on multiMap based on some bad experience?
a
I'm mostly just unconvinced (for no reason) that they are 100% guaranteed to output each channel in the same order they were generated in (many other uses involve setting each channel to some dynamic value rather than creating channels of N repeats) . And given that generating a value channel with
.collect()
either works or fails loud (because multiple items would cause a weird shape) I see it as a safer alternative that. Also
collect
is just the more widely used pattern for these reference channels in nf-core
👍 1
i
@Arthur Is your suggestion to do something like the following?
Copy code
result = CLAIR3(
            ch_input_clair3,    
            fasta.collect(),              
            fai.fai.collect()        
        )
I just tried that and it failed with this error:
Missing process or function view([DataflowStream[?], DataflowStream[?], DataflowStream[?], DataflowStream[?], DataflowStream[?], DataflowStream[?], DataflowStream[?]])
I also couldn't make the multimap work, it complained with the same error. I'll include more of my code on how I generated the channels, maybe there's something there
👍 1
Copy code
workflow BENCHMARK_HUMAN_VCF{
    take:
        ch_input_bam // tuple (bam, bai)
        ref // path
    main:
        // Model and platform presets
        model_presets = [
            ont: 'ont',
            pacbio: 'hifi',
            hifi: 'hifi'
        ]

        platform_presets = [
            ont: 'ont',
            pacbio: 'hifi',
            hifi: 'hifi'
        ]

        // Resolve model and platform
        resolved_model = params.clair3_model ?: model_presets[params.sequencing_platform] ?: 'ont'
        resolved_platform = platform_presets[params.sequencing_platform] ?: 'ont'

        // Prepare input channel with resolved values
        ch_input_clair3 = ch_input_bam.map { bam, bai ->
            tuple(
                [id:bam.simpleName],
                bam,
                bai,
                resolved_model,      // packaged_model
                [],                  // user_model (empty for packaged models)
                resolved_platform    // platform
            )
        }


        fasta = ref.map{ it -> tuple([id:it.simpleName], it)}.collect()
        fai_in_ch = fasta.map{meta, fa -> tuple(meta, fa, [])}
        fai = SAMTOOLS_FAIDX(fai_in_ch, false).fai.collect()

        result = CLAIR3(
            ch_input_clair3, 
            fasta,     
            fai      
        )
}
a
Ok so to me (on mobile) that last workflow snippet looks ok I think
i
I think I found the issue. The error above was thrown by my naive attempt at understanding the output from CLAIR3, which was a line at the very end with
result.view()
but that apparently doesn't work for a set of output channels, I have amended that to
result.vcf.view()
and now it seems to run for all of the input bam/bai file sets. Thank you both for your suggestions!
a
Yes that would do it
Glad you solved it