Skip to content

Commit

Permalink
Corrected odds ratio formula, #237
Browse files Browse the repository at this point in the history
  • Loading branch information
136s committed Dec 8, 2023
1 parent 4d2540f commit 5ac2bcf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions gseapy/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ def calc_pvalues(query, gene_sets, background=20000, **kwargs):
# expect_count = k*m/bg
# oddr= x / expect_count
# oddr= (x*(bg-m))/(m*(k-x)) # thanks to @sreichl.
oddr = ((x + 0.5) * (bg - m + 0.5)) / (
(m + 0.5) * (k - x + 0.5)
) # Haldane-Anscombe correction, issue #132
# oddr = ((x + 0.5) * (bg - m + 0.5)) / (
# (m + 0.5) * (k - x + 0.5)
# ) # Haldane-Anscombe correction, issue #132
bu = 0.5 # base up for Haldane-Anscombe correction. When bu=0, the result is exactly equal to Enrichr.
oddr = ((x + bu) * (bg - m - k + x + bu)) / ((m - x + bu) * (k - x + bu)) # issue #237
vals.append((s, pval, oddr, x, m, hits))

return zip(*vals)
Expand Down

0 comments on commit 5ac2bcf

Please sign in to comment.