Bio::T...o::PAML(3pm)

πŸ“¦
version 1.7.3 Β· 3 versions
, in debian bookworm, debian trixie

πŸ’– Bio::Tools::Phylo::PAML πŸ’–

okay bestie, so this is Bio::Tools::Phylo::PAML β€” a Perl module from the User Contributed Perl Documentation collection. It parses the output from the PAML programs codeml, baseml, basemlg, codemlsites and yn00. Parses. That's the whole job. She reads, she doesn't run. πŸ’…


✨ VERSION ✨

version 1.7.3 β€” that's the one, no cap.


🌸 SYNOPSIS 🌸

Like, here's the whole vibe in code form. Copy it, love it, run it:

#!/usr/bin/perl -Tw
use strict;

use Bio::Tools::Phylo::PAML;

# need to specify the output file name (or a fh) (defaults to
# -file => "codeml.mlc"); also, optionally, the directory in which
# the other result files (rst, 2ML.dS, etc) may be found (defaults
# to "./")
my $parser = Bio::Tools::Phylo::PAML->new
  (-file => "./results/mlc", -dir => "./results/");

# get the first/next result; a Bio::Tools::Phylo::PAML::Result object,
# which isa Bio::SeqAnalysisResultI object.
my $result = $parser->next_result();

# get the sequences used in the analysis; returns Bio::PrimarySeq
# objects (OTU = Operational Taxonomic Unit).
my @otus = $result->get_seqs();

# codon summary: codon usage of each sequence [ arrayref of {
# hashref of counts for each codon } for each sequence and the
# overall sum ], and positional nucleotide distribution [ arrayref
# of { hashref of frequencies for each nucleotide } for each
# sequence and overall frequencies ]:
my ($codonusage, $ntdist) = $result->get_codon_summary();

# example manipulations of $codonusage and $ntdist:
printf "There were %d %s codons in the first seq (%s)\n",
  $codonusage->[0]->{AAA}, 'AAA', $otus[0]->id();
printf "There were %d %s codons used in all the sequences\n",
  $codonusage->[$#{$codonusage}]->{AAA}, 'AAA';
printf "Nucleotide %c was present %g of the time in seq %s\n",
  'A', $ntdist->[1]->{A}, $otus[1]->id();

# get Nei & Gojobori dN/dS matrix:
my $NGmatrix = $result->get_NGmatrix();

# get ML-estimated dN/dS matrix, if calculated; this corresponds to
# the runmode = -2, pairwise comparison usage of codeml
my $MLmatrix = $result->get_MLmatrix();

# These matrices are length(@otu) x length(@otu) "strict lower
# triangle" 2D-matrices, which means that the diagonal and
# everything above it is undefined.  Each of the defined cells is a
# hashref of estimates for "dN", "dS", "omega" (dN/dS ratio), "t",
# "S" and "N".  If a ML matrix, "lnL" and "kappa" will also be defined.
printf "The omega ratio for sequences %s vs %s was: %g\n",
  $otus[0]->id, $otus[1]->id, $MLmatrix->[0]->[1]->{omega};

# with a little work, these matrices could also be passed to
# Bio::Tools::Run::Phylip::Neighbor, or other similar tree-building
# method that accepts a matrix of "distances" (using the LOWTRI
# option):
my $distmat = [ map { [ map { $$_{omega} } @$_ ] } @$MLmatrix ];

# for runmode's other than -2, get tree topology with estimated
# branch lengths; returns a Bio::Tree::TreeI-based tree object with
# added PAML parameters at each node
my ($tree) = $result->get_trees();
for my $node ($tree->get_nodes()) {
   # inspect the tree: the "t" (time) parameter is available via
   # $node->branch_length(); all other branch-specific parameters
   # ("omega", "dN", etc.) are available via
   # ($omega) = $node->get_tag_values('omega');
}

# if you are using model based Codeml then trees are stored in each
# modelresult object
for my $modelresult ( $result->get_NSSite_results ) {
  # model M0, M1, etc
  print "model is ", $modelresult->model_num, "\n";
  my ($tree) = $modelresult->get_trees();
  for my $node ($tree->get_nodes()) {
   # inspect the tree: the "t" (time) parameter is available via
   # $node->branch_length(); all other branch-specific parameters
   # ("omega", "dN", etc.) are available via
   # ($omega) = $node->get_tag_values('omega');
 }
}

# get any general model parameters: kappa (the
# transition/transversion ratio), NSsites model parameters ("p0",
# "p1", "w0", "w1", etc.), etc.
my $params = $result->get_model_params();
printf "M1 params: p0 = %g\tp1 = %g\n", $params->{p0}, $params->{p1};

# parse AAML result files
my $aamat = $result->get_AADistMatrix();
my $aaMLmat = $result->get_AAMLDistMatrix();

πŸ¦‹ DESCRIPTION πŸ¦‹

So bestie, this module is literally here to parse the output from the PAML programs codeml, baseml, basemlg, codemlsites and yn00. If you wanna actually run some PAML programs, go hang out with the Bio::Tools::Run::Phylo::PAML::* modules. This one? She only parses. That's her lane and she's iconic in it. πŸ’…

She has fledgling support for PAML version 4.3a (October 2009). Fledgling. Baby. Newborn. So if anything goes wrong, pls report it to the mailing list (scroll down to FEEDBACK).

🧚 parse_codeml example

use Bio::Tools::Phylo::PAML;

my $parser = new Bio::Tools::Phylo::PAML(-file    => shift,
                                         -verbose => shift);

my $result = $parser->next_result;
my @otus = $result->get_seqs();
my $MLmatrix = $result->get_MLmatrix();
my $NGmatrix = $result->get_NGmatrix();

# These matrices are length(@otu) x length(@otu) "strict lower
# triangle" 2D-matrices, which means that the diagonal and
# everything above it is undefined.  Each of the defined cells is a
# hashref of estimates for "dN", "dS", "omega" (dN/dS ratio), "t",
# "S" and "N".  If a ML matrix, "lnL" will also be defined.

@otus = $result->get_seqs();
$MLmatrix = $result->get_MLmatrix();
$NGmatrix = $result->get_NGmatrix();
for( my $i=0;$i<scalar @$MLmatrix;$i++) {
    for( my $j = $i+1; $j < scalar @{$MLmatrix->[$i]}; $j++ ) {
        printf "The ML omega ratio for sequences %s vs %s was: %g\n",
          $otus[$i]->id, $otus[$j]->id, $MLmatrix->[$i]->[$j]->{omega};
    }
}

for( my $i=0;$i<scalar @$MLmatrix;$i++) {
    for( my $j = $i+1; $j < scalar @{$MLmatrix->[$i]}; $j++ ) {
        printf "The NG omega ratio for sequences %s vs %s was: %g\n",
          $otus[$i]->id, $otus[$j]->id, $NGmatrix->[$i]->[$j]->{'omega'};
    }
}

πŸ‘‘ METHODS πŸ‘‘

🌟 new

  • Title : new
  • Usage : my $obj = Bio::Tools::Phylo::PAML->new(%args);
  • Function : Builds a brand new Bio::Tools::Phylo::PAML object, fresh out the box ✨
  • Returns : Bio::Tools::Phylo::PAML
  • Args : Hash of options: -file, -fh, -dir
    • -file (or -fh) should contain the contents of the PAML outfile;
    • -dir is the (optional) name of the directory in which the PAML program was run (and includes other PAML-generated files from which we can try to gather data)

🌈 Implement Bio::AnalysisParserI interface

πŸ’œ next_result

  • Title : next_result
  • Usage : $result = $obj->next_result();
  • Function : Returns the next result available from the input, or undef if there are no more results. (When it's gone, it's gone, she said.)
  • Example :
  • Returns : a Bio::Tools::Phylo::PAML::Result object
  • Args : none

πŸŽ€ TO DO πŸŽ€

Implement get_posteriors(). For NSsites models, obtain arrayrefs of posterior probabilities for membership in each class for every position; probabilities correspond to classes w0, w1, ... etc.

my @probs = $result->get_posteriors();

# find, say, positively selected sites!
if ($params->{w2} > 1) {
  for (my $i = 0; $i < @probs ; $i++) {
    if ($probs[$i]->[2] > 0.5) {
       # assumes model M1: three w's, w0, w1 and w2 (positive selection)
       printf "position %d: (%g prob, %g omega, %g mean w)\n",
         $i, $probs[$i]->[2], $params->{w2}, $probs[$i]->[3];
    }
  }
} else { print "No positive selection found!\n"; }

⭐ TODO ⭐

  • RST parsing -- done, Avilella contributions bug#1506, added by jason 1.29
    • -- still need to parse in joint probability and non-syn changes at site table

πŸ’Œ FEEDBACK πŸ’Œ

🌸 Mailing lists

User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to the Bioperl mailing list. Your participation is much appreciated. (fr fr, they wanna hear from you 🫢)

bioperl-l@bioperl.org              - General discussion
http://bioperl.org/Support.html    - About the mailing lists

🩷 Support

Please direct usage questions or support issues to the mailing list:

bioperl-l@bioperl.org

rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible.

bestie, pls don't DM the maintainer. the list is right there and it's full of experts who will actually fix your thing. and yes, include code + data examples, that's the whole point. πŸ™ˆ

πŸ› Reporting bugs

Report bugs to the Bioperl bug tracking system to help us keep track of the bugs and their resolution. Bug reports can be submitted via the web:

https://github.com/bioperl/bio-tools-phylo-paml/issues

πŸ‘‘ AUTHORS πŸ‘‘

Jason Stajich <jason@bioperl.org>

Aaron Mackey <amackey@virginia.edu>

Albert Vilella <avilella@gmail.com>

Sendu Bala <bix@sendu.me.uk>

Dave Messina <dmessina@cpan.org>


This software is copyright (c) by Jason Stajich <jason@bioperl.org>, and by Aaron Mackey <amackey@virginia.edu>.

This software is available under the same terms as the perl 5 programming language system itself.


and that's the whole page, bestie πŸ’– this doc shipped with perl v5.34.0, dated 2022-10-14, and it's filed under Bio::T...o::PAML(3pm) in the User Contributed Perl Documentation pile. go forth and parse, you gorgeous nerd. mwah. πŸ’…βœ¨

πŸ“¦ where this page comes from