skbio.tree.TreeNode.compare_subsets

TreeNode.compare_subsets(other, exclude_absent_taxa=False)[source]

Returns fraction of overlapping subsets where self and other differ.

Names present in only one of the two trees will count as mismatches, if you don’t want this behavior, strip out the non-matching tips first.

Parameters:

other : TreeNode

The tree to compare

exclude_absent_taxa : bool

Strip out names that don’t occur in both trees

Returns:

float

The fraction of overlapping subsets that differ between the trees

Examples

>>> from six import StringIO
>>> from skbio import TreeNode
>>> tree1 = TreeNode.read(StringIO("((a,b),(c,d));"))
>>> tree2 = TreeNode.read(StringIO("(((a,b),c),d);"))
>>> tree1.compare_subsets(tree2)
0.5