def test_evaluate_composition_depth_too_high(self):
     with self.assertRaisesRegex(ValueError, "8 is larger than the max"):
         _evaluate_composition(
             self.exp, self.obs, depth=8, palette='Set1',
             plot_tar=True, plot_tdr=True, plot_r_value=True,
             plot_r_squared=True, plot_bray_curtis=False,
             plot_jaccard=False, plot_observed_features=True,
             plot_observed_features_ratio=True, metadata=None)
 def test_evaluate_composition_metadata_not_superset(self):
     incomplete_md = qiime2.CategoricalMetadataColumn(
                 pd.Series(['there_can_only_be_one'], name='mock_id',
                           index=pd.Index(['s3'], name='id')))
     with self.assertRaisesRegex(ValueError, "Missing samples in metadata"):
         _evaluate_composition(
             self.exp_one_sample, self.obs, depth=7, palette='Set1',
             plot_tar=True, plot_tdr=True, plot_r_value=True,
             plot_r_squared=True, plot_bray_curtis=False,
             plot_jaccard=False, plot_observed_features=True,
             plot_observed_features_ratio=True, metadata=incomplete_md)
 def test_evaluate_composition_metadata_values_not_subset(self):
     underrepresented_md = qiime2.CategoricalMetadataColumn(
         pd.Series(['there_can_only_be_one', 'what_is_this?',
                    'i_am_not_really_here'],
                   name='mock_id', index=pd.Index(['s3', 's1', 's2'],
                                                  name='id')))
     with self.assertRaisesRegex(ValueError, "Missing samples in table"):
         _evaluate_composition(
             self.exp_one_sample, self.obs, depth=7, palette='Set1',
             plot_tar=True, plot_tdr=True, plot_r_value=True,
             plot_r_squared=True, plot_bray_curtis=False,
             plot_jaccard=False, plot_observed_features=True,
             plot_observed_features_ratio=True,
             metadata=underrepresented_md)
Exemplo n.º 4
0
 def test_evaluate_composition_metadata_not_superset(self):
     incomplete_md = qiime2.MetadataCategory(
         pd.DataFrame({'mock_id': ['there_can_only_be_one']},
                      index=['s3'])['mock_id'])
     with self.assertRaisesRegex(ValueError, "Missing samples in metadata"):
         _evaluate_composition(self.exp_one_sample,
                               self.obs,
                               depth=7,
                               palette='Set1',
                               plot_tar=True,
                               plot_tdr=True,
                               plot_r_value=True,
                               plot_r_squared=True,
                               plot_observed_features=True,
                               plot_observed_features_ratio=True,
                               metadata=incomplete_md)
Exemplo n.º 5
0
 def test_evaluate_composition_dont_test_all_levels(self):
     empty_expectations = pd.DataFrame(
         columns=['s1', 's2', 's3']).astype(float)
     empty_expectations.index.name = 'Taxon'
     mc = self.misclassified.loc[[
         'k__Ag;p__Bg;c__Cg;o__Dg;f__Eg;g__Fg;s__Gg'
     ]]
     mc.index = ['k__Ag;p__Bg;c__Cg;o__Dg;f__Eg']
     mc.index.name = 'Taxon'
     res = _evaluate_composition(self.exp,
                                 self.obs,
                                 depth=5,
                                 palette='Set1',
                                 plot_tar=True,
                                 plot_tdr=True,
                                 plot_r_value=True,
                                 plot_r_squared=True,
                                 plot_observed_features=True,
                                 plot_observed_features_ratio=True,
                                 metadata=None)
     pdt.assert_frame_equal(res[0],
                            self.exp_results[self.exp_results['level'] < 6])
     pdt.assert_frame_equal(res[1], empty_expectations)
     pdt.assert_frame_equal(res[2], mc)
     pdt.assert_frame_equal(res[3], empty_expectations)
 def test_evaluate_composition_mockrobiota(self):
     res = _evaluate_composition(
         self.exp, self.obs, depth=7, palette='Set1',
         plot_tar=True, plot_tdr=True, plot_r_value=True,
         plot_r_squared=True, plot_bray_curtis=True,
         plot_jaccard=True, plot_observed_features=True,
         plot_observed_features_ratio=True, metadata=None)
     pdt.assert_frame_equal(res[0], self.exp_results)
     pdt.assert_frame_equal(res[1], self.false_neg)
     pdt.assert_frame_equal(res[2], self.misclassified)
     pdt.assert_frame_equal(res[3], self.underclassified)
Exemplo n.º 7
0
 def test_evaluate_composition_metadata_values_not_subset(self):
     underrepresented_md = qiime2.MetadataCategory(
         pd.DataFrame(
             {
                 'mock_id': [
                     'there_can_only_be_one', 'what_is_this?',
                     'i_am_not_really_here'
                 ]
             },
             index=['s3', 's1', 's2'])['mock_id'])
     with self.assertRaisesRegex(ValueError, "Missing samples in table"):
         _evaluate_composition(self.exp_one_sample,
                               self.obs,
                               depth=7,
                               palette='Set1',
                               plot_tar=True,
                               plot_tdr=True,
                               plot_r_value=True,
                               plot_r_squared=True,
                               plot_observed_features=True,
                               plot_observed_features_ratio=True,
                               metadata=underrepresented_md)
 def test_evaluate_composition_mockrobiota_metadata_map(self):
     res = _evaluate_composition(
         self.exp, self.obs, depth=7, palette='Set1',
         plot_tar=True, plot_tdr=True, plot_r_value=True,
         plot_r_squared=True, plot_bray_curtis=False,
         plot_jaccard=False, plot_observed_features=True,
         plot_observed_features_ratio=True, metadata=self.metadata)
     false_neg = self.false_neg[['HMPMockV1.1.Even1',
                                 'HMPMockV1.2.Staggered1']]
     pdt.assert_frame_equal(res[0], self.exp_results)
     pdt.assert_frame_equal(res[1], false_neg)
     pdt.assert_frame_equal(res[2], self.misclassified)
     pdt.assert_frame_equal(res[3], self.underclassified)
 def test_evaluate_composition_metadata_map_to_mock_sample(self):
     res = _evaluate_composition(
         self.exp_one_sample, self.obs, depth=7, palette='Set1',
         plot_tar=True, plot_tdr=True, plot_r_value=True,
         plot_r_squared=True, plot_bray_curtis=False,
         plot_jaccard=False, plot_observed_features=True,
         plot_observed_features_ratio=True,
         metadata=self.metadata_one_sample)
     pdt.assert_frame_equal(res[0], self.exp_results)
     # false_neg should contain only one column header since the map
     # contains one sample (rename to match column name in exp_one_sample)
     false_neg = self.false_neg[['s1']]
     false_neg.columns = ['there_can_only_be_one']
     false_neg.index.name = 'Taxon'
     pdt.assert_frame_equal(res[1], false_neg)
     pdt.assert_frame_equal(res[2], self.misclassified)
     pdt.assert_frame_equal(res[3], self.underclassified)