Skip to content

Method `baltic.tree.treeStats`

Barney Potter edited this page Oct 14, 2024 · 1 revision

tree.treeStats() Method

Description

The treeStats() method in the BALTIC tree class provides a summary of various statistics and characteristics of the phylogenetic tree. It's useful for quickly understanding the structure and properties of a tree.

Syntax

def treeStats(self)

Parameters

This method doesn't take any parameters.

Functionality

  1. Traverses the tree to ensure all attributes are up to date.
  2. Calculates and prints the following information:
    • Tree height
    • Tree length (sum of all branch lengths)
    • Whether the tree is strictly bifurcating
    • Whether the tree is a multitype tree
    • Whether the tree is a singleton (consists of a single tip)
    • Presence of annotations (traits)
    • Number of objects in the tree (total, nodes, and leaves)

Use Cases

  1. Quick inspection of a newly created or imported tree.
  2. Verifying tree properties after manipulation operations.
  3. Debugging tree-related issues.
  4. Reporting tree characteristics in publications or analyses.

Example

# Assuming we have a tree object
tree.treeStats()

# This will print output similar to:
# Tree height: 10.234567
# Tree length: 25.678901
# strictly bifurcating tree
# annotations present
# 
# Numbers of objects in tree: 100 (49 nodes and 51 leaves)

Notes

  • This method prints its output directly and doesn't return any values.
  • It automatically calls traverse_tree() to ensure all tree attributes are up to date before calculating statistics.
  • The "strictly bifurcating" property means that each internal node has exactly two children.
  • A "multitype" tree contains nodes with only one child, which can occur after certain tree manipulations or in some specialized analyses.
  • A "singleton" tree consists of only a single tip (leaf) node.
  • The presence of annotations indicates that at least some nodes or leaves have additional data stored in their traits dictionaries.
Clone this wiki locally