Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thedamian
    Member
    • Feb 2012
    • 50

    #1

    mapped reads statistics (from .bam)

    Hi,

    Do you know if it is possible to obtain such statistics from the .bam file:

    Total Unique - total reads aligning to only a single location in the reference
    U0 - # of unique hits with 0 mismatches
    U1 - # of unique hits with 1 mismatches
    U2 - # of unique hits with 2 mismatches
    R012 - # of hits aligning to multiple location in the reference with 0,1 or 2 mismatches
    NM - # of reads without a match to the reference

    (I know samtools flagstat but it is not what I need)

    Thanks in advance
  • dpryan
    Devon Ryan
    • Jul 2011
    • 3478

    #2
    Yes, it's possible, but something like samtools flagstat won't produce that. You could code something easily enough, though. Also, think long and hard about what you mean when you write "unique". What you likely really want are reads whose probability of incorrect alignment is sufficiently low (i.e., their MAPQ is sufficiently high).

    Comment

    • Michael.Ante
      Senior Member
      • Oct 2011
      • 127

      #3
      You can use awk or perl to count your frequencies with an associative array. If you have the computational resources, you may count the reads occurring only once in your alignment. This can lead to problems, dpryan already mentioned.
      Moreover, you should have a look at the fields in the sam-file's alignment section, which were set by your aligner.
      The number of mismatches can be extracted from the CIGAR-string or directly found in the NM-field. Some aligners are clipping the reads; the clipping is not represented in the NM-field.

      Just have a look at http://samtools.sourceforge.net/SAM1.pdf for further information.

      Comment

      • dpryan
        Devon Ryan
        • Jul 2011
        • 3478

        #4
        A warning regarding the CIGAR field is that mismatches are typically not indicated unless they're indels. A few aligners, such as BBMap, can be told to include this information in the cigar string, but you're otherwise stuck parsing the MD auxiliary tag (remember that the NM tag indicates the edit distance, which can include indels...whether those should be included in the counts depends on ones goals).

        BTW, I'd recommend using the pysam module in python, since you then don't have to reinvent the wheel in terms of parsing the alignments.

        Comment

        • jwfoley
          Senior Member
          • Jun 2009
          • 183

          #5
          Originally posted by dpryan View Post
          Also, think long and hard about what you mean when you write "unique". What you likely really want are reads whose probability of incorrect alignment is sufficiently low (i.e., their MAPQ is sufficiently high).
          Yes, counting mismatches is not generally a useful thing to do, and "unique" best hits aren't nearly stringent enough; if you want to count confident alignments, the command is "samtools view -cq 10 somefile.bam" (or a more stringent number, but 10 works fine for me).

          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, Yesterday, 11:13 AM
          0 responses
          16 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, Yesterday, 10:48 AM
          0 responses
          15 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-15-2026, 10:52 AM
          0 responses
          35 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-14-2026, 05:39 AM
          0 responses
          42 views
          0 reactions
          Last Post SEQadmin2  
          Working...