1

I am trying to use nextflow pipeline to do a fringerprint(bamCoverage) from deeptool. When I input the bam files and run the script. it says I don't have index files. error: [E::idx_find_and_load] Could not retrieve index file for 'Kasumi_NCOR1.genome.sorted.bam' [E::idx_find_and_load] Could not retrieve index file for 'Kasumi_NCOR1.genome.sorted.bam' 'Kasumi_NCOR1.genome.sorted.bam' does not appear to have an index. You MUST index the file first!

process fingerprint_cov {

    publishDir "${params.outdir}/fingerprint_cov", mode: 'copy'

    input:
    set val(sample_id), file(samples) from sorted_bam_sample_control_ch.samples
    set val(sample_id_c), file(controls) from sorted_bam_sample_control_ch.controls

    output:
    set val(sample_id), file("${sample_id}.cov.bedgraph") into sample_cov_ch
    set val(sample_id_c), file("${sample_id_c}.cov.bedgraph") into control_cov_ch

    script:
    """

    bamCoverage -b ${samples} -o ${sample_id}.cov.bedgraph -of bedgraph -bs 1000 -p 10
    bamCoverage -b ${controls} -o ${sample_id_c}.cov.bedgraph -of bedgraph -bs 1000 -p 10

    """
}

sorted_bam_sample_control_ch.samples has all the sample bam files, and sorted_bam_sample_control_ch.control has the control bam files. How do I input the bam.bai files? I have also seen that output bam and bam.bai to a channel, but how to process this steps?

This is my sample input. but when I run the process it only runs one sample

[Kasumi_H3K36, [/mnt/Data/cut_and_tag/work/0c/24e138a92a1eb0d906e1e9fad9ba4b/Kasumi_H3K36.genome.sorted.bam, /mnt/Data/cut_and_tag/work/0c/24e138a92a1eb0d906e1e9fad9ba4b/Kasumi_H3K36.genome.sorted.bam.bai]]
[Kasumi_H4K5, [/mnt/Data/cut_and_tag/work/7e/a740e11ce39f2a310b749603c785a4/Kasumi_H4K5.genome.sorted.bam, /mnt/Data/cut_and_tag/work/7e/a740e11ce39f2a310b749603c785a4/Kasumi_H4K5.genome.sorted.bam.bai]]
[Kasumi_NCOR1, [/mnt/Data/cut_and_tag/work/b8/e91ff7c7aea0fa3a0814530ab07972/Kasumi_NCOR1.genome.sorted.bam, /mnt/Data/cut_and_tag/work/b8/e91ff7c7aea0fa3a0814530ab07972/Kasumi_NCOR1.genome.sorted.bam.bai]]
[Kasumi_JMJD1C, [/mnt/Data/cut_and_tag/work/49/99ebe402d2b1953a95968525e258f6/Kasumi_JMJD1C.genome.sorted.bam, /mnt/Data/cut_and_tag/work/49/99ebe402d2b1953a95968525e258f6/Kasumi_JMJD1C.genome.sorted.bam.bai]]

Here is the control input

[Kasumi_IgG, [/mnt/Data/cut_and_tag/work/0e/1cd7aefd90105205e58fb6ef912aa4/Kasumi_IgG.genome.sorted.bam, /mnt/Data/cut_and_tag/work/0e/1cd7aefd90105205e58fb6ef912aa4/Kasumi_IgG.genome.sorted.bam.bai]]

1 Answer 1

0

You'll need to index your BAM files first if the index (.bai) files don't already exist. You can use samtools index <bam> for this.

Then all you would need to do is input these into your process somehow. Rather than having a separate variable in each of your input sets/tuples, what I find works quite nicely is grouping the BAM files and their indexes in a tuple of the form: tuple( bam, bai )

Then your process might look like:

process fingerprint_cov {

    publishDir "${params.outdir}/fingerprint_cov", mode: 'copy'

    input:
    set val(test_sample_id), file(indexed_test_bam) from sorted_bam_sample_control_ch.samples
    set val(control_sample_id), file(indexed_control_bam) from sorted_bam_sample_control_ch.controls

    output:
    set val(test_sample_id), file("${test_sample_id}.cov.bedgraph") into sample_cov_ch
    set val(control_sample_id), file("${control_sample_id}.cov.bedgraph") into control_cov_ch

    script:
    def test_bam = indexed_test_bam.first()
    def control_bam = indexed_control_bam.first()

    """
    bamCoverage -b "${test_bam}" -o "${sample_id}.cov.bedgraph" -of bedgraph -bs 1000 -p 10
    bamCoverage -b "${control_bam}" -o "${sample_id_c}.cov.bedgraph" -of bedgraph -bs 1000 -p 10
    """
}
8
  • Only one of my samples went through. Why is that happened?
    – Shikan
    Dec 24, 2020 at 6:24
  • I suspect it might have something to do with multiple input channels. Please see: Understand how multiple input channels work. You may also want to edit your question to include a view() of your input channels.
    – Steve
    Dec 24, 2020 at 9:15
  • the script you advise is working, but only one of the sample went through. I edited the question and provided the sample input channel view
    – Shikan
    Jan 2, 2021 at 0:17
  • Sorry @Shikan, can I just check - is that the output of sorted_bam_sample_control_ch.samples.view()? What does your other input channel look like? I.e. what's the output of sorted_bam_sample_control_ch.controls.view()? If you could clarify that would be great - thanks!
    – Steve
    Jan 2, 2021 at 12:55
  • 1
    It is a different case. Last one was using sample to compare to the control. This time is two process. I did solve this by splitting into two processes. Thank you!
    – Shikan
    Jan 3, 2021 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.