Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • yksikaksi
    Member
    • Dec 2009
    • 20

    How can I parse these reads

    Code:
    ::::::::::::::
    0H.ptFlagstat.txt
    ::::::::::::::
    49080460 + 0 in total 
    0 + 0 duplicates
    6444347 + 0 mapped (13.13%:nan%)
    49080460 + 0 paired in sequencing
    45547041 + 0 read1  
    3533419 + 0 read2   
    5822436 + 0 properly paired (11.86%:nan%)  ***
    5822436 + 0 with itself and mate mapped
    621911 + 0 singletons (1.27%:nan%)
    Good day.

    I would like to parse the paired reads (***) from PCR duplicates removed sorted BAM files. I knew SAMtools or Picard tools can do that, however, I'm not sure what function or what option I should use.

    Could anyone kindly please contribute the idea(s) or command line(s) or advice?

    Thank you very much.
  • maubp
    Peter (Biopython etc)
    • Jul 2009
    • 1544

    #2
    PCR duplicates are marked in SAM/BAM as part of the read's FLAG entry (one of the bits).

    You can use 'samtools view' with the -f and/or -F switches to filter reads based on their FLAG values.

    By default 'samtools view' does BAM to SAM, but it can do SAM to SAM or BAM to BAM as well which is more sensible for filtering.

    Comment

    • swbarnes2
      Senior Member
      • May 2008
      • 910

      #3
      What exactly are you trying to parse?

      You can use samtools view and filter by flags (-f or -F) to break out particular kinds of reads based ontheri flags. You can use samtools view to make a .sam, and pipe that straight into a program like awk or grep.

      Code:
      samtools view file.bam | grep whatever - > grepped.sam

      Comment

      • yksikaksi
        Member
        • Dec 2009
        • 20

        #4
        I want to exclude unmapped reads from the PCR duplicates removed BAM file (done by Picard MarkDuplicates tools) before carry on to downstream analysis. Thanks for the replied and suggestions. Appreciate that!

        Comment

        • swbarnes2
          Senior Member
          • May 2008
          • 910

          #5
          Code:
          samtools view -bF 4 file.bam > mapped.bam
          will make a new .bam that has only mapped reads.

          the -F 4 means that it will exclude entries in your .bam that have the 4 flagged in the binary flag; 4 is the code for unmapped read. The -b means that it will output a .bam, instead of a .sam, which is the default behavior for samtools view.

          Comment

          • yksikaksi
            Member
            • Dec 2009
            • 20

            #6
            Thanks for the code and the explanation. Thanks a lot.

            Comment

            Latest Articles

            Collapse

            • GATTACAT
              Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
              by GATTACAT
              Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
              07-01-2026, 11:43 AM
            • SEQadmin2
              Nine Things a Sample Prep Scientist Thinks About Before Sequencing
              by SEQadmin2


              I’m not a sequencing expert. I’m a purification scientist who uses NGS to evaluate workflows my group develops. With this perspective, we think about the sample first and the NGS workflow second. The sequencer is an exceptionally honest reporter, but it can only report on what you give it, so whether you get clean, interpretable data from an NGS workflow is largely determined before you begin.

              Here are nine questions we think about, in roughly the order they matter, before...
              06-18-2026, 07:11 AM

            ad_right_rmr

            Collapse

            News

            Collapse

            Topics Statistics Last Post
            Started by SEQadmin2, 07-02-2026, 11:08 AM
            0 responses
            18 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 06-30-2026, 05:37 AM
            0 responses
            19 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 06-26-2026, 11:10 AM
            0 responses
            21 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 06-17-2026, 06:09 AM
            0 responses
            54 views
            0 reactions
            Last Post SEQadmin2  
            Working...