mtopic.pl.signatures#
- mtopic.pl.signatures(mdata, mod, signatures='signatures', n_top=30, cmap='viridis', figsize=None, fontsize=8, transparent=False, save=None)#
Visualize the feature signatures for each topic in a specified modality of a MuData object.
This function generates bar plots displaying the top n_top features associated with each topic in a specified modality of a MuData object. Features are ranked by their score, providing insight into the key contributors for each topic. The plots are arranged in a grid layout for easy comparison.
- Parameters:
mdata (muon.MuData) – A MuData object containing multimodal single-cell data with feature-topic distributions stored in varm.
mod (str) – The modality to visualize topic signatures for (e.g., ‘rna’, ‘protein’).
signatures (str, optional) – Key in the varm attribute of the specified modality representing the feature-topic distributions to plot. Default is ‘signatures’.
n_top (int, optional) – Number of top features to display for each topic. Default is 30.
cmap (str, optional) – Colormap to use for visualizing feature importance. Default is ‘viridis’.
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 and the number of top features. Default is None.
fontsize (int, optional) – Font size for plot titles and labels. Default is 8.
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 the top 30 features for each topic in the 'rna' modality mtopic.pl.signatures( mdata, mod='rna', signatures='signatures', n_top=30, cmap='plasma', fontsize=10 ) # Save the figure to a file mtopic.pl.signatures( mdata, mod='rna', save='topic_signatures.pdf' )