pegasus.gsea

pegasus.gsea(data, rank_key, pathways, method='gseapy', gsea_key='gsea_out', min_size=15, max_size=500, n_jobs=4, seed=0, verbose=True, **kwargs)[source]

Perform Gene Set Enrichment Analysis (GSEA).

Parameters
  • data (MultimodalData or UnimodalData) – Single-cell or pseudo-bulk data.

  • rank_key (str) – Key in pre-computed DE results representing gene ranks. The string format is de_key:attr, where de_key is the key of DE results in data.varm, and attr is the column name in data.varm['de_key'] used as the gene signatures for GSEA analysis.

  • pathways (str) – Either a keyword or a path to the gene set file in GMT format. If keyword, choosing from “hallmark” and “canonical_pathways” (MSigDB H and C2/CP).

  • method (str, optional, default: gseapy) – Specify which package to use as the backend for GSEA. By default gseapy, use GSEAPY’s prerank method. Notice that permutation_num=1000 is set by default. If you want to change these parameters, please reset in kwargs. Alternatively, if specify fgsea, then use R package fgsea, which requires rpy2 and R installation.

  • gsea_key (str, optional, default: "gsea_out") – Key to use to store GSEA results as a data frame.

  • min_size (int, optional, default: 15) – Minimum allowed number of genes from gene set also the data set.

  • max_size (int, optional, default: 500) – Maximum allowed number of genes from gene set also the data set.

  • n_jobs (int, optional, default: 4) – Numbr of threads used for parallel computation.

  • seed (int, optional, default: 0) – Random seed to make sure GSEA results are reproducible.

  • verbose (bool, optional, default: True) – If printing out progress of the job. Only works when method="gseapy".

  • kwargs – If method="gseapy", pass other keyword arguments to gseapy.prerank function. Details about GSEAPY prerank function’s optional parameters are here.

Return type

None

Returns

  • None

  • Update data.unsdata.uns[gsea_key]: GSEA outputs sorted by q-values (adjusted p-values) in ascending order, and if q-values are equal, sort by NES scores in descending order.

Examples

>>> pg.gsea(data, "deseq2:stat", "canonical_pathways")
>>> pg.gsea(data, "de_res:1:mwu_U", "canonical_pathways", method="fgsea")