insitupy.plotting.cell_expression_along_axis#
- insitupy.plotting.cell_expression_along_axis(adata, axis, genes, cell_type_column, cell_type, xlim=(0, inf), min_expression=0, xlabel=None, fit_reg=False, kde=False, max_cols=4, savepath=None, save_only=False, dpi_save=300, fig_height=4, fig_marginal_ratio=0.15, scatter_size=1, wspace=0.15, hspace=0.25, font_scale_factor=1)#
Plot gene expression along a specified axis for selected cell types.
This function visualizes gene expression for one or more genes along a continuous axis (e.g., pseudotime, spatial coordinate) for a specified cell type or group of cell types. It generates a grid of subplots with scatter plots, optional LOESS regression fits, and marginal KDE plots for both the axis and gene expression distributions.
- Parameters:
adata – AnnData object containing single-cell data.
axis – Key in
adata.obsor a tuple (obsm key, column key) to use for the x-axis.cell_type_column (
str) – Column inadata.obswith cell type annotations.cell_type (
Union[str,List[str]]) – Cell type(s) to include in the plot.xlim (
Tuple[Union[int,float],Union[int,float]] (default:(0, inf))) – X-axis limits. Defaults to (0, np.inf).min_expression (
Union[int,float] (default:0)) – Minimum expression threshold. Defaults to 0.xlabel (
Optional[str] (default:None)) – Custom x-axis label. Defaults to axis name.fit_reg (
bool(default:False)) – Whether to overlay a LOESS regression line. Defaults to False.kde (
bool(default:False)) – Whether to overlay a 2D KDE plot. Defaults to False.max_cols (
bool(default:4)) – Maximum number of columns in the subplot grid. Defaults to 4.savepath (
Union[str,PathLike,Path] (default:None)) – Path to save the figure. Defaults to None.save_only (
bool(default:False)) – If True, saves the figure without displaying it. Defaults to False.dpi_save (
int(default:300)) – DPI for saved figure. Defaults to 300.fig_height (
Number(default:4)) – Height of each subplot row. Defaults to 4.fig_marginal_ratio (
Number(default:0.15)) – Ratio of marginal KDE height to main plot. Defaults to 0.15.scatter_size (
Number(default:1)) – Size of scatter plot points. Defaults to 1.wspace (
Number(default:0.15)) – Horizontal spacing between subplots. Defaults to 0.15.hspace (
Number(default:0.25)) – Vertical spacing between subplot rows. Defaults to 0.25.font_scale_factor (
Number(default:1)) – Scaling factor for font sizes. Defaults to 1.
- Returns:
Displays and/or saves the generated figure.
- Return type:
None