mtopic.pl.zscores#
- mtopic.pl.zscores(mdata, mod, x, zscores='zscores', cmap=None, marker='.', s=10, fontsize=10, figsize=None, transparent=False, save=None)#
Visualize the spatial or embedding-based distribution of z-scores for topics in a specified modality.
This function generates scatter plots showing the distribution of z-scores for each topic in a specified modality of a MuData object. Z-scores are used to highlight spatial or embedding-based patterns of feature expression across samples, revealing significant variations relative to the global mean.
- Parameters:
mdata (muon.MuData) – A MuData object containing multimodal single-cell data with z-scores stored in the obsm attribute.
mod (str) – The modality to visualize z-scores for (e.g., ‘rna’, ‘protein’).
x (str) – The key in obsm of mdata representing the spatial coordinates or embeddings to use for plotting (e.g., ‘coords’, ‘umap’).
zscores (str, optional) – The key in obsm of the specified modality representing the z-scores to plot. Default is ‘zscores’.
cmap (matplotlib.colors.Colormap or None, optional) – The colormap to use for visualizing z-scores. If None, a custom colormap is applied. Default is None.
marker (str, optional) – Marker style for scatter plots. Default is ‘.’.
s (int, optional) – Marker size for scatter plots. Default is 10.
fontsize (int, optional) – Font size for plot titles and colorbar ticks. Default is 10.
figsize (tuple, optional) – Tuple specifying the figure size (width, height) in inches. If None, the size is automatically determined based on the number of topics. Default is None.
transparent (bool, optional) – Whether to make the figure background transparent. Useful for overlays in presentations. Default is False.
save (str, optional) – Path to save the figure. If None, the figure is displayed but not saved. Default is None.
- Returns:
None
- Example:
import mtopic # Load MuData object mdata = mtopic.read.h5mu("path/to/file.h5mu") # Visualize z-scores for topics in the 'rna' modality using spatial coordinates mtopic.pl.zscores( mdata, mod='rna', x='coords', zscores='zscores', cmap='coolwarm', marker='o', s=15 ) # Save the figure to a file mtopic.pl.zscores( mdata, mod='rna', x='umap', save='zscores_distribution.pdf' )