insitupy.plotting.cell_abundance_along_axis#
- insitupy.plotting.cell_abundance_along_axis(adata, axis, groupby=None, xlim=(0, inf), savepath=None, figsize=(8, 6), save_only=False, dpi_save=300, multiple='stack', histplot_element='bars', kde=False, verbose=True)#
Plot cell abundance along a specified axis.
This function visualizes the distribution of cells along a continuous variable (e.g., pseudotime, spatial coordinate) using histograms or KDE plots. It supports grouping by a categorical variable and allows customization of the histogram style.
- Parameters:
adata (AnnData) – AnnData object containing single-cell data.
axis (Union[str, Tuple[str, str]]) – Key for the x-axis. Can be a column in
adata.obsor a tuple (obsm_key, obsm_col) for accessing values fromadata.obsm.groupby (Optional[str], optional) – Column in
adata.obsto group cells by. Defaults to None.xlim (Tuple, optional) – Range of x-axis values to include. Defaults to (0, np.inf).
savepath (Optional[os.PathLike], optional) – Path to save the figure. If None, the figure is not saved.
figsize (Tuple, optional) – Size of the figure in inches. Defaults to (8, 6).
save_only (bool, optional) – If True, saves the figure without displaying it. Defaults to False.
dpi_save (int, optional) – Resolution (DPI) for saving the figure. Defaults to 300.
multiple (Literal["layer", "dodge", "stack", "fill"], optional) – How to display multiple groups. Defaults to “stack”.
histplot_element (Literal["bars", "step", "poly"], optional) – Style of histogram elements. Defaults to “bars”.
kde (bool, optional) – If True, plots KDE instead of histogram. Defaults to False.
verbose (bool, optional) – If True, prints progress messages. Defaults to True.
- Returns:
Displays and/or saves the generated plot.
- Return type:
None