peach.pl.results

Contents

peach.pl.results#

Results visualization functions.

This module provides specialized plotting functions for statistical analysis results from archetypal analysis. Creates publication-ready visualizations with proper aesthetic formatting and interactive features.

Main Functions: - dotplot(): Publication-ready dotplots for statistical test results

Features: - Automatic detection of result types (genes, pathways, patterns) - Smart column detection and fallback handling - Publication-quality formatting and spacing - Interactive hover information and zooming - Support for effect sizes and significance levels

Functions

dotplot(results_df,Β *[,Β x_col,Β y_col,Β ...])

Create dotplot visualization for statistical results.

peach.pl.results.dotplot(results_df, *, x_col='archetype', y_col='gene', size_col='mean_archetype', color_col='pvalue', top_n_per_group=10, filter_zero_p=True, log_transform_p=True, max_log_p=300.0, title='Gene-Archetype Associations', figsize=(12, 8), color_palette='plasma', save_path=None, **kwargs)[source]#

Create dotplot visualization for statistical results.

Creates publication-ready dotplot showing statistical test results with effect sizes encoded as dot size and significance as color.

Parameters:
  • results_df (pd.DataFrame) – Statistical test results from pc.tl.gene_associations(), pc.tl.pathway_associations(), or pc.tl.pattern_analysis().

  • x_col (str, default: "archetype") – Column for x-axis (groups).

  • y_col (str, default: "gene") – Column for y-axis (features).

  • size_col (str, default: "mean_archetype") – Column for dot size (effect magnitude).

  • color_col (str, default: "pvalue") – Column for dot color (significance).

  • top_n_per_group (int, default: 10) – Number of top results per group.

  • filter_zero_p (bool, default: True) – Whether to filter out p-values of exactly 0.

  • log_transform_p (bool, default: True) – Whether to apply -log10 transformation to p-values.

  • max_log_p (float, default: 300.0) – Maximum -log10(p-value) cap.

  • title (str, default: "Gene-Archetype Associations") – Plot title.

  • figsize (tuple[float, float], default: (12, 8)) – Figure size as (width, height).

  • color_palette (str, default: "plasma") – Matplotlib colormap name.

  • save_path (str | None, default: None) – Path to save the figure.

  • **kwargs – Additional arguments passed to create_dotplot_visualization.

Returns:

Dotplot figure with: - X-axis: Groups (archetypes/patterns) - Y-axis: Features (genes/pathways), sorted by effect size - Dot size: Effect magnitude (with legend) - Dot color: -log10(p-value) (with colorbar) - Background panels grouping features by archetype

Return type:

matplotlib.figure.Figure

Notes

Auto-detects result type and adjusts columns: - Gene results: Uses defaults - Pathway results: Switches y_col to β€˜pathway’ - Pattern results: Uses pattern_name, effect_range - Exclusivity results: Uses tradeoff_score, effect_range

Examples

>>> gene_results = pc.tl.gene_associations(adata)
>>> fig = pc.pl.dotplot(gene_results)
>>> plt.show()
>>> # Pathway results (auto-detected)
>>> pathway_results = pc.tl.pathway_associations(adata)
>>> fig = pc.pl.dotplot(pathway_results, title="Pathway Associations")