From 46dabb326fab66b9c7b6a1e2a45571602685b150 Mon Sep 17 00:00:00 2001 From: Haibao Tang Date: Fri, 3 Nov 2023 20:34:52 -0700 Subject: [PATCH] Add test_multiple_testing --- makefile | 7 ++++--- tests/test_multiple_testing.py | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 tests/test_multiple_testing.py diff --git a/makefile b/makefile index e1849bf..94c719d 100755 --- a/makefile +++ b/makefile @@ -349,7 +349,7 @@ dnld_anno_uniprot: NOSETESTS := \ tests/test_study_zero.py \ tests/test_annotations_gaf.py::test_gaf_read_fb \ - tests/test_parents_ancestors.py \ + tests/test_parents_ancestors.py \ tests/test_rpt_gene2go_evidencecodes.py \ tests/test_sorter_sections.py \ tests/test_sorter_desc2nts.py \ @@ -376,7 +376,7 @@ NOSETESTS := \ tests/test_wr_tbl_subset.py \ tests/test_goea_local.py \ tests/test_write_hier.py \ - tests/test_cli_write_hierarchy.py \ + tests/test_cli_write_hierarchy.py \ tests/test_go_print.py \ tests/test_read_gaf_allow_nd.py \ tests/test_write_summary_cnts.py \ @@ -389,7 +389,8 @@ NOSETESTS := \ tests/test_goea_statsmodels.py \ tests/test_goea_rpt_bonferroni.py \ tests/test_wr_py_goea_results.py \ - tests/test_mapslim.py + tests/test_mapslim.py \ + tests/test_multiple_testing.py # Run all tests. If you are submitting a pull request, all tests must pass. update: diff --git a/tests/test_multiple_testing.py b/tests/test_multiple_testing.py new file mode 100644 index 0000000..7ee21e3 --- /dev/null +++ b/tests/test_multiple_testing.py @@ -0,0 +1,20 @@ +import numpy as np + +from goatools.multiple_testing import HolmBonferroni + + +def test_holmbonferroni(): + corrected_pvals = HolmBonferroni( + [0.01, 0.01, 0.03, 0.05, 0.005], a=0.05 + ).corrected_pvals + assert np.allclose(corrected_pvals, np.array([0.04, 0.04, 0.06, 0.05, 0.025])) + + +def test_holmbonferroni_pval_all_1(): + corrected_pvals = HolmBonferroni([1, 1, 1, 1, 1], a=0.05).corrected_pvals + assert np.allclose(corrected_pvals, np.array([1, 1, 1, 1, 1])) + + +def test_holmbonferroni_pval_mixed(): + corrected_pvals = HolmBonferroni([1, 0.01, 0.03, 0.05, 1], a=0.05).corrected_pvals + assert np.allclose(corrected_pvals, np.array([1.0, 0.05, 0.12, 0.15, 1.0]))