Skip to content

Commit

Permalink
bug fix/enhancement HolmBonferroni correction (#282)
Browse files Browse the repository at this point in the history
Co-authored-by: Sean Cascarina <[email protected]>
  • Loading branch information
RossLabCSU and Sean Cascarina authored Nov 4, 2023
1 parent d48c32f commit c63a596
Showing 1 changed file with 5 additions and 2 deletions.
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

0 comments on commit c63a596

Please sign in to comment.