Esempio n. 1
0
 def test_reorder_unifrac_res(self):
     """ reorder_unifrac_res should correctly reorder a misordered 3x3 matrix
     """
     mtx = numpy.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]], "float")
     unifrac_mtx = numpy.array([[1, 3, 2], [7, 9, 8], [4, 6, 5]], "float")
     sample_names = ["yo", "it's", "samples"]
     unifrac_sample_names = ["yo", "samples", "it's"]
     reordered_mtx = _reorder_unifrac_res([unifrac_mtx, unifrac_sample_names], sample_names)
     self.assertFloatEqual(reordered_mtx, mtx)
Esempio n. 2
0
 def test_reorder_unifrac_res(self):
     """ reorder_unifrac_res should correctly reorder a misordered 3x3 matrix
     """
     mtx = numpy.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 'float')
     unifrac_mtx = numpy.array([[1, 3, 2], [7, 9, 8], [4, 6, 5]], 'float')
     sample_names = ['yo', "it's", "samples"]
     unifrac_sample_names = ['yo', "samples", "it's"]
     reordered_mtx = _reorder_unifrac_res(
         [unifrac_mtx, unifrac_sample_names], sample_names)
     self.assertFloatEqual(reordered_mtx, mtx)
Esempio n. 3
0
 def test_make_unifrac_metric(self):
     """ exercise of the unweighted unifrac metric should not throw errors"""
     tree = parse_newick(self.l19_treestr, PhyloNode)
     unif = make_unifrac_metric(False, unifrac, True)
     res = unif(self.l19_data, self.l19_taxon_names, tree, self.l19_sample_names)
     envs = make_envs_dict(self.l19_data, self.l19_sample_names, self.l19_taxon_names)
     unifrac_mat, unifrac_names = fast_unifrac(tree, envs, modes=["distance_matrix"])["distance_matrix"]
     self.assertFloatEqual(res, _reorder_unifrac_res([unifrac_mat, unifrac_names], self.l19_sample_names))
     self.assertEqual(res[0, 0], 0)
     self.assertEqual(res[0, 3], 0.0)
     self.assertNotEqual(res[0, 1], 1.0)
Esempio n. 4
0
 def test_make_unifrac_metric(self):
     """ exercise of the unweighted unifrac metric should not throw errors"""
     tree = parse_newick(self.l19_treestr, PhyloNode)
     unif = make_unifrac_metric(False, unifrac, True)
     res = unif(self.l19_data, self.l19_taxon_names, tree,
         self.l19_sample_names)
     envs = make_envs_dict(self.l19_data, self.l19_sample_names,
         self.l19_taxon_names)
     unifrac_mat, unifrac_names = fast_unifrac(tree, envs, 
             modes=['distance_matrix'])['distance_matrix']
     self.assertFloatEqual(res, _reorder_unifrac_res([unifrac_mat,
         unifrac_names], self.l19_sample_names))
     self.assertEqual(res[0,0], 0)
     self.assertEqual(res[0,3], 0.0)
     self.assertNotEqual(res[0,1], 1.0)