Skip to content

Commit

Permalink
Merge pull request #238 from 136s/master
Browse files Browse the repository at this point in the history
Corrected odds ratio formula, #237
  • Loading branch information
zqfang committed Dec 21, 2023
2 parents 4d2540f + 5ac2bcf commit 3b2594d
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 3b2594d

Please sign in to comment.