metachat.pl.plot_communication_responseGenes
- metachat.pl.plot_communication_responseGenes(df_deg, df_yhat, show_gene_names=True, top_ngene_per_cluster=-1, colormap='magma', cluster_colormap='Plotly', color_range=None, font_scale=1, figsize=(10, 10), plot_savepath=None, return_genes=False)[source]
Plot the smoothed gene expression profiles of metabolic cell communication response genes.
This function visualizes the response genes inferred from metabolic cell communication analysis. Genes are grouped by response clusters and displayed as a heatmap, where columns correspond to genes and rows represent the order of received signals.
The function allows highlighting top-ranked genes per cluster based on the Wald statistic and sorting both genes and clusters according to their expression peak locations.
This function should be run after
mc.tl.communication_responseGenes()andmc.tl.communication_responseGenes_cluster().Parameters
- df_degpandas.DataFrame
DataFrame results of response gene analysis from
mc.tl.communication_responseGenes()andmc.tl.communication_responseGenes_cluster().- df_yhatpandas.DataFrame
DataFrame containing smoothed and normalized expression values of the same genes
- show_gene_namesbool, default=True
Whether to show gene names as x-axis tick labels in the heatmap.
- top_ngene_per_clusterint, default=-1
Number of top genes to display per cluster. If set to a non-negative value, only the top-ranked genes (by Wald statistic) within each cluster are plotted. If
-1, all genes are included.- colormapstr, default=’magma’
Colormap used for expression values (passed to seaborn/Matplotlib).
- cluster_colormapstr, default=’Plotly’
Qualitative colormap used to color gene clusters. Accepts predefined names such as
'Plotly','Light24','Dark24', or'Alphabet'.- color_rangetuple, optional
Tuple
(vmin, vmax)specifying the lower and upper limits for expression color scaling. Values outside this range are clipped. IfNone, full dynamic range is used.- font_scalefloat, default=1
Scaling factor for seaborn font sizes.
- figsizetuple of float, default=(10, 10)
Size of the output figure (width, height).
- plot_savepathstr, optional
File path to save the figure. If
None, the figure is not saved.- return_genesbool, default=False
Whether to return the list of genes displayed in the plot.
Returns
- selected_geneslist of str, optional
If
return_genes=True, returns a list of gene names in the order they appear in the heatmap. Otherwise, returnsNone.
Notes
Clusters are first sorted by the mean position of the peak expression (
np.argmaxof smoothed values).Within each cluster, genes are ranked by the Wald statistic, and optionally truncated to the top
Ngenes.The resulting heatmap displays genes grouped and color-coded by cluster assignment.
This function relies on
get_cmap_qualitative()to obtain qualitative color palettes.