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
        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
        ...
        Yesterday, 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
      • 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

      ad_right_rmr

      Collapse

      News

      Collapse

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