scikit-bio is back in active development! Check out our announcement of revitalization.

skbio.tree.TreeNode.root_at#

TreeNode.root_at(node)[source]#

Return a new tree rooted at the provided node.

This can be useful for drawing unrooted trees with an orientation that reflects knowledge of the true root location.

Parameters:
nodeTreeNode or str

The node to root at

Returns:
TreeNode

A new copy of the tree

Raises:
TreeError

Raises a TreeError if a tip is specified as the new root

Examples

>>> from skbio import TreeNode
>>> tree = TreeNode.read(["(((a,b)c,(d,e)f)g,h)i;"])
>>> print(tree.root_at('c'))
(a,b,((d,e)f,(h)g)c)root;