mtopic.pl.feature_activity#
- mtopic.pl.feature_activity(mdata, x, features, cmap='gnuplot', marker='.', s=10, p_top=99, fontsize=10, figsize=None, transparent=False, save=None)#
Visualize the distribution of specified features in a MuData object.
This function plots the spatial or embedding-based distribution of specified features (e.g., genes or proteins) across a sample dataset. Each feature is visualized individually, highlighting regions with high or low activity levels. This allows users to identify spatial patterns or clusters of cells associated with specific features.
- Parameters:
mdata (muon.MuData) – A MuData object containing multimodal single-cell data, including spatial coordinates and expression matrices.
x (str) – The key in obsm of mdata representing the spatial coordinates or embeddings to use for plotting.
features (list) – A list of features (e.g., genes or proteins) to visualize.
cmap (str, optional) – The colormap to use for visualizing feature activity. Default is ‘gnuplot’.
marker (str, optional) – Marker style for scatter plots. Default is ‘.’.
s (int, optional) – Marker size in the scatter plots. Default is 10.
p_top (float, optional) – Percentile threshold to highlight top feature activity values. Points above this percentile are displayed prominently. Default is 99.
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, size is automatically determined based on the number of features. Default is None.
transparent (bool, optional) – If True, saves the figure with a transparent background. 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") # Specify features to visualize features = ['GeneA', 'GeneB', 'ProteinX'] # Plot spatial distribution of selected features mtopic.pl.feature_activity( mdata, x='coords', features=features, cmap='viridis', save='feature_activity.png' )