gsea
Run single-omic GSEA with a gmt and a rank list in form of list[tuple[str, float]].
Parameters
gmt_path-Stringof the path to the gmt file of interestrank_list-list[tuple[str, float]]the rank list of interest.
Returns
Returns a list containing the GSEA results for every set.
Panics
Panics if the GMT or the rank list is malformed or not at specified path.
Example
import webgestaltpy
def create_rank_list(file_path: str) -> list[tuple[str, float]]:
"""Function that converts rnk file to format for gsea().
This is for demo purposes. gsea_from_files would be more convenient in this case.
However, for when the scores are calculated in a Python script, gsea() allows you to directly
use the results without having to save to a file first.
"""
res = []
with open(file_path, "r") as r:
lines = r.readlines()
for line in lines:
if "\t" in line:
vals = line.split("\t")
res.append((vals[0], float(vals[1])))
return res
res = webgestaltpy.gsea("kegg.gmt", create_rank_list("test.rnk"))
print(res[0:2]) ## print first two results
Output
Your results may vary depending on random permutations