Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • sheremey
    Junior Member
    • Oct 2010
    • 7

    strand-specific bam files

    Hello all,

    I know this must be a very simple and common task, sorry if I've overlooked an existing recommendation while searching the forum.

    Given: BAM file with aligned paired-end reads
    Needed: split it into 2 strand-specific BAM files (first read in each aligned pair should correspond to F strand of the reference in the first BAM file and to the R strand of the reference in the second BAM file).

    Thanks a lot!
  • maubp
    Peter (Biopython etc)
    • Jul 2009
    • 1544

    #2
    Look at the samtools view -f and -F options, you could do this by filtering on the FLAG 0x10 values.

    (If you have paired data things are more interesting...)

    Comment

    • sheremey
      Junior Member
      • Oct 2010
      • 7

      #3
      Originally posted by maubp View Post
      Look at the samtools view -f and -F options, you could do this by filtering on the FLAG 0x10 values.

      (If you have paired data things are more interesting...)
      I believe the FLAG relates to an individual read, right? My first BAM file needs to have first reads aligned to F and second reads to R of the reference. I cannot believe there is no standard solution for this task (that is supposed to be popular in downstream analysis) for paired-end data that is overwhelmingly popular now... Is this indeed the case?

      Comment

      • maubp
        Peter (Biopython etc)
        • Jul 2009
        • 1544

        #4
        I don't know why you would want to do (what popular downstream analysis exactly?), but you could do this with 'samtools view' and the FLAG filters.

        Before spending any effort on this, please clarify if you want file one to have reads like this:

        Code:
               1 ---> 
        =========================
                       <--- 2
        And file two to have:

        Code:
               2 ---> 
        =========================
                       <--- 1

        Comment

        • sheremey
          Junior Member
          • Oct 2010
          • 7

          #5
          Originally posted by maubp View Post
          I don't know why you would want to do (what popular downstream analysis exactly?), but you could do this with 'samtools view' and the FLAG filters.

          Before spending any effort on this, please clarify if you want file one to have reads like this:

          Code:
                 1 ---> 
          =========================
                         <--- 2
          And file two to have:

          Code:
                 2 ---> 
          =========================
                         <--- 1

          Thank you,

          Yes, that's exactly the desired outcome.
          As to downstream analysis, I am talking about investigating on antisense transcription phenomena (given a strand-specific library), which is going to be increasingly popular down the road. Thanks a lot!

          Comment

          • swbarnes2
            Senior Member
            • May 2008
            • 910

            #6
            Put the reads with flags of 99 (read 1, mapped forward, mate mapped reverse, properly paired) and 147(read 2, mapped reverse, properly paired) in file 1, and the reads with flags 83 and 163 in file 2.

            Comment

            • maubp
              Peter (Biopython etc)
              • Jul 2009
              • 1544

              #7
              I concur file one needs:

              0x1 - paired
              0x2 - properly paired
              0x20 - partner on reverse strand
              0x40 - read one
              FLAGs 0x1 + 0x2 + 0x20 + 0x40 = 0x63 = 99 in decimal

              And file one also needs:

              0x1 - paired
              0x2 - properly paired
              0x10 - on reverse strand
              0x80 - read two
              FLAGs 0x1 + 0x2 + 0x10 + 0x80 = 0x93 = 147 in decimal

              So I'd use 'samtools view' twice to get those reads, then 'samtools merge' to combine them into file one.

              Likewise for file two:

              0x1 - paired
              0x2 - properly paired
              0x10 - reverse strand
              0x40 - read one
              FLAGs 0x1 + 0x2 + 0x10 + 0x40 = 0x53 = 83 in decimal

              And file two also needs:

              0x1 - paired
              0x2 - properly paired
              0x30 - partner on reverse strand
              0x80 - read two
              FLAGs 0x1 + 0x2 + 0x20 + 0x80 = 0xA3 = 163 in decimal

              Comment

              • sheremey
                Junior Member
                • Oct 2010
                • 7

                #8
                Originally posted by maubp View Post
                I concur file one needs:

                0x1 - paired
                0x2 - properly paired
                0x20 - partner on reverse strand
                0x40 - read one
                FLAGs 0x1 + 0x2 + 0x20 + 0x40 = 0x63 = 99 in decimal

                And file one also needs:

                0x1 - paired
                0x2 - properly paired
                0x10 - on reverse strand
                0x80 - read two
                FLAGs 0x1 + 0x2 + 0x10 + 0x80 = 0x93 = 147 in decimal

                So I'd use 'samtools view' twice to get those reads, then 'samtools merge' to combine them into file one.

                Likewise for file two:

                0x1 - paired
                0x2 - properly paired
                0x10 - reverse strand
                0x40 - read one
                FLAGs 0x1 + 0x2 + 0x10 + 0x40 = 0x53 = 83 in decimal

                And file two also needs:

                0x1 - paired
                0x2 - properly paired
                0x30 - partner on reverse strand
                0x80 - read two
                FLAGs 0x1 + 0x2 + 0x20 + 0x80 = 0xA3 = 163 in decimal
                Thank you! That's outstanding!

                Comment

                Latest Articles

                Collapse

                ad_right_rmr

                Collapse

                News

                Collapse

                Topics Statistics Last Post
                Started by SEQadmin2, 06-09-2026, 11:58 AM
                0 responses
                22 views
                0 reactions
                Last Post SEQadmin2  
                Started by SEQadmin2, 06-05-2026, 10:09 AM
                0 responses
                29 views
                0 reactions
                Last Post SEQadmin2  
                Started by SEQadmin2, 06-04-2026, 08:59 AM
                0 responses
                39 views
                0 reactions
                Last Post SEQadmin2  
                Started by SEQadmin2, 06-02-2026, 12:03 PM
                0 responses
                61 views
                0 reactions
                Last Post SEQadmin2  
                Working...