gneiss.sort.ladderize

gneiss.sort.ladderize(tree, ascending=True)[source]

Sorts tree according to the size of the subtrees.

Parameters:tree (skbio.TreeNode) – Input tree where leafs correspond to features.
Returns:A tree whose tips are sorted according to subtree size.
Return type:skbio.TreeNode

Examples

>>> from skbio import TreeNode
>>> tree = TreeNode.read([u'((a,b)c, ((g,h)e,f)d)r;'])
>>> print(tree.ascii_art())
                    /-a
          /c-------|
         |          \-b
-r-------|
         |                    /-g
         |          /e-------|
          \d-------|          \-h
                   |
                    \-f
>>> sorted_tree = ladderize(tree)
>>> print(sorted_tree.ascii_art())
                    /-a
          /c-------|
         |          \-b
-r-------|
         |          /-f
          \d-------|
                   |          /-g
                    \e-------|
                              \-h