Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fix/enhancement HolmBonferroni correction #282

Merged
merged 1 commit into from
Nov 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions goatools/multiple_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ class HolmBonferroni(_AbstractCorrection):
def set_correction(self):
"""Do Holm-Bonferroni multiple test correction on original p-values."""
if len(self.pvals):
idxs, correction = list(zip(*self._generate_significant()))
if all(p==1. for p in self.pvals):
idxs, correction = [(0,), (1,)]
else:
idxs, correction = list(zip(*self._generate_significant()))
idxs = list(idxs)
self.corrected_pvals[idxs] *= correction

Expand All @@ -218,7 +221,7 @@ def _generate_significant(self):
for _, idxs in groupby(pvals_idxs, lambda x: x[0]):
idxs = list(idxs)
for p, i in idxs:
if p * 1. / num_pvals < self.a:
if p < 1.:
yield (i, num_pvals)
num_pvals -= len(idxs)

Expand Down