scatrans.extract_gene_lists#
- scatrans.extract_gene_lists(de_results, *, logfc_cutoff=0.5, pval_cutoff=0.05, logfc_direction='up', separate_directions=False, name_prefix=None, gene_case=None)[source]#
Extract named gene lists from one or more DE result DataFrames for downstream enrichment.
This is the recommended way to prepare inputs for compare_enrichment when you have results from differential_expression() or the all_results from active_score().
Supports up / down / both, and can split directions into separate named sets (e.g. “GA_up”, “GA_down”) so you can enrich and visualize them distinctly (useful for upset plots and grouped dotplots).
- Parameters:
de_results (DataFrame or dict[str, DataFrame]) –
Single DataFrame: treated as one unnamed contrast (you can use name_prefix).
dict {contrast_name: de_df}: each df is processed and keys become the cluster names.
logfc_cutoff (float) – Minimum |logFC| (sign handled by direction).
pval_cutoff (float) – Max p_adj (or p_val if no p_adj column).
logfc_direction ({"up", "down", "both"})
separate_directions (bool) – If True and direction in {“both”, “up”, “down”} context, will emit separate entries “<name>_up” and “<name>_down”. Great for “up vs down” enrichment comparison.
name_prefix (str, optional) – Prepended to generated names when a single df is passed.
gene_case (optional) – Passed through to gene cleaning.
- Returns:
Ready to pass to compare_enrichment(gene_clusters=…).
- Return type:
Example
# Multiple contrasts de_dict = {“GA_vs_Ctrl”: ga_res, “GB_vs_Ctrl”: gb_res} gene_sets = scat.extract_gene_lists(
de_dict, logfc_cutoff=0.5, pval_cutoff=0.05, logfc_direction=”up”
) comp = scat.compare_enrichment(gene_sets, gene_sets=”GO_Biological_Process”, organism=”mouse”)
# Up and down as separate “clusters” for upset / grouped dotplot gene_sets = scat.extract_gene_lists(
de_dict, logfc_direction=”both”, separate_directions=True
)