metachat.pl.plot_MSpair_contribute_group
- metachat.pl.plot_MSpair_contribute_group(adata, database_name=None, group_name=None, metabolite_name=None, summary='sender', cmap='green', group_cmap=None, figsize=(4, 6), ax=None, plot_savepath=None)[source]
Plot a heatmap showing group-level contributions of metabolite–sensor pairs for a specific metabolite.
This function visualizes how each cell group contributes to the overall communication strength of all metabolite–sensor pairs associated with a given metabolite. It is particularly useful for identifying dominant sender or receiver groups for specific metabolites.
Parameters
- adataanndata.AnnData
Annotated data matrix containing MetaChat results. Must include: -
adata.uns['df_metasen_filtered']: table linking metabolites (HMDB IDs) to sensors. -adata.obsm['MetaChat-<database_name>-sum-<summary>']: communication summary matrix.- database_namestr
Name of the metabolite–sensor interaction database used for MCC computation.
- group_namestr
Column name in
adata.obsspecifying the cell group or cluster identity.- metabolite_namestr
HMDB ID of the metabolite to visualize.
- summary{“sender”, “receiver”}, default=”sender”
Whether to visualize sender- or receiver-side contributions.
- cmap{“green”, “red”, “blue”}, default=”green”
Colormap for the heatmap. - “green”: metabolic enrichment style - “red”: activity intensity style - “blue”: signal pathway style
- group_cmapdict, optional
Mapping from group names to colors. If
None, derived automatically fromadata.uns[group_name + '_colors'].- figsizetuple of float, default=(4, 6)
Figure size (width, height).
- axmatplotlib.axes.Axes, optional
Existing Matplotlib axis to draw the heatmap on. If
None, a new figure is created.- plot_savepathstr, optional
File path to save the figure (e.g.,
"results/MSpair_contribution_heatmap.pdf"). The format is inferred from the file extension. IfNone, the plot is displayed interactively without saving.
Returns
- axmatplotlib.axes.Axes
Matplotlib axis containing the contribution heatmap.
Notes
- The function requires prior execution of:
mc.tl.metabolic_communication()mc.tl.summary_communication()mc.tl.communication_group()ormc.tl.communication_group_spatial()
Each column represents a metabolite–sensor pair, and each row represents a cell group.
Values are log-transformed group-level summed communication scores.