This subpackage provides functions and data structures for creating (phylogenetic) trees.

The Tree is the central class in this subpackage. It wraps a root TreeNode object. A TreeNode is either an intermediate node, if it has child TreeNode objects, or otherwise a leaf node.

A Tree is not a container itself: Objects, e.g species names or sequences, that are represented by the nodes, cannot be stored directly in a Tree or TreeNode. Instead, each leaf node has a reference index: These indices refer to a separate list or array, containing the actual reference objects.

A Tree can be created from or exported to a Newick notation, usingthe Tree.from_newick() or Tree.to_newick() method, respectively.

A Tree can be build from a pairwise distance matrix using the popular UPGMA (upgma()) and Neighbor-Joining (neighbor_joining()) algorithms.

Data structures


A Tree represents a rooted tree (e.g.


TreeNode objects are part of a rooted tree (e.g.


An exception that occurs in context of tree topology.


Convert a tree into a binary tree.

Clustering algorithms


Perform hierarchical clustering using the unweighted pair group method with arithmetic mean (UPGMA).


Perform hierarchical clustering using the neighbor joining algorithm.