gneiss.balances.balance_basis

gneiss.balances.balance_basis(tree_node)[source]

Determines the basis based on bifurcating tree.

This is commonly referred to as sequential binary partition [1]. Given a binary tree relating a list of features, this module can be used to calculate an orthonormal basis, which is used to calculate the ilr transform.

Parameters:treenode (skbio.TreeNode) – Input bifurcating tree. Must be strictly bifurcating (i.e. every internal node needs to have exactly 2 children).
Returns:
  • basis (np.array) – Returns a set of orthonormal bases in the Aitchison simplex corresponding to the tree. The order of the basis is index by the level order of the internal nodes.
  • nodes (list, skbio.TreeNode) – List of tree nodes indicating the ordering in the basis.
Raises:ValueError – The tree doesn’t contain two branches.

Examples

>>> from gneiss.balances import balance_basis
>>> from skbio import TreeNode
>>> tree = u"((b,c)a, d)root;"
>>> t = TreeNode.read([tree])
>>> basis, nodes = balance_basis(t)
>>> basis
array([[ 0.18507216,  0.18507216,  0.62985567],
       [ 0.14002925,  0.57597535,  0.28399541]])

Notes

The tree must be strictly bifurcating, meaning that every internal node has exactly 2 children.

See also

skbio.stats.composition.ilr()

References

[1]J.J. Egozcue and V. Pawlowsky-Glahn “Exploring Compositional Data with the CoDa-Dendrogram” (2011)