scatrans.compare_enrichment#
- scatrans.compare_enrichment(gene_clusters, *, fun=None, pval_cutoff=None, padj_cutoff=None, min_size=5, max_size=500, restrict_background_to_gene_sets=True, force_universe=False, organism='mouse', gene_sets='GO_Biological_Process', universe=None, adata=None, gene_set_source='scatrans', gene_case=None, verbose=True, return_all=False, raise_on_error=False, adjust_across_clusters=False, **kwargs)[source]#
Run enrichment analysis across multiple named groups/clusters/contrasts (clusterProfiler::compareCluster style).
Important default note on multiple-testing:
adjust_across_clusters=False(the default) performs BH FDR correction separately inside each cluster. This is conservative per group but when you have many clusters the overall false discovery rate across the whole table can be higher than a single global correction. If you intend to compare significance across clusters, useadjust_across_clusters=True; per-cluster calls then usereturn_all=Trueinternally (all size-eligible terms, including zero-overlap) before a single global BH step, and the final table is filtered bypadj_cutoff/pval_cutoffunless you also passreturn_all=True.Biological comparability notes (inspired by clusterProfiler best practices): - When adata= or universe= is supplied, the same background is used for every cluster.
This is critical for fair comparison across groups.
Term filtering (min_size etc.) and p-adjustment are done per-cluster (standard and conservative). You can post-filter the returned table.
A ‘Cluster’ column is always added as the first column.
Rich per-cluster metadata (including failures and empty) is stored under .attrs[“per_cluster”] and also under .attrs[“scatrans”][“per_cluster”].
- Parameters:
...
raise_on_error (bool, default False) – If True, any exception from a per-cluster enrichment call will be re-raised immediately (good for debugging). If False (default), the cluster is recorded as failed and execution continues (good for large batch runs).
fun (Callable | None)
pval_cutoff (float | None)
padj_cutoff (float | None)
min_size (int)
max_size (int)
restrict_background_to_gene_sets (bool)
force_universe (bool)
organism (str)
gene_sets (Any)
adata (Any | None)
gene_set_source (str)
gene_case (str | None)
verbose (bool)
return_all (bool)
adjust_across_clusters (bool)
kwargs (Any)
- Returns:
Concatenated results with a leading “Cluster” column. Compatible with the enhanced scat.pl.enrich_dotplot(…, cluster_col=”Cluster”) and scat.pl.enrich_upsetplot(…) / enrich_vennplot.
- Return type:
pd.DataFrame
Example
…