Ejemplo n.º 1
0
    def test_ancom_tau(self):
        exp1 = pd.DataFrame({'W': np.array([8, 7, 3, 3, 7, 3, 3, 3, 3]),
                            'reject': np.array([True, False, False, False,
                                                False, False, False, False,
                                                False], dtype=bool)})
        exp2 = pd.DataFrame({'W': np.array([17, 17, 5, 6, 16, 5, 7, 5,
                                            4, 5, 8, 4, 5, 16, 5, 11, 4, 6]),
                            'reject': np.array([True, True, False, False,
                                                True, False, False, False,
                                                False, False, False, False,
                                                False, True, False, False,
                                                False, False],  dtype=bool)})
        exp3 = pd.DataFrame({'W': np.array([16, 16, 17, 10, 17, 16, 16,
                                            15, 15, 15, 13, 10, 10, 10,
                                            9, 9, 9, 9]),
                            'reject': np.array([True, True, True, False,
                                                True, True, True, True,
                                                True, True, True, False,
                                                False, False, False, False,
                                                False, False],  dtype=bool)})

        result1 = ancom(self.table4, self.cats4, tau=0.25)
        result2 = ancom(self.table9, self.cats9, tau=0.02)
        result3 = ancom(self.table10, self.cats10, tau=0.02)

        assert_data_frame_almost_equal(result1, exp1)
        assert_data_frame_almost_equal(result2, exp2)
        assert_data_frame_almost_equal(result3, exp3)
Ejemplo n.º 2
0
 def test_ancom_no_signal(self):
     result = ancom(self.table3,
                    self.cats3,
                    multiple_comparisons_correction=None)
     exp = pd.DataFrame({'W': np.array([0]*7),
                         'reject': np.array([False]*7, dtype=bool)})
     assert_data_frame_almost_equal(result, exp)
Ejemplo n.º 3
0
 def test_ancom_alpha(self):
     result = ancom(self.table1, self.cats1, alpha=0.5)
     exp = pd.DataFrame({'W': np.array([6, 6, 4, 5, 5, 4, 2]),
                         'reject': np.array([True, True, False, True,
                                             True, False, False],
                                            dtype=bool)})
     assert_data_frame_almost_equal(result, exp)
Ejemplo n.º 4
0
 def test_ancom_basic_counts_swapped(self):
     result = ancom(self.table8, self.cats8)
     exp = pd.DataFrame({'W': np.array([5, 5, 2, 2, 2, 2, 2]),
                         'reject': np.array([True, True, False, False,
                                             False, False, False],
                                            dtype=bool)})
     assert_data_frame_almost_equal(result, exp)
Ejemplo n.º 5
0
 def test_ancom_multiple_comparisons(self):
     result = ancom(self.table1,
                    self.cats1,
                    multiple_comparisons_correction='holm-bonferroni',
                    significance_test=scipy.stats.mannwhitneyu)
     exp = pd.DataFrame({'W': np.array([0]*7),
                         'reject': np.array([False]*7, dtype=bool)})
     assert_data_frame_almost_equal(result, exp)
Ejemplo n.º 6
0
 def test_ancom_no_signal(self):
     result = ancom(self.table3,
                    self.cats3,
                    multiple_comparisons_correction=None)
     exp = pd.DataFrame({
         'W': np.array([0] * 7),
         'reject': np.array([False] * 7, dtype=bool)
     })
     assert_data_frame_almost_equal(result, exp)
Ejemplo n.º 7
0
 def test_ancom_alpha(self):
     result = ancom(self.table1, self.cats1, alpha=0.5)
     exp = pd.DataFrame({
         'W':
         np.array([6, 6, 4, 5, 5, 4, 2]),
         'reject':
         np.array([True, True, False, True, True, False, False], dtype=bool)
     })
     assert_data_frame_almost_equal(result, exp)
Ejemplo n.º 8
0
 def test_ancom_letter_categories(self):
     result = ancom(self.table7,
                    self.cats7,
                    multiple_comparisons_correction=None)
     exp = pd.DataFrame({'W': np.array([5, 3, 3, 2, 2, 5, 2]),
                         'reject': np.array([True, False, False, False,
                                             False, True, False],
                                            dtype=bool)})
     assert_data_frame_almost_equal(result, exp)
Ejemplo n.º 9
0
 def test_ancom_noncontiguous(self):
     result = ancom(self.table5,
                    self.cats5,
                    multiple_comparisons_correction=None)
     exp = pd.DataFrame({'W': np.array([6, 2, 2, 2, 2, 6, 2]),
                         'reject': np.array([True, False, False, False,
                                             False, True, False],
                                            dtype=bool)})
     assert_data_frame_almost_equal(result, exp)
Ejemplo n.º 10
0
 def test_ancom_basic_counts_swapped(self):
     result = ancom(self.table8, self.cats8)
     exp = pd.DataFrame({
         'W':
         np.array([5, 5, 2, 2, 2, 2, 2]),
         'reject':
         np.array([True, True, False, False, False, False, False],
                  dtype=bool)
     })
     assert_data_frame_almost_equal(result, exp)
Ejemplo n.º 11
0
 def test_ancom_multiple_comparisons(self):
     result = ancom(self.table1,
                    self.cats1,
                    multiple_comparisons_correction='holm-bonferroni',
                    significance_test=scipy.stats.mannwhitneyu)
     exp = pd.DataFrame({
         'W': np.array([0] * 7),
         'reject': np.array([False] * 7, dtype=bool)
     })
     assert_data_frame_almost_equal(result, exp)
Ejemplo n.º 12
0
 def test_ancom_alternative_test(self):
     result = ancom(self.table1,
                    self.cats1,
                    multiple_comparisons_correction=None,
                    significance_test=scipy.stats.ttest_ind)
     exp = pd.DataFrame({'W': np.array([5, 5, 2, 2, 2, 2, 2]),
                         'reject': np.array([True,  True, False, False,
                                             False, False, False],
                                            dtype=bool)})
     assert_data_frame_almost_equal(result, exp)
Ejemplo n.º 13
0
    def test_ancom_tau(self):
        exp1 = pd.DataFrame({
            'W':
            np.array([8, 7, 3, 3, 7, 3, 3, 3, 3]),
            'reject':
            np.array(
                [True, False, False, False, False, False, False, False, False],
                dtype=bool)
        })
        exp2 = pd.DataFrame({
            'W':
            np.array(
                [17, 17, 5, 6, 16, 5, 7, 5, 4, 5, 8, 4, 5, 16, 5, 11, 4, 6]),
            'reject':
            np.array([
                True, True, False, False, True, False, False, False, False,
                False, False, False, False, True, False, False, False, False
            ],
                     dtype=bool)
        })
        exp3 = pd.DataFrame({
            'W':
            np.array([
                16, 16, 17, 10, 17, 16, 16, 15, 15, 15, 13, 10, 10, 10, 9, 9,
                9, 9
            ]),
            'reject':
            np.array([
                True, True, True, False, True, True, True, True, True, True,
                True, False, False, False, False, False, False, False
            ],
                     dtype=bool)
        })

        result1 = ancom(self.table4, self.cats4, tau=0.25)
        result2 = ancom(self.table9, self.cats9, tau=0.02)
        result3 = ancom(self.table10, self.cats10, tau=0.02)

        assert_data_frame_almost_equal(result1, exp1)
        assert_data_frame_almost_equal(result2, exp2)
        assert_data_frame_almost_equal(result3, exp3)
Ejemplo n.º 14
0
 def test_ancom_letter_categories(self):
     result = ancom(self.table7,
                    self.cats7,
                    multiple_comparisons_correction=None)
     exp = pd.DataFrame({
         'W':
         np.array([5, 3, 3, 2, 2, 5, 2]),
         'reject':
         np.array([True, False, False, False, False, True, False],
                  dtype=bool)
     })
     assert_data_frame_almost_equal(result, exp)
Ejemplo n.º 15
0
 def test_ancom_noncontiguous(self):
     result = ancom(self.table5,
                    self.cats5,
                    multiple_comparisons_correction=None)
     exp = pd.DataFrame({
         'W':
         np.array([6, 2, 2, 2, 2, 6, 2]),
         'reject':
         np.array([True, False, False, False, False, True, False],
                  dtype=bool)
     })
     assert_data_frame_almost_equal(result, exp)
Ejemplo n.º 16
0
 def test_ancom_normal_data(self):
     result = ancom(self.table2,
                    self.cats2,
                    multiple_comparisons_correction=None,
                    significance_test=scipy.stats.ttest_ind)
     exp = pd.DataFrame({'W': np.array([8, 8, 3, 3,
                                        8, 3, 3, 3, 3]),
                         'reject': np.array([True, True, False, False,
                                             True, False, False,
                                             False, False],
                                            dtype=bool)})
     assert_data_frame_almost_equal(result, exp)
Ejemplo n.º 17
0
 def test_ancom_alternative_test(self):
     result = ancom(self.table1,
                    self.cats1,
                    multiple_comparisons_correction=None,
                    significance_test=scipy.stats.ttest_ind)
     exp = pd.DataFrame({
         'W':
         np.array([5, 5, 2, 2, 2, 2, 2]),
         'reject':
         np.array([True, True, False, False, False, False, False],
                  dtype=bool)
     })
     assert_data_frame_almost_equal(result, exp)
Ejemplo n.º 18
0
 def test_ancom_normal_data(self):
     result = ancom(self.table2,
                    self.cats2,
                    multiple_comparisons_correction=None,
                    significance_test=scipy.stats.ttest_ind)
     exp = pd.DataFrame({
         'W':
         np.array([8, 8, 3, 3, 8, 3, 3, 3, 3]),
         'reject':
         np.array(
             [True, True, False, False, True, False, False, False, False],
             dtype=bool)
     })
     assert_data_frame_almost_equal(result, exp)
Ejemplo n.º 19
0
 def test_ancom_multiple_groups(self):
     test_table = pd.DataFrame(self.table4)
     original_table = copy.deepcopy(test_table)
     test_cats = pd.Series(self.cats4)
     original_cats = copy.deepcopy(test_cats)
     result = ancom(test_table, test_cats)
     # Test to make sure that the input table hasn't be altered
     assert_data_frame_almost_equal(original_table, test_table)
     # Test to make sure that the input table hasn't be altered
     pdt.assert_series_equal(original_cats, test_cats)
     exp = pd.DataFrame({'W': np.array([8, 7, 3, 3, 7, 3, 3, 3, 3]),
                         'reject': np.array([True, True, False, False,
                                             True, False, False, False,
                                             False], dtype=bool)})
     assert_data_frame_almost_equal(result, exp)
Ejemplo n.º 20
0
    def test_permutative_f(self):
        test_table = pd.DataFrame(self.table1)
        original_table = copy.deepcopy(test_table)
        test_cats = pd.Series(self.cats1)
        original_cats = copy.deepcopy(test_cats)
        result = ancom(test_table, test_cats, significance_test='permutative-anova')
        # Test to make sure that the input table hasn't be altered
        assert_data_frame_almost_equal(original_table, test_table)
        # Test to make sure that the input table hasn't be altered
        pdt.assert_series_equal(original_cats, test_cats)
        exp = pd.DataFrame({'W': np.array([6, 6, 3, 3, 2, 2, 2]),
                            'reject': np.array([True, True, False, False,
                                                False, False, False],
                                               dtype=bool)})

        assert_data_frame_almost_equal(result, exp)
Ejemplo n.º 21
0
 def test_ancom_basic_counts(self):
     test_table = pd.DataFrame(self.table1)
     original_table = copy.deepcopy(test_table)
     test_cats = pd.Series(self.cats1)
     original_cats = copy.deepcopy(test_cats)
     result = ancom(test_table,
                    test_cats,
                    multiple_comparisons_correction=None)
     # Test to make sure that the input table hasn't be altered
     assert_data_frame_almost_equal(original_table, test_table)
     # Test to make sure that the input table hasn't be altered
     pdt.assert_series_equal(original_cats, test_cats)
     exp = pd.DataFrame({'W': np.array([5, 5, 2, 2, 2, 2, 2]),
                         'reject': np.array([True, True, False, False,
                                             False, False, False],
                                            dtype=bool)})
     assert_data_frame_almost_equal(result, exp)
Ejemplo n.º 22
0
 def test_ancom_multiple_groups(self):
     test_table = pd.DataFrame(self.table4)
     original_table = copy.deepcopy(test_table)
     test_cats = pd.Series(self.cats4)
     original_cats = copy.deepcopy(test_cats)
     result = ancom(test_table, test_cats)
     # Test to make sure that the input table hasn't be altered
     assert_data_frame_almost_equal(original_table, test_table)
     # Test to make sure that the input table hasn't be altered
     pdt.assert_series_equal(original_cats, test_cats)
     exp = pd.DataFrame({
         'W':
         np.array([8, 7, 3, 3, 7, 3, 3, 3, 3]),
         'reject':
         np.array(
             [True, True, False, False, True, False, False, False, False],
             dtype=bool)
     })
     assert_data_frame_almost_equal(result, exp)
Ejemplo n.º 23
0
 def test_ancom_basic_counts(self):
     test_table = pd.DataFrame(self.table1)
     original_table = copy.deepcopy(test_table)
     test_cats = pd.Series(self.cats1)
     original_cats = copy.deepcopy(test_cats)
     result = ancom(test_table,
                    test_cats,
                    multiple_comparisons_correction=None)
     # Test to make sure that the input table hasn't be altered
     assert_data_frame_almost_equal(original_table, test_table)
     # Test to make sure that the input table hasn't be altered
     pdt.assert_series_equal(original_cats, test_cats)
     exp = pd.DataFrame({
         'W':
         np.array([5, 5, 2, 2, 2, 2, 2]),
         'reject':
         np.array([True, True, False, False, False, False, False],
                  dtype=bool)
     })
     assert_data_frame_almost_equal(result, exp)
Ejemplo n.º 24
0
    def test_permutative_f(self):
        test_table = pd.DataFrame(self.table1)
        original_table = copy.deepcopy(test_table)
        test_cats = pd.Series(self.cats1)
        original_cats = copy.deepcopy(test_cats)
        result = ancom(test_table,
                       test_cats,
                       significance_test='permutative-anova')
        # Test to make sure that the input table hasn't be altered
        assert_data_frame_almost_equal(original_table, test_table)
        # Test to make sure that the input table hasn't be altered
        pdt.assert_series_equal(original_cats, test_cats)
        exp = pd.DataFrame({
            'W':
            np.array([6, 6, 3, 3, 2, 2, 2]),
            'reject':
            np.array([True, True, False, False, False, False, False],
                     dtype=bool)
        })

        assert_data_frame_almost_equal(result, exp)
Ejemplo n.º 25
0
 def test_ancom_fail_size_mismatch(self):
     with self.assertRaises(ValueError):
         ancom(self.table1, self.badcats3)
Ejemplo n.º 26
0
    def test_ancom_fail_missing(self):
        with self.assertRaises(ValueError):
            ancom(self.bad3, self.cats1)

        with self.assertRaises(ValueError):
            ancom(self.table1, self.badcats1)
Ejemplo n.º 27
0
 def test_ancom_fail_not_implemented_multiple_comparisons_correction(self):
     with self.assertRaises(ValueError):
         ancom(self.table2,
               self.cats2,
               multiple_comparisons_correction='fdr')
Ejemplo n.º 28
0
 def test_ancom_fail_negative(self):
     with self.assertRaises(ValueError):
         ancom(self.bad2, self.cats2, multiple_comparisons_correction=None)
Ejemplo n.º 29
0
 def test_ancom_fail_type(self):
     with self.assertRaises(TypeError):
         ancom(self.table1.values, self.cats1)
     with self.assertRaises(TypeError):
         ancom(self.table1, self.cats1.values)
Ejemplo n.º 30
0
 def test_ancom_fail_multiple_groups(self):
     with self.assertRaises(TypeError):
         ancom(self.table4, self.cats4,
               significance_test=scipy.stats.ttest_ind)
Ejemplo n.º 31
0
 def test_ancom_fail_alpha(self):
     with self.assertRaises(ValueError):
         ancom(self.table1, self.cats1, alpha=-1)
     with self.assertRaises(ValueError):
         ancom(self.table1, self.cats1, alpha=1.1)
Ejemplo n.º 32
0
 def test_ancom_fail_not_implemented_multiple_comparisons_correction(self):
     with self.assertRaises(ValueError):
         ancom(self.table2, self.cats2,
               multiple_comparisons_correction='fdr')
Ejemplo n.º 33
0
    def test_ancom_fail_missing(self):
        with self.assertRaises(ValueError):
            ancom(self.bad3, self.cats1)

        with self.assertRaises(ValueError):
            ancom(self.table1, self.badcats1)
Ejemplo n.º 34
0
 def test_ancom_fail_size_mismatch(self):
     with self.assertRaises(ValueError):
         ancom(self.table1, self.badcats3)
Ejemplo n.º 35
0
 def test_ancom_fail_1_group(self):
     with self.assertRaises(ValueError):
         ancom(self.table1, self.badcats5)
Ejemplo n.º 36
0
 def test_ancom_fail_tau(self):
     with self.assertRaises(ValueError):
         ancom(self.table1, self.cats1, tau=-1)
     with self.assertRaises(ValueError):
         ancom(self.table1, self.cats1, tau=1.1)
Ejemplo n.º 37
0
 def test_ancom_fail_alpha(self):
     with self.assertRaises(ValueError):
         ancom(self.table1, self.cats1, alpha=-1)
     with self.assertRaises(ValueError):
         ancom(self.table1, self.cats1, alpha=1.1)
Ejemplo n.º 38
0
 def test_ancom_fail_1_group(self):
     with self.assertRaises(ValueError):
         ancom(self.table1, self.badcats5)
Ejemplo n.º 39
0
 def test_ancom_fail_tau(self):
     with self.assertRaises(ValueError):
         ancom(self.table1, self.cats1, tau=-1)
     with self.assertRaises(ValueError):
         ancom(self.table1, self.cats1, tau=1.1)
Ejemplo n.º 40
0
 def test_ancom_fail_negative(self):
     with self.assertRaises(ValueError):
         ancom(self.bad2, self.cats2, multiple_comparisons_correction=None)
Ejemplo n.º 41
0
 def test_ancom_fail_multiple_groups(self):
     with self.assertRaises(TypeError):
         ancom(self.table4,
               self.cats4,
               significance_test=scipy.stats.ttest_ind)
Ejemplo n.º 42
0
 def test_ancom_fail_type(self):
     with self.assertRaises(TypeError):
         ancom(self.table1.values, self.cats1)
     with self.assertRaises(TypeError):
         ancom(self.table1, self.cats1.values)