skbio.tree.TreeNode.tip_tip_distances

TreeNode.tip_tip_distances(endpoints=None)[source]

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

State: Experimental as of 0.4.0.

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

The distance matrix

Return type

DistanceMatrix

Raises

ValueError – If any of the specified endpoints are not tips

Notes

If a node does not have an associated length, 0.0 will be used and a RepresentationWarning will be raised.

Examples

>>> from skbio import TreeNode
>>> tree = TreeNode.read(["((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.]]