scatrans.pl.enrich_dotplot#
- scatrans.pl.enrich_dotplot(enrich_df, top_n=15, show_terms=None, title='Enrichment Dotplot', save_path=None, figsize=(7, 8), dpi=300, fontsize=12, x='GeneRatio', color_by='Adjusted P-value', size_by='Count', cmap='viridis_r', dot_max=None, dot_min=None, smallest_dot=0.0, ax=None, show=True, use_style=False, cluster_col=None, facet_by_cluster=False, return_data=False)[source]#
Dotplot for enrichment results (clusterProfiler style).
- Common display choices (all columns from run_enrichment / run_kegg / run_gsea are available):
- x: what to plot on the x-axis. Supported / nice values:
“GeneRatio” (default for ORA), “FoldEnrichment”, “Count”, “-log10(p.adj)”, “NES” (auto default for GSEA). You can also pass any other numeric column present in the dataframe. Example: x=”NES” for GSEA results.
size_by: controls dot size (default “Count”). Common: “Count”, “GeneRatio”.
color_by: controls dot color (default “Adjusted P-value” or “p.adjust” for ORA; for GSEA results with “NES” it will default to “NES” with a diverging colormap). Smaller p-values are usually more interesting.
dot_max, dot_min, smallest_dot: omicverse-style controls for dot size range (see omicverse.pl.dotplot for the excellent reference implementation).
Legend handling (colorbar for p-value + size legend for Count/GeneRatio) uses constrained_layout + careful bbox_to_anchor upper-right placement for the size legend. This follows the patterns from gseapy (zqfang/gseapy plot.DotPlot) and omicverse.pl.dotplot to avoid the two legend elements overlapping on the right side of the figure.
- show_terms gives clusterProfiler-like flexibility:
int: show top N terms (overrides top_n)
“auto”: intelligently select terms with p.adjust < 0.05 and Count >= 2 (then top_n of those, sorted by significance + size). Falls back gracefully.
list/tuple of str: show exactly the matching terms (match on Term or Description; order of the list is respected when possible). This is analogous to dotplot(…, showCategory = c(“term1”, “term2”)).
- Multi-group / compare support (new):
If the input df contains a “Cluster” column (or you pass cluster_col=”Cluster”), terms are automatically prefixed with “[Cluster] “ so groups are visually distinct.
show_terms=”auto” (and int) now collects top terms intelligently across clusters when a Cluster column is present (union of interesting terms per cluster).
facet_by_cluster=True will produce a grid of subplots (one per cluster) using the same rich dotplot logic. Excellent for publication multi-panel figures.
The returned df from scat.compare_enrichment(…) or concat_compare_results(…) works directly.
top_n is still supported for the common “top N” case (when show_terms is None). Supports ax for embedding in publication multi-panel figures.