Announcement

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

  • samtools flagstat mismatch in stats

    Hi all,
    I have a bam file created from illumina alignments with bwa. When I try to get the number of aligned reads 2 different ways I get 2 different numbers...

    When I run flagstat:
    samtools flagstat myBam.bam
    I get this many mapped reads
    41721001 mapped (93.82%)

    However when I try to get this on my own with this command:
    samtools view myBam.bam | awk -F '\t' '($3 != "*")' | wc -l
    I get this number
    42283661

    I'm sure I'm doing something wrong, but not sure what. Is it incorrect to think that all reads with a non '*' listed in the third column should be considered aligned?

    thanks for the help!

  • #2
    Originally posted by rcorbett View Post
    Hi all,
    I have a bam file created from illumina alignments with bwa. When I try to get the number of aligned reads 2 different ways I get 2 different numbers...

    When I run flagstat:
    samtools flagstat myBam.bam
    I get this many mapped reads
    41721001 mapped (93.82%)

    However when I try to get this on my own with this command:
    samtools view myBam.bam | awk -F '\t' '($3 != "*")' | wc -l
    I get this number
    42283661

    I'm sure I'm doing something wrong, but not sure what. Is it incorrect to think that all reads with a non '*' listed in the third column should be considered aligned?

    thanks for the help!
    You want:
    Code:
    samtools view -f 4 myBam.bam | wc -l
    See the FLAG field in the SAM spec.

    Comment


    • #3
      When the flag field is '*', does it mean an unmapped read? I know that a flag 4 is definitely unmapped.
      --
      bioinfosm

      Comment


      • #4
        Originally posted by bioinfosm View Post
        When the flag field is '*', does it mean an unmapped read? I know that a flag 4 is definitely unmapped.
        The '*' in the flag field is invalid, and does not conform to the specification (see the "Note" in Section 2.2.1).

        Comment

        Latest Articles

        Collapse

        • seqadmin
          Advanced Methods for the Detection of Infectious Disease
          by seqadmin




          The recent pandemic caused worldwide health, economic, and social disruptions with its reverberations still felt today. A key takeaway from this event is the need for accurate and accessible tools for detecting and tracking infectious diseases. Timely identification is essential for early intervention, managing outbreaks, and preventing their spread. This article reviews several valuable tools employed in the detection and surveillance of infectious diseases.
          ...
          11-27-2023, 01:15 PM
        • seqadmin
          Strategies for Investigating the Microbiome
          by seqadmin




          Microbiome research has led to the discovery of important connections to human and environmental health. Sequencing has become a core investigational tool in microbiome research, a subject that we covered during a recent webinar. Our expert speakers shared a number of advancements including improved experimental workflows, research involving transmission dynamics, and invaluable analysis resources. This article recaps their informative presentations, offering insights...
          11-09-2023, 07:02 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, Yesterday, 10:48 AM
        0 responses
        16 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 11-29-2023, 08:26 AM
        0 responses
        12 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 11-29-2023, 08:12 AM
        0 responses
        13 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 11-27-2023, 08:12 AM
        0 responses
        21 views
        0 likes
        Last Post seqadmin  
        Working...
        X