Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gene_x
    Senior Member
    • May 2010
    • 108

    #1

    how to get reads with "mate mapped to a different chr"

    In the output of
    Code:
    samtools flagstat input.bam
    There is these last two lines:

    HTML Code:
    xxx +0 with mate mapped to a different chr
    xxx +0 with mate mapped to a different chr (mapQ>=5)
    I'm wondering what's the FLAG for "mate mapped to a different chr"?
  • Brian Bushnell
    Super Moderator
    • Jan 2014
    • 2709

    #2
    There is no flag; you compare "rname" with "rnext". If they are the same, or "rnext" is "=", and they are both mapped (0x1 set, 0x4 and 0x8 not set) then they are on the same sequence. They are mapped to different sequences if both are mapped but rnext is not "=" and not equal to rname.

    Comment

    • gene_x
      Senior Member
      • May 2010
      • 108

      #3
      Originally posted by Brian Bushnell View Post
      There is no flag; you compare "rname" with "rnext". If they are the same, or "rnext" is "=", and they are both mapped (0x1 set, 0x4 and 0x8 not set) then they are on the same sequence.
      oh, i see. Thanks!

      Comment

      • Richard Finney
        Senior Member
        • Feb 2009
        • 701

        #4
        Good question.

        Consult the Sam format documentation.



        Section 1.4 contains the bitwise flag descriptions.

        Note that not all software properly sets these flags.

        I guess you'd check the 0x4 and 0x8 flags ( 0x4=segment unmapped, 0x8=segment unmapped). If both unmapped then check if field 3 (RNAME) is not same as field 7 (RNEXT) [and 8 field is not '*' and not '='] .

        There are various "FIXMATE" programs running around; you may wish to use.

        I'm not sure about 0x800 flag (not same as 0x8). "Chimeric" I'm guessing doesn't always mean same chromosome.
        Last edited by Richard Finney; 01-12-2015, 12:24 PM.

        Comment

        • Brian Bushnell
          Super Moderator
          • Jan 2014
          • 2709

          #5
          Originally posted by Richard Finney View Post
          I'm not sure about 0x800 flag (not same as 0x8). "Chimeric" i'm guessing doesn't always mean same chromosome.
          I don't think the answer is fully defined for either chimeric or secondary alignments.

          Comment

          • gene_x
            Senior Member
            • May 2010
            • 108

            #6
            Originally posted by Brian Bushnell View Post
            I don't think the answer is fully defined for either chimeric or secondary alignments.
            I'm actually pretty confused about what is "secondary alignment".. can you clarify it a little bit?

            Also, in the attached image, I don't understand how the entry in the second column equals to that in the first column? For example, 0x0001 and p are supposed to represent the same thing I guess? what's the encoding conversion rules here? And where is the string representation used? In BAM files?
            Attached Files

            Comment

            • Brian Bushnell
              Super Moderator
              • Jan 2014
              • 2709

              #7
              I have not seen that string notation before ("p", "P", etc) and it's not part of the SAM specification as far as I know. Reads are supposed to have at most one primary alignment; if a read maps to multiple locations, it can have multiple secondary alignments (0x100 flag bit). But reads can also have multiple 0x800 "supplementary" alignments, a new feature of the sam format which is rather confusing.

              Comment

              • gene_x
                Senior Member
                • May 2010
                • 108

                #8
                Originally posted by Brian Bushnell View Post
                I have not seen that string notation before ("p", "P", etc) and it's not part of the SAM specification as far as I know. Reads are supposed to have at most one primary alignment; if a read maps to multiple locations, it can have multiple secondary alignments (0x100 flag bit). But reads can also have multiple 0x800 "supplementary" alignments, a new feature of the sam format which is rather confusing.
                Yeah, the documentation is very limited and confusing. I have to search online for a few tutorials to get an OK understanding of bitwise FLAG..

                I'm confused.. what does supplementary alignment mean?

                Comment

                • Brian Bushnell
                  Super Moderator
                  • Jan 2014
                  • 2709

                  #9
                  In practice, if you run bwa, it means a chimeric alignment, in which there are multiple local alignments that are not very close to each other. I am not aware of any other aligners that generate it.

                  Comment

                  • gene_x
                    Senior Member
                    • May 2010
                    • 108

                    #10
                    Originally posted by Brian Bushnell View Post
                    In practice, if you run bwa, it means a chimeric alignment, in which there are multiple local alignments that are not very close to each other. I am not aware of any other aligners that generate it.
                    I see. Thanks.

                    Comment

                    • dpryan
                      Devon Ryan
                      • Jul 2011
                      • 3478

                      #11
                      Originally posted by Brian Bushnell View Post
                      I have not seen that string notation before ("p", "P", etc) and it's not part of the SAM specification as far as I know.
                      It's been deprecated. Back in the day, there was a multicharacter version of the FLAG field available from samtools. That was done away with after the conversion to htslib (I'm pretty sure it was still there in 0.1.19). The only thing I've ever seen use those is BS-Seeker2, in fact.

                      Comment

                      • gene_x
                        Senior Member
                        • May 2010
                        • 108

                        #12
                        Originally posted by dpryan View Post
                        It's been deprecated. Back in the day, there was a multicharacter version of the FLAG field available from samtools. That was done away with after the conversion to htslib (I'm pretty sure it was still there in 0.1.19). The only thing I've ever seen use those is BS-Seeker2, in fact.
                        I see. Good to know!

                        Comment

                        • splaisan
                          senior molecular biologist
                          • Jun 2009
                          • 32

                          #13
                          one way to get it

                          see https://www.biostars.org/p/17575/#327644
                          http://www.bits.vib.be/index.php

                          Comment

                          Latest Articles

                          Collapse

                          • SEQadmin2
                            Beyond CRISPR/Cas9: Understand, Choose, and Use the Right Genome Editing Tool
                            by SEQadmin2



                            CRISPR/Cas9 sparked the gene editing revolution for both research and therapeutics.1 But this system still showed severe issues that limited its applications. The most prominent were the heavy reliance on PAM sequences, delivery limitations, double-stranded breaks that prompt unintended edits and cell death, and editing inefficiency (both in targeting and in knock-in reliability).

                            Despite this, “CRISPR helped turn genome editing from a specialized technique into
                            ...
                            07-31-2026, 11:01 AM
                          • SEQadmin2
                            Proteomic Platforms: How to Choose the Right Analytical Strategy to Improve Detection and Clinical Applications
                            by SEQadmin2


                            Proteomics platforms are evolving rapidly, with advances in mass spectrometry and affinity-based approaches expanding what researchers can detect and at what scale. As the field moves toward deeper proteome coverage and clinical applications, scientists face an increasingly complex landscape of tools. This article will explore how researchers are navigating these choices to find the right platform for their work.

                            The systematic characterization of the human proteome has
                            ...
                            07-20-2026, 11:48 AM

                          ad_right_rmr

                          Collapse

                          News

                          Collapse

                          Topics Statistics Last Post
                          Started by SEQadmin2, 08-06-2026, 07:41 AM
                          0 responses
                          16 views
                          0 reactions
                          Last Post SEQadmin2  
                          Started by SEQadmin2, 08-03-2026, 10:13 AM
                          0 responses
                          32 views
                          0 reactions
                          Last Post SEQadmin2  
                          Started by SEQadmin2, 07-31-2026, 02:55 AM
                          0 responses
                          42 views
                          0 reactions
                          Last Post SEQadmin2  
                          Started by SEQadmin2, 07-24-2026, 12:17 PM
                          0 responses
                          26 views
                          0 reactions
                          Last Post SEQadmin2  
                          Working...