Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • malbuquerque
    Junior Member
    • Oct 2013
    • 4

    #1

    samtools piping problem

    Hello SEQanswers,

    My ultimate goal is to pipe multiple different regions of a bam file to different commands in a single command line argument.

    Basically, I am trying to generate some metrics from a BAM file that will be flagged for optical duplicates and then (without storing to disc) I want to pipe each chromosome to a program.

    ex.

    java -jar picard/MarkDuplicates.jar I=test.bam O=/dev/stdout | tee >(samtools view 'chr1' -| ./generate_metrics) >(samtools view 'chr2' -| ./generate_metrics) ...

    any advice if my current implementation isn't the best?
    The issue right now is attempting to pull a segment from the bamfile after an initial pipe.

    Thanks,

    Marco
  • dpryan
    Devon Ryan
    • Jul 2011
    • 3478

    #2
    Well, that works, put the command is going to get really unwieldy. Why don't you either pipe to a perl/python/whatever script and have it pipe accordingly (the input to MarkDuplicates is already sorted, so your script would just need to pipe to one instance of ./generate_metrics at a time) or just rewrite ./generate_metrics to handle multiple chromosomes (assuming you have the source code).

    Comment

    • malbuquerque
      Junior Member
      • Oct 2013
      • 4

      #3
      The idea is to parrallel these operations. So I will ultimately be submitting qsubs for each chromosomes operations, Its just a matter of segmenting the BAM file into its appropriate segments.

      Comment

      • dpryan
        Devon Ryan
        • Jul 2011
        • 3478

        #4
        I'd be a little surprised if piping like that into qsub would actually work. If you want to parcel this out to multiple nodes, why don't you just markDuplicates on a chromosome per node and generate_metrics on that?

        Comment

        • malbuquerque
          Junior Member
          • Oct 2013
          • 4

          #5
          That sound like a great idea

          Thanks! The duplicate algorithm (im assuming) is only looking for reads of the same length and position correct (i.e. there wont be duplicates accross different chromosomes).

          Comment

          • dpryan
            Devon Ryan
            • Jul 2011
            • 3478

            #6
            I think it just looks at the 5' position of both mates in a pair and marks duplicates if there are multiple pairs with the same 5' position(s). I could be misremembering that, though.

            Comment

            • malbuquerque
              Junior Member
              • Oct 2013
              • 4

              #7
              So this is what I'm thinking from what you have told me

              samtools view sample.bam 'chr1' | java -jar $PICARDROOT/MarkDuplicates.jar I= - O=sample_chr1.bam M=metrics_chr1.txt

              Or is there something else I need to pass to I...

              Comment

              • dpryan
                Devon Ryan
                • Jul 2011
                • 3478

                #8
                Yeah, but I'd forgotten that MarkDuplicates can't take input via a pipe, so that won't work. I'm not coming up with a way to do that that doesn't end up involving considerable programming with MPI. Do you have the code for generate_metrics? It would seem easier to just write it to handle multiple contigs. Alternatively, presuming that actually marking the duplicates is the rate limiting step, then just run it on a single node.

                Comment

                • dpryan
                  Devon Ryan
                  • Jul 2011
                  • 3478

                  #9
                  Oh, have a look at Biobambam, which can MarkDuplicates but writes its temp files to a local disk (it's geared more toward clusters). BTW, see also this thread on Biostars.

                  Comment

                  • rhinoceros
                    Senior Member
                    • Apr 2013
                    • 372

                    #10
                    Maybe gnuparallel could solve your parallelization? This thread explains it comprehensively..
                    savetherhino.org

                    Comment

                    Latest Articles

                    Collapse

                    • SEQadmin2
                      Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
                      by SEQadmin2



                      Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

                      Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
                      ...
                      10-14-2026, 09:55 AM
                    • SEQadmin2
                      New Genomics Technologies Take Aim at Long-Standing Limits
                      by SEQadmin2


                      Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

                      We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
                      ...
                      09-28-2026, 10:25 AM

                    ad_right_rmr

                    Collapse

                    News

                    Collapse

                    Topics Statistics Last Post
                    Started by SEQadmin2, 10-15-2026, 10:52 AM
                    0 responses
                    24 views
                    0 reactions
                    Last Post SEQadmin2  
                    Started by SEQadmin2, 10-14-2026, 05:39 AM
                    0 responses
                    30 views
                    0 reactions
                    Last Post SEQadmin2  
                    Started by SEQadmin2, 10-13-2026, 09:56 AM
                    0 responses
                    26 views
                    0 reactions
                    Last Post SEQadmin2  
                    Started by SEQadmin2, 10-09-2026, 11:14 AM
                    0 responses
                    28 views
                    0 reactions
                    Last Post SEQadmin2  
                    Working...