Seqanswers Leaderboard Ad

Collapse

Announcement

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

  • bioperl for samtools

    Hi users,
    I'm using Bio:B::Sam to analyse my data from Illumina.
    I have bam, sam and fasta files,but I don't know how use bio-samtools and its modules to interface to the pileup routines.
    Anyone could help me?!
    thanks a lot,
    ME

  • #2
    Which of the examples from the online documentation have you tried? The SNP caller example is a good illustration of writing a "walker" which will visit regions of the alignment and compute something.

    Comment


    • #3
      Hi Krobison, thanx for oyur quick reply! I'm using the indications from this site: http://search.cpan.org/~lds/Bio-SamT.../Bio/DB/Sam.pm . But the examples are not so easy to understand...How can I extract pileup from bam? Or from my pileup file, how can I extract the information? I really can't understand the example or the module!

      Comment


      • #4
        Hello there,
        I recently have encoutered the same problem. Have you got it sorted? Perhaps, you can divulge a bit information... thanx

        Comment


        • #5
          Okay, here is one possible exam answer :-) The $sam argument needs to be the Perl object created from the .bam file. The callback scheme is probably not how I would have designed things, but that's a matter of personal design taste & one must work with the way the Perl interface is.

          This code could be a little rusty; I mostly use another tool now for SNP calling. Wouldn't shock me if there is a more compact & clever way to code this either.

          Code:
          package SnpCaller;
          ## please give Keith Robison, Infinity Pharmaceuticals & Omics! Omics! credit
          ## if you find this useful. 
          ## If you don't please post your improvement or criticism!
          
          sub new
          {
              my ($class)=@_;
              my $this={'minQ'=>25, 'minMinor'=>2, 'minDepth'=>4};
              bless $this,$class;
              return $this;
          }
          
          ### variation on "extremely stupid" SNP caller from Sam.pm docs
          
          sub callSnps
          {
              my ($this,$sam,$region)=@_;
              # region in form chr2:1-10
              my @SNPs=();
              my $snpCaller=sub 
              {
                  my ($seqid,$pos,$p)=@_;
                  # any speed gain from fetching long segment at start?
                  my $refbase=$sam->segment($seqid,$pos,$pos)->dna;
          
                  $refbase=~tr/a-z/A-Z/;
                  my %bases=();
                  my %maxQual=();
                  return if (scalar(@{$p})<$this->{'minDepth'});
                  for my $pileup(@{$p})
                  {
                      my $b=$pileup->b;
                      next if ($pileup->indel); # doesn't handle indels; need to in future
                      my $qbase=substr($b->qseq,$pileup->qpos,1);
                      next unless ($qbase=~/[ATCG]/i);
                      my $qscore=ord(substr($b->qscore,$pileup->qpos,1))-33;
                      next unless ($qscore>$this->{'minQ'});
                      $bases{$qbase}++;
                      $maxQual{$qbase}=$qscore if ($qscore>$maxQual{$qbase});
                  }
                  my $store=1;
                  if (scalar(keys %bases)==1)
                  {
                      $store=0 if (defined $bases{$refbase});
                  }
                  else
                  {
                      my @counts=sort {$b<=>$a} values %bases;
                      $store=0 if ($counts[1]<$this->{'minMinor'});
                  }
                  push(@SNPs,{'pos'=>$pos,'ref'=>$refbase, 'bases'=>\%bases,'maxQual'=>\%maxQual}) if ($store); 
              };
              $sam->pileup($region,$snpCaller);
              return @SNPs;
          }

          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...
            Yesterday, 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, Today, 06:57 AM
          0 responses
          7 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, Yesterday, 07:17 AM
          0 responses
          13 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 05-02-2024, 08:06 AM
          0 responses
          19 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 04-30-2024, 12:17 PM
          0 responses
          21 views
          0 likes
          Last Post seqadmin  
          Working...
          X