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
            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, Yesterday, 11:49 AM
          0 responses
          15 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 04-24-2024, 08:47 AM
          0 responses
          16 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 04-11-2024, 12:08 PM
          0 responses
          61 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 04-10-2024, 10:19 PM
          0 responses
          60 views
          0 likes
          Last Post seqadmin  
          Working...
          X