Created
May 2, 2015 15:27
-
-
Save anonymous/0e8890908d426d89fcc4 to your computer and use it in GitHub Desktop.
Pasted from IPython
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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