API#

Importing InSituPy#

import insitupy as isp

Individual submodules can then be imported like this:

isp.dataclasses
isp.io
isp.plotting

Core Data Objects#

Individual datasets#

InSituData([path, metadata, slide_id, ...])

InSituData class for managing and analyzing spatially resolved transcriptomics data.

Read a saved InSituData object with:

InSituData.read(path)

Read an InSituData object from a specified folder.

Handle multiple datasets#

InSituExperiment()

A class to manage and analyze multiple spatially resolved single-cell transcriptomics experiments.

Read a saved InSituExperiment project with:

InSituExperiment.read(path)

Read an InSituExperiment object from a specified folder.

To generate a new InSituExperiment object, either from a configurations file or from histological regions, following functions are available:

InSituExperiment.from_config(config_path[, mode])

Create an InSituExperiment object from a configuration file.

InSituExperiment.from_regions(data, region_key)

Creates an InSituExperiment object from specified regions in the given InSituData.

To concatenate multiple InSituExperiment objects:

InSituExperiment.concat(objs[, new_col_name])

Concatenate multiple InSituExperiment objects.

Import data objects#

Import the data objects like this:

from insitupy import InSituData, InSituExperiment

Core Data Classes#

Data classes are used to store the different modalities.

Cellular data#

dataclasses.CellData(matrix, boundaries[, ...])

Data object containing an AnnData object and a boundary object which are kept in sync.

dataclasses.MultiCellData()

Data object containing multiple CellData objects.

dataclasses.BoundariesData(cell_names, ...)

Object to read and load boundaries of cells and nuclei.

Image data#

dataclasses.ImageData([img_files, ...])

Object to read and load images.

Geometric data#

dataclasses.ShapesData([files, keys, ...])

Object to store annotations.

dataclasses.AnnotationsData([files, keys, ...])

dataclasses.RegionsData([files, keys, ...])

The different data classes can be read using following functions:


Read external data#

Following functions allow reading data from external sources, e.g. from an Xenium In Situ experiment or from QuPath. To read an individual dataset on can use following functions:

io.read_qupath(path, pixel_size, ...[, ...])

Load and process QuPath-exported spatial data into an InSituData object.

io.read_xenium(path[, nuclei_type, ...])

Reads Xenium In Situ data from the specified directory.

To read multiple datasets exported from QuPath into an InSituExperiment object, following functions can be used:

io.read_qupath_project(path[, pixel_size, ...])

Load and process a full QuPath project directory into an InSituExperiment object.


Plotting#

Import the plotting submodule either as isp.plotting or isp.pl.

plotting.spatial(data, keys[, cells_layer, ...])

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

plotting.cellular_composition(data, ...[, ...])

Plots the composition of cell types for specified regions or annotations.

plotting.cell_abundance_along_axis(adata, axis)

Plot cell abundance along a specified axis.

plotting.cell_expression_along_axis(adata, ...)

Plot gene expression along a specified axis for selected cell types.

plotting.volcano(results[, ...])

Generate multi-panel volcano plots for differential expression results.

plotting.colorlegend([viewer, mapping, ...])

plotting.overview(data[, cells_layer, ...])

Plots an overview table with metadata and quality control metrics.