skbio.tree.TreeNode.tip_tip_distances

TreeNode.tip_tip_distances(endpoints=None)[source]

Returns distance matrix between pairs of tips, and a tip order.

By default, all pairwise distances are calculated in the tree. If endpoints are specified, then only the distances between those tips are computed.

Parameters:

endpoints : list of TreeNode or str, or None

A list of TreeNode objects or names of TreeNode objects

Returns:

DistanceMatrix

The distance matrix

Raises:

ValueError

If any of the specified endpoints are not tips

NoLengthError

If a node without length is encountered

Examples

>>> from six import StringIO
>>> from skbio import TreeNode
>>> tree = TreeNode.read(StringIO("((a:1,b:2)c:3,(d:4,e:5)f:6)root;"))
>>> mat = tree.tip_tip_distances()
>>> print(mat)
4x4 distance matrix
IDs:
a, b, d, e
Data:
[[  0.   3.  14.  15.]
 [  3.   0.  15.  16.]
 [ 14.  15.   0.   9.]
 [ 15.  16.   9.   0.]]