troutpy.pl.rank_factor_genes_loadings

troutpy.pl.rank_factor_genes_loadings#

troutpy.pl.rank_factor_genes_loadings(sdata, layer, n_genes=20, fontsize=15, ncols=4, sharey=True, show=True, save=None, ax=None, **kwargs)#

Plot top scoring genes for each factor from NMF/LDA.

Parameters:
  • sdata (SpatialData) – The SpatialData object containing the factorized data.

  • layer (str) – The layer name in sdata where the factorized results are stored.

  • n_genes (int (default: 20)) – Number of top genes to display per factor.

  • fontsize (int (default: 15)) – Font size for gene names.

  • ncols (int (default: 4)) – Number of panels per row.

  • sharey (bool (default: True)) – Whether to share the y-axis scale across subplots.

  • show (bool (default: True)) – Whether to show the plot.

  • save (Optional[str] (default: None)) – Path to save the figure. If None, the figure is not saved.

  • ax (Optional[Axes] (default: None)) – Existing axes to plot into. If None, a new figure and grid of axes are created.

  • kwargs – Additional keyword arguments (currently unused).

Return type:

list[Axes] | None

Returns:

If show=True, None. Otherwise, the list of matplotlib.axes.Axes used for plotting.