In [7]:
from biom import load_table
from skbio import TreeNode
from io import StringIO
import numpy as np
from skbio.diversity.alpha._base import alpha_diversity, observed_otus, faith_pd

In [13]:
t = load_table('/Users/caporaso/code/q2d2/example-data/keyboard/q191/otu-table.tsv')
d = t.matrix_data.toarray().astype('int').T
tree = TreeNode.read('/Users/caporaso/code/q2d2/example-data/keyboard/q191/rep-set.tre')

In [14]:
%%timeit
alpha_diversity('faith_pd', d, ids=t.ids('sample'), otu_ids=t.ids('observation'), tree=tree)


100 loops, best of 3: 9.44 ms per loop

In [15]:
%%timeit
alpha_diversity(faith_pd, d, ids=t.ids('sample'), otu_ids=t.ids('observation'), tree=tree)


1 loops, best of 3: 840 ms per loop

In [16]:
840./9.44


Out[16]:
88.98305084745763

In [ ]: