Seqanswers Leaderboard Ad

Collapse

Announcement

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

  • read strand

    Hi NGS users,
    is there a way (by using bioperl module of samtools) to extract the information about the strand of the reads using a bam alignment?
    Thanx a lot!
    ME

  • #2
    I don't know how to do it in perl, but I've done it in python using pysam. You can take a look at:
    franklin library for NGS sequencing analysis. Contribute to JoseBlanca/franklin development by creating an account on GitHub.


    The code that does the job is around lines 140 to 170 in the function _snvs_in_bam.

    Comment


    • #3
      Originally posted by m_elena_bioinfo View Post
      Hi NGS users,
      is there a way (by using bioperl module of samtools) to extract the information about the strand of the reads using a bam alignment?
      Thanx a lot!
      ME
      Yes, here is some sample code:

      Code:
      #!/usr/bin/perl
      
      use strict;
      use warnings;
      
      use Bio::DB::Sam
      
      # Instantiate a new Bio::DB::Sam object, passing it the BAM file and the reference FASTA.
      
      my $sam = Bio::DB::Sam ->new(-bam=>"myPath/myBamFile.bam",
                                   -fasta=>"myPath/myFastaFile.fa");
      
      
      # Create a collection of alignment objects.  The arguments for get_features_by_location are seq_id (e.g. chrom name), start and end (1 based).
      
      
      my @alignments = $sam->get_features_by_location(-seq_id=>'chr1',
                                                      -start=>500,
                                                      -end=>15000);
      
      
      # Iterate over the aligments, querying each one for the strand of the read.
      
      for my $a (@alignments) {
      	
      	my $strand=$a->strand;
      	
      	# Do something with strand info.
      	
      	# You can also get seq_id, start, end, cigar string and much more about each alignment.
      	
      }

      Comment


      • #4
        Thank you very much for the rapid answers! Both are very useful!

        @kmcarr:in module Bio:B::Sam i found two different thing:
        my $strand=$a->strand;
        my $strand-query=$a->query->strand;

        What is the different? The query strand (the second variable) is the strand of the read?

        Comment


        • #5
          Originally posted by m_elena_bioinfo View Post
          Thank you very much for the rapid answers! Both are very useful!

          @kmcarr:in module Bio:B::Sam i found two different thing:
          my $strand=$a->strand;
          my $strand-query=$a->query->strand;

          What is the different? The query strand (the second variable) is the strand of the read?
          By my reading of the APIs they are both giving you the same information, just from slightly different points of view. In the first case you are calling the strand method on a Bio:B::BAM::Alignment object, and in the second case you are calling the strand method within a Bio:B::BAM::Query object.

          In the first case strand reports whether the query sequence matches the forward (+1) or reverse (-1) strand of the reference. The second method reports whether or not the query sequence itself (+1) or the reverse complement of the query sequence (-1) matches the forward strand of the reference.

          Comment


          • #6
            Great Kmcarr, thanks for all the help you gave me.
            I tried to compare the two codes by extracting the strand of the reads in both methods. The results were the same!

            So I think that the only difference is the context and the module of bioperl that you use in your script!

            Comment

            Latest Articles

            Collapse

            • seqadmin
              Recent Advances in Sequencing Analysis Tools
              by seqadmin


              The sequencing world is rapidly changing due to declining costs, enhanced accuracies, and the advent of newer, cutting-edge instruments. Equally important to these developments are improvements in sequencing analysis, a process that converts vast amounts of raw data into a comprehensible and meaningful form. This complex task requires expertise and the right analysis tools. In this article, we highlight the progress and innovation in sequencing analysis by reviewing several of the...
              05-06-2024, 07:48 AM
            • seqadmin
              Essential Discoveries and Tools in Epitranscriptomics
              by seqadmin




              The field of epigenetics has traditionally concentrated more on DNA and how changes like methylation and phosphorylation of histones impact gene expression and regulation. However, our increased understanding of RNA modifications and their importance in cellular processes has led to a rise in epitranscriptomics research. “Epitranscriptomics brings together the concepts of epigenetics and gene expression,” explained Adrien Leger, PhD, Principal Research Scientist...
              04-22-2024, 07:01 AM

            ad_right_rmr

            Collapse

            News

            Collapse

            Topics Statistics Last Post
            Started by seqadmin, Yesterday, 07:03 AM
            0 responses
            15 views
            0 likes
            Last Post seqadmin  
            Started by seqadmin, 05-10-2024, 06:35 AM
            0 responses
            37 views
            0 likes
            Last Post seqadmin  
            Started by seqadmin, 05-09-2024, 02:46 PM
            0 responses
            45 views
            0 likes
            Last Post seqadmin  
            Started by seqadmin, 05-07-2024, 06:57 AM
            0 responses
            39 views
            0 likes
            Last Post seqadmin  
            Working...
            X