Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • paperblu
    Junior Member
    • Jul 2014
    • 2

    #1

    extract strand information from bam file in a specific position

    Hi All
    I am new on this Forum and I have an issue that I hope you can help me to solve.
    I have strand specific paired-end RNA sequencing and I would like to extract the strand information of reads that fall in a particular genomic region (from bam file)
    Obviously I have to consider the first in pair to determine the strand orientation (because in paired-end one of reads is always on the opposite strand).

    For example, I would like to know if reads falling in chr1:122592431-123294331 are located in plus or minus strand (in bam file).

    How would you do it?Any suggestion?

    Thank you
  • dariober
    Senior Member
    • May 2010
    • 311

    #2
    Originally posted by paperblu View Post
    Hi All
    I am new on this Forum and I have an issue that I hope you can help me to solve.
    I have strand specific paired-end RNA sequencing and I would like to extract the strand information of reads that fall in a particular genomic region (from bam file)
    Obviously I have to consider the first in pair to determine the strand orientation (because in paired-end one of reads is always on the opposite strand).

    For example, I would like to know if reads falling in chr1:122592431-123294331 are located in plus or minus strand (in bam file).

    How would you do it?Any suggestion?

    Thank you
    It's a bit unclear to me what output format you want. If you want to know how many first-in-pair alignments in a region map to the forward and to the reverse strand, you could use something on these lines:

    Code:
    region='chr1:1-10000'
    bam='myaln.bam'
    
    samtools view -f 64 -F 4 $bam $region \
    | gawk '{if (and($2, 16)) {cnt_reverse++} else {cnt_forward++}}END{print "Reads on forward: " cnt_forward "\nReads on reverse: " cnt_reverse}' 
    
    ## Example output:
    Reads on forward: 2970
    Reads on reverse: 3950

    Comment

    • paperblu
      Junior Member
      • Jul 2014
      • 2

      #3
      Hi dariober
      thank you for your reply and I am sorry if I have been a little unclear.
      But yes, my desired output should be something like your (I would like to obtain the number just of reads firs in pair or second in pair, that are, if I am correct, reads that mark genes in positive strand or negative).

      I made this:

      Code:
      samtools view -b $mybam $myregion | samtools view -f 0x0040 - | wc -l | awk '{ print$0"\t+"}'
      output

      Code:
      7    +
      That means that in $myregion I have 7 reads first in pair.Isn't it?
      The problem is that for each coordinate I have to perfom the command twice to know first in pair and second in pair.
      Any other suggestion ?

      Thank you

      Comment

      Latest Articles

      Collapse

      • SEQadmin2
        Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
        by SEQadmin2



        Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

        Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
        ...
        10-14-2026, 09:55 AM
      • SEQadmin2
        New Genomics Technologies Take Aim at Long-Standing Limits
        by SEQadmin2


        Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

        We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
        ...
        09-28-2026, 10:25 AM

      ad_right_rmr

      Collapse

      News

      Collapse

      Topics Statistics Last Post
      Started by SEQadmin2, Yesterday, 11:13 AM
      0 responses
      19 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, Yesterday, 10:48 AM
      0 responses
      18 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 10-15-2026, 10:52 AM
      0 responses
      36 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 10-14-2026, 05:39 AM
      0 responses
      42 views
      0 reactions
      Last Post SEQadmin2  
      Working...