Skip to content

Commit

Permalink
Add test_multiple_testing
Browse files Browse the repository at this point in the history
  • Loading branch information
tanghaibao committed Nov 4, 2023
1 parent c63a596 commit 46dabb3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
7 changes: 4 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 \
Expand All @@ -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:
Expand Down
20 changes: 20 additions & 0 deletions tests/test_multiple_testing.py
Original file line number Diff line number Diff line change
@@ -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]))

0 comments on commit 46dabb3

Please sign in to comment.