TreeNode.
root_at_midpoint
()[source]¶Return a new tree rooted at midpoint of the two tips farthest apart
State: Experimental as of 0.4.0.
This method doesn’t preserve the internal node naming or structure, but does keep tip to tip distances correct. Uses unrooted_copy but operates on a full copy of the tree.
TreeError – If a tip ends up being the mid point
TreeNode – A tree rooted at its midpoint
LengthError – Midpoint rooting requires length and will raise (indirectly) if evaluated nodes don’t have length.
See also
Examples
>>> from skbio import TreeNode
>>> tree = TreeNode.read(["(((d:1,e:1,(g:1)f:1)c:1)b:1,h:1)a:1;"])
>>> print(tree.root_at_midpoint())
((d:1.0,e:1.0,(g:1.0)f:1.0)c:0.5,((h:1.0)b:1.0):0.5)root;