From 5ac2bcf761cba25405f85ff825967a172859db4c Mon Sep 17 00:00:00 2001 From: Yuki SUYAMA Date: Fri, 8 Dec 2023 16:04:04 +0900 Subject: [PATCH] Corrected odds ratio formula, #237 --- gseapy/stats.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gseapy/stats.py b/gseapy/stats.py index ae4b031..137d031 100644 --- a/gseapy/stats.py +++ b/gseapy/stats.py @@ -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)