scdef.tl.gsea ¶
gsea(model: scDEF, libs: Sequence[str] = ('KEGG_2019_Human',), custom_gene_sets: Optional[Dict[str, Sequence[str]]] = None, organism: str = 'Human', background_genes: Optional[Sequence[str]] = None, layers: Optional[Sequence[int]] = None, top_genes: Optional[int] = None, cutoff: float = 0.05, outdir: Optional[str] = None) -> DataFrame
Run Enrichr pathway enrichment for cached signatures across layers.
This utility uses signatures from scd.tl.get_stored_confident_signatures
and does not rely on model-level ranking by raw W.
Online libraries in libs are fetched to local dicts and merged with
custom_gene_sets so each factor is tested against one combined
gene-set universe using a single gp.enrich call. By default, runs
for all layers and stores per-layer results in adata.uns['factor_enrichments'].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
scDEF
|
fitted scDEF model with cached confident signatures — run
|
required |
libs
|
Sequence[str]
|
Enrichr library names to fetch and test against. Fetching these
requires network access; pass an empty sequence to run fully offline
against |
('KEGG_2019_Human',)
|
custom_gene_sets
|
Optional[Dict[str, Sequence[str]]]
|
your own gene sets, merged into the same universe as
|
None
|
organism
|
str
|
organism passed to Enrichr when resolving |
'Human'
|
background_genes
|
Optional[Sequence[str]]
|
background universe for the enrichment test. Defaults to the genes in the model. |
None
|
layers
|
Optional[Sequence[int]]
|
layer indices to run. Defaults to every layer. |
None
|
top_genes
|
Optional[int]
|
use only this many genes per signature, highest-scoring first. Defaults to the whole signature. |
None
|
cutoff
|
float
|
adjusted p-value below which a term is reported as enriched. |
0.05
|
outdir
|
Optional[str]
|
directory for gseapy's own output files. Defaults to not writing them. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
One row per enriched term per factor, concatenated across the requested |
DataFrame
|
layers. The same table is stored per layer in |
DataFrame
|
|