insitupy.plotting.spatial

Contents

insitupy.plotting.spatial#

insitupy.plotting.spatial(data, keys, cells_layer=None, layer=None, region_tuple=None, annotations_key=None, image_key=None, filter_mode=None, filter_tuple=None, xlim=None, ylim=None, spot_size=10, alpha=1.0, max_cols=4, savepath=None, save_only=False, dpi_save=300, show=True, plot_config=None, layout_config=None, data_config=None, verbose=False)#

Plot spatial omics data with optional images, annotations, and regions.

This function generates spatial scatter plots of spatially-resolved omics data from one or multiple InSituData or InSituExperiment objects. It supports categorical and continuous features, overlays images and annotations, and provides flexible configuration for plotting, layout, and saving.

Parameters:
  • Main

    dataInSituData or InSituExperiment

    Input dataset or experiment.

    keysstr or list of str

    Feature key(s) to plot (e.g., gene names or annotations).

    cells_layerstr, optional

    Name of the cell layer to extract data from.

    layerstr, optional

    AnnData layer to extract values from.

    region_tupletuple of (str, str), optional

    Region identifier (dataset key, region name).

    annotations_keytuple or str, optional

    Key(s) for annotations to overlay.

    image_keystr, optional

    Key for associated images to overlay.

    filter_modestr, optional

    Mode used for filtering cells (e.g., “contains”, “greater than”).

    filter_tupletuple, optional

    Parameters for filtering (depends on filter_mode).

  • Plotting

    xlimtuple of float, optional

    X-axis limits.

    ylimtuple of float, optional

    Y-axis limits.

    spot_sizefloat, default=10

    Marker size for cells.

    alphafloat, default=1.0

    Transparency for plotted markers.

  • Layout

    max_colsint, optional, default=4

    Maximum number of subplot columns.

  • Save

    savepathstr, optional

    Path to save the figure (if None, figure is not saved).

    save_onlybool, default=False

    If True, save figure without displaying.

    dpi_saveint, default=300

    Resolution in DPI for saving the figure.

    showbool, default=True

    Whether to display the plot.

  • Configuration

    plot_configPlotConfig, optional

    Plot configuration object (overrides defaults if provided).

    layout_configLayoutConfig, optional

    Layout configuration object (overrides defaults if provided).

    data_configDataConfig, optional

    Data configuration object (overrides defaults if provided).

  • Miscellaneous

    verbosebool, default=False

    If True, print progress messages.

Returns:

Displays and/or saves the generated spatial plot(s).

Return type:

None

Raises:
  • ValueError – If filter parameters or layout arguments are invalid.

  • ValueError – If mixed categorical and continuous values are encountered for a key.

Examples

>>> import insitupy as isp
>>> isp.pl.spatial(data, keys="GeneA")
>>> isp.pl.spatial(exp, keys=["GeneA", "GeneB"], image_key="lowres", savepath="plots/")