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
              Choosing Between NGS and qPCR
              by seqadmin



              Next-generation sequencing (NGS) and quantitative polymerase chain reaction (qPCR) are essential techniques for investigating the genome, transcriptome, and epigenome. In many cases, choosing the appropriate technique is straightforward, but in others, it can be more challenging to determine the most effective option. A simple distinction is that smaller, more focused projects are typically better suited for qPCR, while larger, more complex datasets benefit from NGS. However,...
              10-18-2024, 07:11 AM
            • seqadmin
              Non-Coding RNA Research and Technologies
              by seqadmin




              Non-coding RNAs (ncRNAs) do not code for proteins but play important roles in numerous cellular processes including gene silencing, developmental pathways, and more. There are numerous types including microRNA (miRNA), long ncRNA (lncRNA), circular RNA (circRNA), and more. In this article, we discuss innovative ncRNA research and explore recent technological advancements that improve the study of ncRNAs.

              Nobel Prize for MicroRNA Discovery
              This week,...
              10-07-2024, 08:07 AM

            ad_right_rmr

            Collapse

            News

            Collapse

            Topics Statistics Last Post
            Started by seqadmin, Yesterday, 05:31 AM
            0 responses
            10 views
            0 likes
            Last Post seqadmin  
            Started by seqadmin, 10-24-2024, 06:58 AM
            0 responses
            20 views
            0 likes
            Last Post seqadmin  
            Started by seqadmin, 10-23-2024, 08:43 AM
            0 responses
            48 views
            0 likes
            Last Post seqadmin  
            Started by seqadmin, 10-17-2024, 07:29 AM
            0 responses
            58 views
            0 likes
            Last Post seqadmin  
            Working...
            X