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

            ad_right_rmr

            Collapse

            News

            Collapse

            Topics Statistics Last Post
            Started by seqadmin, 04-25-2024, 11:49 AM
            0 responses
            20 views
            0 likes
            Last Post seqadmin  
            Started by seqadmin, 04-24-2024, 08:47 AM
            0 responses
            20 views
            0 likes
            Last Post seqadmin  
            Started by seqadmin, 04-11-2024, 12:08 PM
            0 responses
            62 views
            0 likes
            Last Post seqadmin  
            Started by seqadmin, 04-10-2024, 10:19 PM
            0 responses
            61 views
            0 likes
            Last Post seqadmin  
            Working...
            X