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

Odds ratios differ between enrichr and gseapy.enrich() #237

Closed
136s opened this issue Dec 8, 2023 · 3 comments
Closed

Odds ratios differ between enrichr and gseapy.enrich() #237

136s opened this issue Dec 8, 2023 · 3 comments

Comments

@136s
Copy link
Contributor

136s commented Dec 8, 2023

Hi,

As mentioned in the isssue #132 , the formula for calculating the odds ratio differs from the Enrichr definition.

Setup

I am reporting a problem with GSEApy version, Python version, and operating
system as follows:

import sys; print(sys.version)
import platform; print(platform.python_implementation()); print(platform.platform())
import gseapy; print(gseapy.__version__)

3.11.0 | packaged by conda-forge | (main, Oct 25 2022, 06:12:32) [MSC v.1929 64 bit (AMD64)]
CPython
Windows-10-10.0.19045-SP0
1.0.6

Steps to reproduce

from pathlib import Path
import subprocess

import gseapy as gp
import pandas as pd

def gene_list():
    gene_list_link = "https://raw.githubusercontent.com/zqfang/GSEApy/master/tests/data/gene_list.txt"
    return (
        pd.read_csv(gene_list_link, header=None, sep="\t")
        .squeeze()
        .str.strip()
        .to_list()
    )


def msigdb_hallmark_2020():
    kegg_gmt_link = "https://maayanlab.cloud/Enrichr/geneSetLibrary?mode=text&libraryName=MSigDB_Hallmark_2020"
    gmt_path = Path("MSigDB_Hallmark_2020.gmt")
    subprocess.run(["curl", "-o", gmt_path.as_posix(), kegg_gmt_link])
    gene_sets = gp.read_gmt(gmt_path.as_posix())
    gmt_path.unlink()
    return gene_sets


background = 20000
col_filter = [
    "Term",
    "Overlap",
    "P-value",
    "Adjusted P-value",
    "Odds Ratio",
    "Combined Score",
]

gseapy.enrichr() behaviour

enr1 = gp.enrichr(
    gene_list=gene_list(), gene_sets="MSigDB_Hallmark_2020", background=background
)
enr1.results[col_filter].head()
Term Overlap P-value Adjusted P-value Odds Ratio Combined Score
0 IL-6/JAK/STAT3 Signaling 19/87 1.1972245657484395e-09 5.986122828742197e-08 6.844693831437825 140.61232377322565
1 TNF-alpha Signaling via NF-kB 27/200 3.220897630403587e-08 5.368162717339312e-07 3.8415676480045455 66.270962847295
2 Complement 27/200 3.220897630403587e-08 5.368162717339312e-07 3.8415676480045455 66.270962847295
3 Inflammatory Response 24/200 1.6358898982890469e-06 2.0448623728613085e-05 3.343017806935333 44.54010811384466
4 heme Metabolism 23/200 5.533816327081873e-06 5.533816327081873e-05 3.181358113561503 38.50917198328045

gseapy.enrich() behaviour

enr2 = gp.enrich(
    gene_list=gene_list(), gene_sets=msigdb_hallmark_2020(), background=background
)
enr2.results[col_filter].sort_values("P-value").head()
Term Overlap P-value Adjusted P-value Odds Ratio Combined Score
22 IL-6/JAK/STAT3 Signaling 19/87 1.1974768437897092e-09 5.987384218948546e-08 5.678650945983 116.65680534113953
41 TNF-alpha Signaling via NF-kB 27/200 3.2213958391716315e-08 5.368993065286052e-07 3.511026893013104 60.56825441128164
10 Complement 27/200 3.2213958391716315e-08 5.368993065286052e-07 3.511026893013104 60.56825441128164
23 Inflammatory Response 24/200 1.6360465440779507e-06 2.0450581800974384e-05 3.1159207583102773 41.51412228865055
47 heme Metabolism 23/200 5.5342613169804326e-06 5.5342613169804326e-05 2.984896280199822 36.13083360370597

Enrichr behaviour

Enrichr result

MSigDB Hallmark 2020 table

The odds ratios for Enrichr and gseapy.enrichr() look the same, but the odds ratios for gseapy.enrich() do not.

Thank you.

136s added a commit to 136s/GSEApy that referenced this issue Dec 8, 2023
@zqfang
Copy link
Owner

zqfang commented Dec 15, 2023

Let see how issue #132 goes first

zqfang added a commit that referenced this issue Dec 21, 2023
Corrected odds ratio formula, #237
@zqfang
Copy link
Owner

zqfang commented Dec 21, 2023

Thank you so much for your contribution. the code has been merge into master. A new quick patch version (1.1.1) has just released.

@136s
Copy link
Contributor Author

136s commented Dec 22, 2023

Thanks for your quick merge and release!

@136s 136s closed this as completed Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants