skbio.tree.TreeNode.lowest_common_ancestor#
- TreeNode.lowest_common_ancestor(tipnames)[source]#
Find lowest common ancestor for a list of tips.
- Parameters:
- tipnamesiterable of TreeNode or str
The nodes of interest
- Returns:
- TreeNode
The lowest common ancestor of the passed in nodes
- Raises:
- ValueError
If no tips could be found in the tree, or if not all tips were found.
Examples
>>> from skbio import TreeNode >>> tree = TreeNode.read(["((a,b)c,(d,e)f)root;"]) >>> nodes = [tree.find('a'), tree.find('b')] >>> lca = tree.lowest_common_ancestor(nodes) >>> print(lca.name) c >>> nodes = [tree.find('a'), tree.find('e')] >>> lca = tree.lca(nodes) # lca is an alias for convience >>> print(lca.name) root