Skip to content

Instantly share code, notes, and snippets.

Created May 2, 2015 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/0e8890908d426d89fcc4 to your computer and use it in GitHub Desktop.
Save anonymous/0e8890908d426d89fcc4 to your computer and use it in GitHub Desktop.
Pasted from IPython
from biom import parse_table
with open('otu_table_hunter.biom') as f:
table = parse_table(f)
print table
table.ids()
table.ids(axis='observation')
table.nnz
normed = table.norm(axis='sample', inplace=False)
phylum_idx = 1
collapse_f = lambda id_, md: "; ".join(md['taxonomy'][:phylum_idx + 1])
collapsed = normed.collapse(collapse_f, axis='observation')
print collapsed
print collapsed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment