Unconfigured Ad

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

    #1

    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

                • 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
                • SEQadmin2
                  Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
                  by SEQadmin2



                  Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
                  ...
                  07-09-2026, 11:10 AM
                • SEQadmin2
                  Cancer Drug Resistance: The Lingering Barrier to Rising Survival
                  by SEQadmin2



                  Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

                  There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
                  07-08-2026, 05:17 AM

                ad_right_rmr

                Collapse

                News

                Collapse

                Topics Statistics Last Post
                Started by SEQadmin2, 07-24-2026, 12:17 PM
                0 responses
                10 views
                0 reactions
                Last Post SEQadmin2  
                Started by SEQadmin2, 07-23-2026, 11:41 AM
                0 responses
                11 views
                0 reactions
                Last Post SEQadmin2  
                Started by SEQadmin2, 07-20-2026, 11:10 AM
                0 responses
                23 views
                0 reactions
                Last Post SEQadmin2  
                Started by SEQadmin2, 07-13-2026, 10:26 AM
                0 responses
                37 views
                0 reactions
                Last Post SEQadmin2  
                Working...