Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #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


    • #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


      • #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


        • #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

          • seqadmin
            Recent Advances in Sequencing Analysis Tools
            by seqadmin


            The sequencing world is rapidly changing due to declining costs, enhanced accuracies, and the advent of newer, cutting-edge instruments. Equally important to these developments are improvements in sequencing analysis, a process that converts vast amounts of raw data into a comprehensible and meaningful form. This complex task requires expertise and the right analysis tools. In this article, we highlight the progress and innovation in sequencing analysis by reviewing several of the...
            05-06-2024, 07:48 AM
          • seqadmin
            Essential Discoveries and Tools in Epitranscriptomics
            by seqadmin




            The field of epigenetics has traditionally concentrated more on DNA and how changes like methylation and phosphorylation of histones impact gene expression and regulation. However, our increased understanding of RNA modifications and their importance in cellular processes has led to a rise in epitranscriptomics research. “Epitranscriptomics brings together the concepts of epigenetics and gene expression,” explained Adrien Leger, PhD, Principal Research Scientist...
            04-22-2024, 07:01 AM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by seqadmin, Yesterday, 06:57 AM
          0 responses
          12 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 05-06-2024, 07:17 AM
          0 responses
          16 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 05-02-2024, 08:06 AM
          0 responses
          19 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 04-30-2024, 12:17 PM
          0 responses
          24 views
          0 likes
          Last Post seqadmin  
          Working...
          X