dendropy.calculate.treemeasure: Unary Tree Statistics and Metrics

Statistics, metrics, measurements, and values calculated on (single) trees.

dendropy.calculate.treemeasure.B1(tree)[source]

Returns the B1 statistic: the reciprocal of the sum of the maximum number of nodes between each interior node and tip over all internal nodes excluding root.

dendropy.calculate.treemeasure.N_bar(tree)[source]

Returns the $ar{N}$ statistic: the average number of nodes above a terminal node.

class dendropy.calculate.treemeasure.PatristicDistanceMatrix(tree)[source]
dendropy.calculate.treemeasure.coalescence_ages(tree)[source]

Returns vector of splits indexed in backward time.

dendropy.calculate.treemeasure.colless_tree_imbalance(tree, normalize='max')[source]

Returns Colless’ tree imbalance or I statistic: the sum of differences of numbers of children in left and right subtrees over all internal nodes. normalize specifies the normalization:

  • “max” or True [DEFAULT]

    normalized to maximum value for tree of this size

  • “yule”

    normalized to the Yule model

  • “pda”

    normalized to the PDA (Proportional to Distinguishable Arrangements) model

  • None or False

    no normalization

dendropy.calculate.treemeasure.divergence_times(tree)[source]

Returns vector of splits indexed in forward time.

dendropy.calculate.treemeasure.node_ages(tree, is_internal_only=False)[source]

Returns vector of branching events indexed in backward time.

dendropy.calculate.treemeasure.node_depths(tree, is_internal_only=False)[source]

Returns vector of branching events indexed in forward time.

dendropy.calculate.treemeasure.patristic_distance(tree, taxon1, taxon2, is_bipartitions_updated=False)[source]

Given a tree with bipartitions encoded, and two taxa on that tree, returns the patristic distance between the two. Much more inefficient than constructing a PhylogeneticDistanceMatrix object.

dendropy.calculate.treemeasure.pybus_harvey_gamma(tree, prec=1e-05)[source]

Returns the gamma statistic of Pybus and Harvey (2000). This statistic is used to test for constancy of birth and death rates over the course of a phylogeny. Under the pure-birth process, the statistic should follow a standard Normal distibution: a Normal(mean=0, variance=1).

If the lengths of different paths to the node differ by more than prec,

then a ValueError exception will be raised indicating deviation from ultrametricty.

Raises a Value Error if the tree is not ultrametric, is non-binary, or has

only 2 leaves.

As a side effect a age attribute is added to the nodes of the tree.

Pybus and Harvey. 2000. “Testing macro-evolutionary models using incomplete molecular phylogenies.” Proc. Royal Society Series B: Biological Sciences. (267). 2267-2272

dendropy.calculate.treemeasure.sackin_index(tree, normalize=True)[source]

Returns the Sackin’s index: the sum of the number of ancestors for each tip of the tree. The larger the Sackin’s index, the less balanced the tree. normalize specifies the normalization:

  • True [DEFAULT]

    normalized to number of leaves; this results in a value equivalent to that given by Tree.N_bar()

  • “yule”

    normalized to the Yule model

  • “pda”

    normalized to the PDA (Proportional to Distinguishable Arrangements) model

  • None or False

    no normalization

dendropy.calculate.treemeasure.treeness(tree)[source]

Returns the proportion of total tree length that is taken up by internal branches.