Seqanswers Leaderboard Ad

Collapse

Announcement

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

  • 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

  • #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


    • #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

      • seqadmin
        Current Approaches to Protein Sequencing
        by seqadmin


        Proteins are often described as the workhorses of the cell, and identifying their sequences is key to understanding their role in biological processes and disease. Currently, the most common technique used to determine protein sequences is mass spectrometry. While still a valuable tool, mass spectrometry faces several limitations and requires a highly experienced scientist familiar with the equipment to operate it. Additionally, other proteomic methods, like affinity assays, are constrained...
        04-04-2024, 04:25 PM
      • seqadmin
        Strategies for Sequencing Challenging Samples
        by seqadmin


        Despite advancements in sequencing platforms and related sample preparation technologies, certain sample types continue to present significant challenges that can compromise sequencing results. Pedro Echave, Senior Manager of the Global Business Segment at Revvity, explained that the success of a sequencing experiment ultimately depends on the amount and integrity of the nucleic acid template (RNA or DNA) obtained from a sample. “The better the quality of the nucleic acid isolated...
        03-22-2024, 06:39 AM

      ad_right_rmr

      Collapse

      News

      Collapse

      Topics Statistics Last Post
      Started by seqadmin, 04-11-2024, 12:08 PM
      0 responses
      27 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 04-10-2024, 10:19 PM
      0 responses
      30 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 04-10-2024, 09:21 AM
      0 responses
      26 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 04-04-2024, 09:00 AM
      0 responses
      52 views
      0 likes
      Last Post seqadmin  
      Working...
      X