dendropy.model.continuous: Continuous Character Evolution

Models and modeling of continuous character evolution.

class dendropy.model.continuous.PhylogeneticIndependentConstrasts(tree, char_matrix, polytomy_strategy=None)[source]

Phylogenetic Independent Contrasts.


  • Felsenstein, J. 1985. Phylogenies and the comparative method. American Naturalist 125:1-15.
  • Garland, T., Jr., Jr., A. F. Bennett, and E. L. Rezende. 2005. Phylogenetic approaches in comparative physiology. Journal of Experimental Biology 208:3015-3035.
  • tree (Tree object) – Tree to use.
  • char_matrix (ContinuousCharacterMatrix) – ContinuousCharacterMatrix that is the source of the data
  • polytomy_strategy

    One of: ‘error’, ‘ignore’, ‘resolve’.

    Throws an error if tree has polytomies.
    No error, but raw contrasts will not be calculated for polytomies.
    Randomly resolve polytomies.

    Defaults to ‘error’ if not specified or set to None.

contrasts_tree(character_index, annotate_pic_statistics=True, state_values_as_node_labels=False, corrected_edge_lengths=False)[source]

Returns a Tree object annotated with the following attributes added to each node (as annotations to be serialized if annotate_pic_statistics is True):

  • pic_state_value
  • pic_state_variance
  • pic_contrast_raw
  • pic_contrast_variance
  • pic_contrast_standardized
  • pic_edge_length_error
  • pic_corrected_edge_length

This tree will have an attribute added to each node, pic. This attribute will be a dictionary with character (column) index as keys. Each column index will map to another dictionary that has the following keys (and values):

  • pic_state_value
  • pic_state_variance
  • pic_contrast_raw
  • pic_contrast_variance
  • pic_contrast_standardized
  • pic_edge_length_error
  • pic_corrected_edge_length
dendropy.model.continuous.evolve_continuous_char(node, rng=None, **kwargs)[source]

Takes a node and a random number generator object, rng This function “evolves” a set of rates on the subtree descending from the node.

kwargs keys that are used are:

the rate of evolution of the rate of evolution. This parameter that controls the degree of deviations away from the molecular clock.
is the minimum rate (default None)
is the maximum rate (default None),
is a string specifying the name of the model. Currently only the KTB (Kishino, Thorne, Bruno) is supported
is a string that specifies the name of the attribute that returns the branch length in terms of time for a node. The default is “edge_length”
is the string that specifies the name of the attribute used to hold the value that is evolving along the nodes. The root of the subtree is assumed to have this field on calling of the function. On success all nodes in the subtree will have the attribute. The default is “mutation_rate”
if specified this is string that gives the name of attribute in each node that is mean value for the branch (default is None). This is filled in after time_attr and val_attr are read, so it is permissible to have this attribute match one of thos strings (although it will make the model odd if the mean_val_attr is the same as the val_attr) constrain_rate_mode controls the behavior when the minimum or maximum rate is simulated. The choices are “crop”, and “linear_bounce” “crop” means that the rate is set to the most extreme value allowed. “linear_bounce” considers the path of evolution of rate to be a simple line from the ancestor’s rate to the proposed rate. The point at which the path crosses the extreme value is determined and the rate is “reflected off” the limiting rate at that point. This causes the rate to avoid the extreme values more than a simulation of small time slices that simply rejects illegal rates.

Currently the only model supported is the one of Kishino, Thorne, and Bruno. “Performance of a Divergence Time Estimation Method under a Probabilistic Model of Rate Evolution.” Molecular Biology and Evolution (2001) vol. 18 (3) pp. 352-361. This model is specified by the code “KTB”. A node’s rate is a log-normal variate with variance determined by the product of the duration of the branch and the roeotroe parameter. The mean of the distribution is chosen such that mean of the log-normal is identical to the rate at the parent. The mean_rate for the branch is the average of the rates at the endpoints.