{"id":21274859,"url":"https://github.com/maayanlab/turbogsea","last_synced_at":"2025-03-15T12:45:13.394Z","repository":{"id":149473594,"uuid":"414630435","full_name":"MaayanLab/turbogsea","owner":"MaayanLab","description":"Fast GSEA implementation of the prerank algorithm. Use Loess interpolation of bimodal ES distribution for accurate p-value estimation.","archived":false,"fork":false,"pushed_at":"2021-10-07T14:21:32.000Z","size":843,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-01-22T03:15:19.725Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MaayanLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-10-07T14:17:41.000Z","updated_at":"2021-11-13T04:21:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"dfab80a8-9ed4-4889-9bfe-9c8baed87919","html_url":"https://github.com/MaayanLab/turbogsea","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaayanLab%2Fturbogsea","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaayanLab%2Fturbogsea/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaayanLab%2Fturbogsea/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaayanLab%2Fturbogsea/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MaayanLab","download_url":"https://codeload.github.com/MaayanLab/turbogsea/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243732255,"owners_count":20338831,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-21T09:26:03.087Z","updated_at":"2025-03-15T12:45:13.375Z","avatar_url":"https://github.com/MaayanLab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg title=\"a title\" alt=\"turboGSEA\" src=\"https://github.com/MaayanLab/turbogsea/blob/main/icon/bgsea_small.png\" width=200\u003e\n\n# turboGSEA Introduction\n\nThis Python package provides a computationally performant \u003cb\u003eG\u003c/b\u003eene \u003cb\u003eS\u003c/b\u003eet \u003cb\u003eE\u003c/b\u003enrichment \u003cb\u003eA\u003c/b\u003enalysis (GSEA) implementation of the pre-rank algorithm [1]. GSEApy was used as the reference for the running sum and enrichment score calculation [2]. The algorithm estimates the enrichment score (ES) distribution of the null model by fitting data to gamma distibutions instead of calculating permutations for each gene set. turboGSEA calculates p-values with much higher accuracy than other reference implementations available in Python.\n\nGene set libraries can directly be loaded from Enrichr (\u003ca href=\"https://maayanlab.cloud/Enrichr\" target=\"_blank\"\u003ehttps://maayanlab.cloud/Enrichr\u003c/a\u003e). For this use the `turbogsea.enrichr.get_library()` function. All libraries can also be listed with `turbogsea.enrichr.print_libraries()`.\n\nturboGSEA provides plotting functions to generate publication ready figures similar to the original GSEA-P software. `turbogsea.plot.running_sum()` plots an enrichment plot for a single gene set and `turbogsea.plot.top_table()` plots the top `n` gene sets in a compact table. \n\n# Installation\n\nturboGSEA is currently only available as a Python package in this GitHub repository. You can install the turboGSEA Python package and its dependencies through pip by using the following command:\n\n```\n$ pip install git+https://github.com/MaayanLab/turbogsea.git\n```\n\n# Run enrichment analysis using turboGSEA\n\nturboGSEA depends on two input files. 1) a gene signature and 2) a gene set library. The gene set library is a dictionary with the name of the gene set as key and a list of gene ids as values. Gene set libraries can be loaded directly from Enrichr. The signature should be a pandas dataframe with two columns [0,1]. The first column should contain the gene ids (matching the gene ids in the gene set library).\n\n| index | 0\t| 1 |\n|:-----|:-------------:|------:|\n| 1\t| ADO\t| -7.833439 |\n| 2\t| CHUK\t| -7.800920 |\n| 3\t| GOLGA4\t| -7.78722 |\n| ... | ... | ... |\n\nThe gene set library is a dictionary with the gene set names as key and lists of gene ids as values.\n\n```python\n{\n'ERBB2 SIGNALING PATHWAY (GO:0038128)': ['CDC37',\n                                          'PTPN12',\n                                          'PIK3CA',\n                                          'SOS1',\n                                          'CPNE3',\n                                          'EGF',\n                                          ...\n                                         ],\n'HETEROTYPIC CELL-CELL ADHESION (GO:0034113)': ['DSC2',\n                                                 'ITGAV',\n                                                 'ITGAD',\n                                                 'LILRB2',\n                                                 ...\n                                                ],\n...\n}\n```\n\n### Python example\n\nThis short example will download two files (signature and gene set library). The gene set library consists of KEGG pathways and the signature is an example signature of differential gene expression of muscle samples from young and old donors. Differential gene expression was computed with Limma Voom.\n\n```python\nimport turbogsea as turbo\nimport urllib.request\nimport pandas as pd\n\n# download example GMT file from Enrichr\nurl = \"https://github.com/MaayanLab/turbogsea/raw/main/testing/ageing_muscle_gtex.tsv\"\nurllib.request.urlretrieve(url, \"ageing_muscle_gtex.tsv\")\n\n# read signature as pandas dataframe\nsignature = pd.read_csv(\"ageing_muscle_gtex.tsv\")\n\n# list available gene set libraries in Enrichr\nturbo.enrichr.print_libraries()\n\n# use enrichr submodule to retrieve gene set library\nlibrary = turbo.enrichr.get_library(\"KEGG_2021_Human\")\n\n# run enrichment analysis\nresult = turbo.gsea(signature, library)\n```\n\n### Optional Parameters\n\nThe main function of `turbogsea.gsea()` supports several optional parameters. The default parameters should work well for most use cases. \n\n| parameter name | type | default\t| description |\n|:-----|:---------|:-------------|:------|\n| `permutations`\t| int | 2000\t| Number of randomized permutations to estimate ES distributions. |\n| `min_size` | int | 5 | Minimum number of genes in geneset. |\n| `max_size` | int | Inf | Maximal number of genes in gene set. |\n| `anchors`\t| int | 20 | Number of gene set size distributions calculated. Remaining are interpolated. |\n| `processes`\t| int | 4\t| Number of parallel threads. Not much gain after 4 threads. |\n| `symmetric` | bool | False | Use same distribution parameters for negative and positive ES. If `False` estimate them separately. |\n| `plotting`| bool | False | Plot estimated anchor parametes. |\n| `verbose` | bool | False | Toggle additonal output. |\n| `seed` | int | 0 | Random seed. Same seed will result in identical result. If seed equal `-1` generate random seed. |\n\n### Plotting enrichment results\n\nturboGSEA supports several plotting functions. `turbogsea.plot.running_sum()` and `turbogsea.plot.top_table()` can be used after enrichment has been performed. `turbogsea.plot.running_sum()` shows the running sum of an individual gene set. It has a `compact` mode in which the image will be more readable if small. `turbogsea.plot.top_table()` shows the top `n` enriched gene sets and displays the results in a table, with normalized enrichment score (NES) and the distribution of hits relative to the gene ranking of the signature.\n\n### Example\n```python\n\nimport turbogsea as turbo\nimport urllib.request\nimport pandas as pd\n\n# download example GMT file from Enrichr\nurl = \"https://github.com/MaayanLab/turbogsea/raw/main/testing/ageing_muscle_gtex.tsv\"\nurllib.request.urlretrieve(url, \"ageing_muscle_gtex.tsv\")\n\n# read signature as pandas dataframe\nsignature = pd.read_csv(\"ageing_muscle_gtex.tsv\")\n\n# list available gene set libraries in Enrichr\nturbo.enrichr.print_libraries()\n\n# use enrichr submodule to retrieve gene set library\nlibrary = turbo.enrichr.get_library(\"KEGG_2021_Human\")\n\n# run enrichment analysis\nresult = turbo.gsea(signature, library)\n\n# plot the enrichment results and save to pdf\nfig = turbo.plot.running_sum(signature, \"CELL ADHESION MOLECULES\", library, result=result, compact=False)\nfig.savefig(\"running_sum.png\", bbox_inches='tight')\n\nfig_compact = turbo.plot.running_sum(signature, \"CELL ADHESION MOLECULES\", library, result=result, compact=True)\nfig_compact.savefig(\"running_sum_compact.png\", bbox_inches='tight')\n\nfig_table = turbo.plot.top_table(signature, library, result, n=15)\nfig_table.savefig(\"top_table.png\", bbox_inches='tight')\n\n```\n\nThe resulting plots will look like the examples below:\n\n#### running_sum.pdf\n\n\u003cdiv style=\"bachground-color: white\"\u003e\n\u003cimg title=\"a title\" alt=\"turboGSEA sunning_sum\" src=\"https://github.com/MaayanLab/turbogsea/blob/main/icon/running_sum.png\" width=300\u003e\n\u003c/div\u003e\n\n#### running_sum_compact.pdf\n\u003cimg title=\"a title\" alt=\"turboGSEA sunning_sum\" src=\"https://github.com/MaayanLab/turbogsea/blob/main/icon/running_sum_compact.png\" width=300\u003e\n\n#### top_table.pdf\n\u003cimg title=\"a title\" alt=\"turboGSEA sunning_sum\" src=\"https://github.com/MaayanLab/turbogsea/blob/main/icon/top_table.png\" width=300\u003e\n\n# Dependencies\nPython 3.6+\n\n# References\n\n[1] Subramanian, Aravind, Heidi Kuehn, Joshua Gould, Pablo Tamayo, and Jill P. Mesirov. \"GSEA-P: a desktop application for Gene Set Enrichment Analysis.\" Bioinformatics 23, no. 23 (2007): 3251-3253.\n\n[2] Fang, Z., A. Wolf, Y. Liao, A. McKay, F. Fröhlich, J. Kimmel, L. Xiaohui, and sorrge. \"zqfang/gseapy: gseapy-v0. 10.3.\" (2021).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaayanlab%2Fturbogsea","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaayanlab%2Fturbogsea","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaayanlab%2Fturbogsea/lists"}