Bio::T...tistics(3pm)

πŸ“¦
version 1.7.8 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

πŸ’– NAME πŸ’–

Bio::Tree::Statistics β€” Calculate certain statistics for a Tree

(yes bestie, that's the page β€” Bio::T...tistics(3pm) from the User Contributed Perl Documentation, we're doing tree math today and it's gonna be iconic πŸŽ€)


✨ SYNOPSIS ✨

use Bio::Tree::Statistics;

🌸 DESCRIPTION 🌸

Okay so, the vibe here is: this is supposed to be where Tree statistics get calculated. Originally it was the home of statistics from a Coalescent simulation. That era is over, she's reinvented herself. πŸ’…

Now it contains several methods for calculating Tree-Trait statistics. Glow-up complete.


🫢 FEEDBACK 🫢

πŸ“¬ Mailing Lists

User feedback is, like, an integral part of the evolution of this and other Bioperl modules. So if you have comments or suggestions, send them preferably to the Bioperl mailing list. Your participation is much appreciated, fr fr.

bioperl-l@bioperl.org                  - General discussion
http://bioperl.org/wiki/Mailing_lists  - 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. The reason? There are many experienced and responsive experts who will be able to look at the problem and quickly address it. So please include a thorough description of the problem, plus code and data examples if at all possible. The more tea you spill, the faster someone can help. πŸ“

πŸ› Reporting Bugs

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

https://github.com/bioperl/bioperl-live/issues

πŸ‘‘ AUTHOR - Jason Stajich πŸ‘‘

Email jason AT bioperl.org

🌈 CONTRIBUTORS 🌈

Heikki Lehvaslaiho, heikki at bioperl dot org


πŸ“– APPENDIX πŸ“–

The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _.

πŸŽ€ new πŸŽ€

Title   : new
Usage   : my $obj = Bio::Tree::Statistics->new();
Function: Builds a new Bio::Tree::Statistics object
Returns : Bio::Tree::Statistics
Args    :

🧬 assess_bootstrap 🧬

Title   : assess_bootstrap
Usage   : my $tree_with_bs = $stats->assess_bootstrap(\@bs_trees,$guide_tree);
Function: Calculates the bootstrap for internal nodes based on the percentage
          of times \@bs_trees agree with each internal node
Returns : L<Bio::Tree::TreeI>
Args    : Arrayref of L<Bio::Tree::TreeI>s
          Guide tree, L<Bio::Tree::TreeI>s

πŸ”₯ transfer_bootstrap_expectation πŸ”₯

Title   : transfer_bootstrap_expectation
Usage   : my $tree_with_bs = $stats->transfer_bootstrap_expectation(\@bs_trees,$guide_tree);
Function: Calculates the Transfer Bootstrap Expectation (TBE) for internal nodes based on
          the methods outlined in Lemoine et al, Nature, 2018.
          Currently experimental.
Returns : L<Bio::Tree::TreeI>
Args    : Arrayref of L<Bio::Tree::TreeI>s
          Guide tree, L<Bio::Tree::TreeI>s
Heads up bestie: this one is marked Currently experimental. Treat it accordingly. ✨

πŸ’ cherries πŸ’

Example    : cherries($tree, $node);
Description: Count number of paired leaf nodes
             in a binary tree
Returns    : integer
Exceptions :
Args       : 1. Bio::Tree::TreeI object
             2. Bio::Tree::NodeI object within the tree, optional

Commonly used statistics assume a binary tree, but β€” plot twist β€” this method returns a value even for trees with polytomies. She's flexible like that. πŸ’…

🌳 Tree-Trait statistics 🌳

The following methods produce descriptors of trait distribution among leaf nodes within the trees. They require that a trait has been set for each leaf node. The tag methods of Bio::Tree::Node are used to store them as key/value pairs β€” and the way that works is, one tree can store more than one trait. Multi-tasking queen. πŸ‘‘

Trees have the method add_traits() to set trait values from a file. See the add_trait() method in Bio::Tree::TreeFunctionsI.

🧚 fitch 🧚

Example    : fitch($tree, $key, $node);
Description: Calculates Parsimony Score (PS) and internal trait
             values using the Fitch 1971 parsimony algorithm for
             the subtree a defined by the (internal) node.
             Node defaults to the root.
Returns    : true on success
Exceptions : leaf nodes have to have the trait defined
Args       : 1. Bio::Tree::TreeI object
             2. trait name string
             3. Bio::Tree::NodeI object within the tree, optional

Runs first fitch_up, which calculates parsimony scores, and then fitch_down, which should resolve most of the trait/character state ambiguities. Two-step process, both steps serving. ✨

Fitch, W.M., 1971. Toward defining the course of evolution: minimal change for a specific tree topology. Syst. Zool. 20, 406-416.

You can access the calculated parsimony values using:

$score = $node->->get_tag_values('ps_score');

and the trait value with:

$traitvalue = $node->->get_tag_values('ps_trait'); # only the first
@traitvalues = $node->->get_tag_values('ps_trait');
Note that there can be more than one trait value, especially for the root node. Don't be surprised bestie, the root is doing the most.

πŸ“ ps πŸ“

Example    : ps($tree, $key, $node);
Description: Calculates Parsimony Score (PS) from Fitch 1971
             parsimony algorithm for the subtree as defined
             by the (internal) node.
             Node defaults to the root.
Returns    : integer, 1 < PS < n, where n is number of branches
Exceptions : leaf nodes have to have the trait defined
Args       : 1. Bio::Tree::TreeI object
             2. trait name string
             3. Bio::Tree::NodeI object within the tree, optional

This is the first half of the Fitch algorithm, and that half is enough for calculating the resolved parsimony values. The trait/character states are commonly left in an ambiguous state. To resolve them, run fitch_down. Periodt.

⬆️ fitch_up ⬆️

Example    : fitch_up($tree, $key, $node);
Description: Calculates Parsimony Score (PS) from the Fitch 1971
             parsimony algorithm for the subtree as defined
             by the (internal) node.
             Node defaults to the root.
Returns    : integer, 1< PS < n, where n is number of branches
Exceptions : leaf nodes have to have the trait defined
Args       : 1. Bio::Tree::TreeI object
             2. trait name string
             3. Bio::Tree::NodeI object within the tree, optional

This is a more generic name for ps, and it indicates that it performs the first bottom-up tree traversal that calculates the parsimony score β€” but usually leaves trait/character states ambiguous. If you're interested in internal trait states, running fitch_down should resolve most of the ambiguities. She's not fully committing yet, it's giving situationship. 😭

⬇️ fitch_down ⬇️

Example    : fitch_down($tree, $node);
Description: Runs the second pass from Fitch 1971
             parsimony algorithm to resolve ambiguous
             trait states left by first pass.
             by the (internal) node.
             Node defaults to the root.
Returns    : true
Exceptions : dies unless the trait is defined in all nodes
Args       : 1. Bio::Tree::TreeI object
             2. Bio::Tree::NodeI object within the tree, optional

Before running this method you should have ran fitch_up (alias to ps). And note that it is not guaranteed that all states are completely resolved. She tries her best, okay. πŸ™ˆ

πŸ¦‹ persistence πŸ¦‹

Example    : persistence($tree, $node);
Description: Calculates the persistence
             for node in the subtree defined by the (internal)
             node.  Node defaults to the root.
Returns    : int, number of generations trait value has to remain same
Exceptions : all the  nodes need to have the trait defined
Args       : 1. Bio::Tree::TreeI object
             2. Bio::Tree::NodeI object within the tree, optional

Persistence measures the stability that the trait value has in a tree. It expresses the number of generations the trait value remains the same. All the descendants of the root in the same generation have to share the same value β€” no exceptions, we're keeping the group chat on the same page. 🫢

Depends on Fitch's parsimony score (PS).

🧺 count_subclusters 🧺

Example    : count_clusters($tree, $node);
Description: Calculates the number of sub-clusters
             in the subtree defined by the (internal)
             node.  Node defaults to the root.
Returns    : int, count
Exceptions : all the  nodes need to have the trait defined
Args       : 1. Bio::Tree::TreeI object
             2. Bio::Tree::NodeI object within the tree, optional

Depends on Fitch's parsimony score (PS).

πŸƒ count_leaves πŸƒ

Example    : count_leaves($tree, $node);
Description: Calculates the number of leaves with same trait
             value as root in the subtree defined by the (internal)
             node.  Requires an unbroken line of identical trait values.
             Node defaults to the root.
Returns    : int, number of leaves with this trait value
Exceptions : all the  nodes need to have the trait defined
Args       : 1. Bio::Tree::TreeI object
             2. Bio::Tree::NodeI object within the tree, optional

Depends on Fitch's parsimony score (PS).

πŸ“ phylotype_length πŸ“

Example    : phylotype_length($tree, $node);
Description: Sums up the branch lengths within phylotype
             excluding the subclusters where the trait values
             are different
Returns    : float, length
Exceptions : all the  nodes need to have the trait defined
Args       : 1. Bio::Tree::TreeI object
             2. Bio::Tree::NodeI object within the tree, optional

Depends on Fitch's parsimony score (PS).

πŸ“Š sum_of_leaf_distances πŸ“Š

Example    : sum_of_leaf_distances($tree, $node);
Description: Sums up the branch lengths from root to leaf
             excluding the subclusters where the trait values
             are different
Returns    : float, length
Exceptions : all the  nodes need to have the trait defined
Args       : 1. Bio::Tree::TreeI object
             2. Bio::Tree::NodeI object within the tree, optional

Depends on Fitch's parsimony score (PS).

🌈 genetic_diversity 🌈

Example    : genetic_diversity($tree, $node);
Description: Diversity is the sum of root to leaf distances
             within the phylotype normalised by number of leaf
             nodes
Returns    : float, value of genetic diversity
Exceptions : all the  nodes need to have the trait defined
Args       : 1. Bio::Tree::TreeI object
             2. Bio::Tree::NodeI object within the tree, optional

Depends on Fitch's parsimony score (PS).

πŸ’« statratio πŸ’«

Example    : statratio($tree, $node);
Description: Ratio of the stem length and the genetic diversity of the
             phylotype L<genetic_diversity>
Returns    : float, separation score
Exceptions : all the  nodes need to have the trait defined
Args       : 1. Bio::Tree::TreeI object
             2. Bio::Tree::NodeI object within the tree, optional

Statratio gives a measure of separation and variability within the phylotype. Larger values identify more rapidly evolving and recent phylotypes β€” i.e. the ones that change their whole personality every season. πŸ”₯

Depends on Fitch's parsimony score (PS).


✨ ai ✨

okay bestie, this one's the Association Index and she's a real one, let's go πŸ’–

  • Example: ai($tree, $key, $node);
  • Description: works out the Association Index (AI) of Whang et al. 2001 for the subtree that the (internal) node defines. The node defaults to the root, no thoughts required 🌱
  • Returns: real
  • Exceptions: leaf nodes have to have the trait defined β€” no trait, no vibes, it will simply not 😭
  • Args:
    1. Bio::Tree::TreeI object
    2. trait name string
    3. Bio::Tree::NodeI object within the tree, optional

Association index (AI) gives a more fine grained results than PS since the result is a real number. ~0 <= AI.

citation time, bestie, we don't plagiarise in this house πŸŽ€

Wang, T.H., Donaldson, Y.K., Brettle, R.P., Bell, J.E., Simmonds, P., 2001. Identification of shared populations of human immunodeficiency Virus Type 1 infecting microglia and tissue macrophages outside the central nervous system. J. Virol. 75 (23), 11686-11699.


✨ mc ✨

now THIS one, the Monophyletic Clade size statistics, she's giving main character energy fr fr πŸ‘‘

  • Example: mc($tree, $key, $node);
  • Description: calculates the Monophyletic Clade (MC) size statistics for the subtree a defined by the (internal) node. Node defaults to the root; πŸ’…
  • Returns: hashref with trait values as keys
  • Exceptions: leaf nodes have to have the trait defined β€” same rule as before, don't come at me πŸ™ˆ
  • Args:
    1. Bio::Tree::TreeI object
    2. trait name string
    3. Bio::Tree::NodeI object within the tree, optional

Monophyletic Clade (MC) size statistics by Salemi at al 2005. It is calculated for each trait value. 1 <= MC <= nx, where nx is the number of tips with value x:

pick the internal node with maximim value for
   number of of tips with only trait x
yes, the typos are canon, I don't make the rules 🫢

MC was defined by Parker et al 2008.

and the receipts, because we cite our sources like the icons we are ⭐

Salemi, M., Lamers, S.L., Yu, S., de Oliveira, T., Fitch, W.M., McGrath, M.S., 2005. Phylodynamic analysis of Human Immunodeficiency Virus Type 1 in distinct brain compartments provides a model for the neuropathogenesis of AIDS. J. Virol. 79 (17), 11343-11352.

Parker, J., Rambaut A., Pybus O., 2008. Correlating viral phenotypes with phylogeny: Accounting for phylogenetic uncertainty Infection, Genetics and Evolution 8 (2008), 239-246.


and that's a wrap on this page, bestie 🌸 this lil doc is living its best life on perl v5.32.1, dated 2021-08-15, and it's the Bio::T...tistics(3pm) manpage β€” slay, go compute something iconic πŸ’–βœ¨

πŸ“¦ where this page comes from