biotaphy.analyses.anc_dp
Module containing code for calculating ancestral states.
Module Contents
Functions
|
Returns the node label or taxon label if node is a tip. |
|
Calculates ancestral distributions. |
|
Calculates the continuous ancestral states for the nodes in a tree. |
- biotaphy.analyses.anc_dp._get_node_label(node)[source]
Returns the node label or taxon label if node is a tip.
- Parameters
node (Node) – A tree node to get the label for.
- Returns
The node label or taxon label.
- Return type
str
- biotaphy.analyses.anc_dp.calculate_ancestral_distributions(tree, char_mtx)[source]
Calculates ancestral distributions.
- Parameters
tree (Tree) – A dendropy tree or TreeWrapper object.
char_mtx (Matrix) – A Matrix object with character information. Each row should represent a tip in the tree and each column should be a bin to calculate ancestral distribution.
- Returns
rows: nodes / tips in the tree
columns: character variables
- depth: first is the calculated value, second layer is standard
error if desired
- Return type
A matrix of character data with the following dimensions
- biotaphy.analyses.anc_dp.calculate_continuous_ancestral_states(tree, char_mtx, sum_to_one=False, calc_std_err=False)[source]
Calculates the continuous ancestral states for the nodes in a tree.
- Parameters
tree (Tree) – A dendropy tree or TreeWrapper object.
char_mtx (Matrix) – A Matrix object with character information. Each row should represent a tip in the tree and each column should be a variable to calculate ancestral state for.
calc_std_err (
bool
, optional) – If True, calculate standard error for each variable. Defaults to False.sum_to_one (
bool
, optional) – If True, standardize the character matrix so that the values in a row sum to one. Defaults to False.
- Raises
ValueError – Raised if none of the tree tips were found in the character data.
- Returns
rows: nodes / tips in the tree
columns: character variables
- depth: first is the calculated value, second layer is standard
error if desired
- Return type
A matrix of character data with the following dimensions