peach.pl.pattern_visualization#
Visualization functions for pattern analysis results.
Functions
|
Create dotplot for pattern analysis results. |
|
Create heatmap showing pattern expression across archetypes. |
|
Create summary barplot showing pattern counts across different analyses. |
- peach.pl.pattern_visualization.pattern_dotplot(pattern_df, pattern_type=None, top_n=20, min_effect_size=0.5, max_pvalue=0.05, figsize=(12, 8), title=None, save_path=None, **kwargs)[source]#
Create dotplot for pattern analysis results.
Visualizes the top features (pathways/genes) for each pattern, showing effect sizes and significance levels.
- Parameters:
pattern_df (pd.DataFrame) – Results from archetype_exclusive_patterns, specialization_patterns, or tradeoff_patterns functions.
pattern_type (str, optional) – Type of pattern for title generation (“exclusive”, “specialization”, “tradeoff”). If None, inferred from data.
top_n (int, default: 20) – Number of top features to show.
min_effect_size (float, default: 0.5) – Minimum absolute effect size to include.
max_pvalue (float, default: 0.05) – Maximum p-value to include.
figsize (tuple, default: (12, 8)) – Figure size.
title (str, optional) – Custom title. If None, auto-generated based on pattern_type.
save_path (str, optional) – Path to save the figure.
**kwargs – Additional arguments passed to create_dotplot_visualization.
- Returns:
Dotplot figure with: - X-axis: Pattern codes or archetype names - Y-axis: Feature names (genes/pathways) - Dot size: Effect size magnitude - Dot color: -log10(p-value) (significance)
Returns placeholder figure with message if input is empty or no features pass filters.
- Return type:
Examples
>>> exclusive = pc.tl.archetype_exclusive_patterns(adata) >>> fig = pc.pl.pattern_dotplot(exclusive, pattern_type="exclusive")
>>> tradeoffs = pc.tl.tradeoff_patterns(adata, tradeoffs="pairs") >>> fig = pc.pl.pattern_dotplot(tradeoffs, min_effect_size=1.0, top_n=30, title="Strong Tradeoff Patterns")
- peach.pl.pattern_visualization.pattern_summary_barplot(pattern_results, figsize=(14, 6), save_path=None)[source]#
Create summary barplot showing pattern counts across different analyses.
- Parameters:
- Returns:
The summary barplot figure
- Return type:
plt.Figure
Examples
>>> results = { ... "exclusive": pc.tl.archetype_exclusive_patterns(adata), ... "specialization": pc.tl.specialization_patterns(adata), ... "tradeoff_pairs": pc.tl.tradeoff_patterns(adata, tradeoffs="pairs"), ... } >>> fig = pc.pl.pattern_summary_barplot(results)
- peach.pl.pattern_visualization.pattern_heatmap(pattern_df, adata, top_n=30, cluster_patterns=True, cluster_features=True, figsize=(10, 12), cmap='RdBu_r', save_path=None, **kwargs)[source]#
Create heatmap showing pattern expression across archetypes.
- Parameters:
pattern_df (pd.DataFrame) – Pattern analysis results
adata (AnnData) – Annotated data object with archetype assignments and scores
top_n (int, default: 30) – Number of top features to show
cluster_patterns (bool, default: True) – Whether to cluster patterns (rows)
cluster_features (bool, default: True) – Whether to cluster features (columns)
figsize (tuple, default: (10, 12)) – Figure size
cmap (str, default: 'RdBu_r') – Colormap for the heatmap
save_path (str, optional) – Path to save the figure
**kwargs – Additional arguments passed to sns.heatmap
- Returns:
The heatmap figure
- Return type:
plt.Figure