biom.table.Table.align_tree

Table.align_tree(tree, axis='observation')

Aligns biom table against tree, only keeping common ids.

Parameters:
treeskbio.TreeNode

The tree object, either respect to the sample metadata or observation metadata.

axis{‘sample’, ‘observation’}

The axis on which to operate.

Returns:
biom.Table

A filtered biom table.

skbio.TreeNode

A filtered skbio TreeNode object.

Examples

>>> from biom import Table
>>> import numpy as np
>>> from skbio import TreeNode
>>> table = Table(np.array([[0, 0, 1, 1],
...                         [2, 2, 4, 4],
...                         [5, 5, 3, 3],
...                         [0, 0, 0, 1]]),
...               ['o1', 'o2', 'o3', 'o4'],
...               ['s1', 's2', 's3', 's4'])
>>> tree = TreeNode.read([u"((o1,o2)f,o3)r;"])
>>> res_table, res_tree = table.align_tree(tree)
>>> print(res_table)
# Constructed from biom file
#OTU ID s1      s2      s3      s4
o1      0.0     0.0     1.0     1.0
o2      2.0     2.0     4.0     4.0
o3      5.0     5.0     3.0     3.0
>>> print(res_tree.ascii_art())
                    /-o1
          /f-------|
-r-------|          \-o2
         |
          \-o3