scmagnify.plotting.rankplot

Contents

scmagnify.plotting.rankplot#

scmagnify.plotting.rankplot(data, modal='GRN', key='network_score', n_top=5, cmap='Reds', selected_genes=None, xlabel='Gene Rank', ylabel='Score', swap_df=False, figsize=None, dpi=150, nrows=None, ncols=3, wspace=0.5, hspace=0.5, sharex=False, sharey=False, context='notebook', default_context=None, theme='white', font_scale=1, show=None, save=None, **kwargs)#

Plot ranked features per group with label annotations.

Parameters:
  • data (AnnData | MuData | GRNMuData) – Single cell data object. Can be an anndata.AnnData, mudata.MuData, scmagnify.GRNMuData

  • modal (Literal['GRN', 'RNA', 'ATAC'] (default: 'GRN')) – Modality key (e.g., ‘RNA’, ‘ATAC’) when using multi-modal data. mudata.MuData or scmagnify.GRNMuData must be provided.

  • key (str (default: 'network_score')) – Key in .varm to retrieve the DataFrame.

  • n_top (int (default: 5)) – Number of top features to label if selected_genes is not provided.

  • cmap (str (default: 'Reds')) – Colormap name or object. See matplotlib.cm.

  • selected_genes (Optional[list[str]] (default: None)) – A list of specific genes to label on the plot.

  • xlabel (str | None (default: 'Gene Rank')) – Label for the x-axis.

  • ylabel (str | None (default: 'Score')) – Label for the y-axis.

  • swap_df (bool (default: False)) – If True, transpose the DataFrame before plotting.

  • figsize (Optional[tuple[float, float]] (default: None)) – Figure size in inches (width, height). See matplotlib.figure.Figure.

  • dpi (int | None (default: 150)) – Dots per inch (resolution) of the figure. See matplotlib.figure.Figure.

  • nrows (Optional[int] (default: None)) – Number of subplot rows. If None, it will be calculated automatically.

  • ncols (int (default: 3)) – Number of subplot columns. If None, it will be calculated automatically.

  • wspace (float | None (default: 0.5)) – Width space between subplots. See matplotlib.pyplot.subplots().

  • hspace (float | None (default: 0.5)) – Height space between subplots. See matplotlib.pyplot.subplots().

  • sharex (bool (default: False)) – If True, subplots will share the x-axis. See matplotlib.pyplot.subplots().

  • sharey (bool (default: False)) – If True, subplots will share the y-axis. See matplotlib.pyplot.subplots().

  • context (str | None (default: 'notebook')) – Seaborn context, e.g., ‘notebook’, ‘paper’. See seaborn.set_context().

  • default_context (Optional[dict] (default: None)) – If True, reset to default seaborn context before plotting.

  • theme (str | None (default: 'white')) – Theme name or rcParams overrides. See seaborn.set_theme().

  • font_scale (float (default: 1)) – Scale factor applied to fonts for the plot. See seaborn.set_context().

  • show (Optional[bool] (default: None)) – Whether to display the figure. If None, the figure will be shown by default.

  • save (Optional[str] (default: None)) – Whether to save the figure. If True, the figure is saved to a file using the writekey. If a str is provided, it is used as the filename, potentially overriding other settings. If None or False, the figure is not saved.

Returns:

Tuple[Figure, np.ndarray[Axes]] | None A tuple of Figure and Axes objects when show is False, otherwise None.