Skip to content

meta_gsea

Run a meta-analysis GSEA with provided rank objects.

Parameters

  • gmt_path - String of the path to the gmt file of interest
  • rank_lists - Lists of list[tuple[str, float]]s of the rank lists of interest.

Returns

Returns a list of a list of dictionaries with the results containing the GSEA results for every set.

The first list contains the results of the meta-analysis. The following lists are the results for each list individually.

Panics

Panics if the any file or 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 re/
res = webgestaltpy.meta_gsea("kegg.gmt", [create_rank_list("test.rnk"), create_rank_list("second_test.rnk")])

res would be a list containing the results of the meta-analysis and each list run individually. In this example, res[0] would look be the results of the meta-analysis. res[1] would be the results from test.rnk, res[2] would be the results from second_test.rnk, and so on.

See the documentation for webgestaltpy.gsea for specifics about the format of the results.