skbio.tree.upgma#

skbio.tree.upgma(dm, weighted=False)[source]#

Perform unweighted pair group method with arithmetic mean (UPGMA) or its weighted variant (WPGMA) for phylogenetic reconstruction.

Parameters:
dmskbio.DistanceMatrix

The input distance matrix.

weightedbool, optional

If True, WPGMA is performed instead of UPGMA. WPGMA is a variant of UPGMA which is unbiased towards the size of subtrees computed.

Returns:
TreeNode

A TreeNode object with estimated edge values.

See also

nj

Notes

UPGMA is a hierarchical clustering method appearing as the average function in the SciPy package, where the linkage matrix produced by average is used to construct a TreeNode object. A weighted variant is known as WPGMA, and both variants are due to Sokal and Michener [1].

References

[1]

Sokal, R.R., & Michener, C.D. (1958). A statistical method for evaluating systematic relationships. University of Kansas science bulletin, 38, 1409-1438.

Examples

Define a distance matrix object for the taxa a, b, and c.

>>> from skbio import DistanceMatrix
>>> data = [[0, 1, 2],
...         [1, 0, 3],
...         [2, 3, 0]]
>>> ids = list('abc')
>>> dm = DistanceMatrix(data, ids)

Construct a tree using UPGMA.

>>> tree = upgma(dm)
>>> print(tree.ascii_art())
          /-c
---------|
         |          /-a
          \--------|
                    \-b

The tree also has estimated edge values assigned to each edge.

>>> print(tree)
(c:1.25,(a:0.5,b:0.5):0.75);