def test_unweighted_root_eval_issue_46(self): tree = self.get_data_path('crawford.tre') table = self.get_data_path('crawford.biom') table_inmem = load_table(table) tree_inmem = skbio.TreeNode.read(tree) ids = table_inmem.ids() otu_ids = table_inmem.ids(axis='observation') cnts = table_inmem.matrix_data.astype(int).toarray().T exp = skbio.diversity.beta_diversity('unweighted_unifrac', cnts, ids=ids, otu_ids=otu_ids, tree=tree_inmem) obs = ssu(table, tree, 'unweighted', False, 1.0, False, 1) npt.assert_almost_equal(obs.data, exp.data) obs2 = unweighted(table, tree) npt.assert_almost_equal(obs2.data, exp.data) tmpfile = '/tmp/uf_ta_1.md5' unweighted_to_file(table, tree, tmpfile, pcoa_dims=0) try: obs3 = h5unifrac(tmpfile) npt.assert_almost_equal(obs3.data, exp.data) finally: os.unlink(tmpfile)
def unweighted_unifrac(table: BIOMV210Format, phylogeny: NewickFormat, threads: int = 1, bypass_tips: bool = False) -> skbio.DistanceMatrix: return unifrac.unweighted(str(table), str(phylogeny), threads=threads, variance_adjusted=False, bypass_tips=bypass_tips)
def test_unweighted_fp32_inmem(self): tree_fp = self.get_data_path('crawford.tre') table_fp = self.get_data_path('crawford.biom') table = load_table(table_fp) tree = skbio.TreeNode.read(tree_fp) ids = table.ids() otu_ids = table.ids(axis='observation') cnts = table.matrix_data.astype(int).toarray().T exp = skbio.diversity.beta_diversity('unweighted_unifrac', cnts, ids=ids, otu_ids=otu_ids, tree=tree) obs = ssu_inmem(table, tree, 'unweighted_fp32', False, 1.0, False, 1) npt.assert_almost_equal(obs.data, exp.data, decimal=6) obs2 = unweighted(table_fp, tree_fp) npt.assert_almost_equal(obs2.data, exp.data)