troutpy.pl.nmf_gene_contributions

troutpy.pl.nmf_gene_contributions#

troutpy.pl.nmf_gene_contributions(sdata, nmf_adata_key='nmf_data', save=True, vmin=0.0, vmax=0.02, saving_path='', cmap='viridis', figsize=(5, 5))#

Plot a heatmap of NMF gene loadings, filtered to genes with a high maximum loading.

Extracts the NMF gene loadings matrix (H matrix) from the AnnData object stored at nmf_adata_key within sdata, keeps only genes whose maximum loading exceeds 0.05, and plots a heatmap of the filtered loadings sorted by their dominant factor.

Parameters:
  • sdata (SpatialData) – A spatial transcriptomics dataset that contains the NMF factors in the specified key.

  • nmf_adata_key (str (default: 'nmf_data')) – The key in sdata that contains the AnnData object with NMF results.

  • save (bool (default: True)) – Whether to save the heatmap plot to disk. The plot is saved in a figures subdirectory of saving_path.

  • vmin (float (default: 0.0)) – Minimum value for the colormap scale.

  • vmax (float (default: 0.02)) – Maximum value for the colormap scale.

  • saving_path (str (default: '')) – Path where the plot should be saved if save is True.

  • cmap (str (default: 'viridis')) – Colormap to use for the heatmap.

  • figsize (tuple[float, float] (default: (5, 5))) – Size of the heatmap figure.

Return type:

None

Returns:

None