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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)