skbio.tree.TreeNode.compare_subsets#

TreeNode.compare_subsets(other, shared_only=False, proportion=True, **kwargs)[source]#

Calculate the difference of subsets between two trees.

Parameters:
otherTreeNode

The other tree to compare with.

shared_onlybool, optional

Only consider taxa shared with the other tree. Default is False.

Changed in version 0.6.3: Renamed from exclude_absent_taxa. The old name is kept as an alias.

proportionbool, optional

Whether to return count (False) or proportion (True, default) of different subsets.

Added in version 0.6.3.

Returns:
float

The count or proportion of subsets that differ between the trees.

Notes

This metric is equivalent to the Robinson-Foulds distance on rooted trees.

Examples

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