API

Import Squidpy as:

import squidpy as sq

Graph

gr.spatial_neighbors(adata[, spatial_key, ...])

Create a graph from spatial coordinates.

gr.spatial_neighbors_from_builder(data, ...)

Create a graph from spatial coordinates using an explicit builder instance.

gr.spatial_neighbors_knn(data, *[, ...])

Create a k-nearest-neighbor graph from spatial coordinates.

gr.spatial_neighbors_radius(data, *, radius)

Create a radius-based graph from spatial coordinates.

gr.spatial_neighbors_delaunay(data, *[, ...])

Create a Delaunay triangulation graph from spatial coordinates.

gr.spatial_neighbors_grid(data, *[, ...])

Create a grid-based graph from spatial coordinates.

gr.GraphMatrixT

Type variable.

gr.SpatialNeighborsResult(connectivities, ...)

Result of spatial_neighbors function.

gr.mask_graph(sdata, table_key, polygon_mask)

Mask the graph based on a polygon mask.

gr.nhood_enrichment(adata, cluster_key[, ...])

Compute neighborhood enrichment by permutation test.

gr.NhoodEnrichmentResult(zscore, counts)

Result of nhood_enrichment function.

gr.co_occurrence(adata, cluster_key[, ...])

Compute co-occurrence probability of clusters.

gr.centrality_scores(adata, cluster_key[, ...])

Compute centrality scores per cluster or cell type.

gr.interaction_matrix(adata, cluster_key[, ...])

Compute interaction matrix for clusters.

gr.ripley(adata, cluster_key[, mode, ...])

Calculate various Ripley's statistics for point processes.

gr.ligrec(adata, cluster_key[, ...])

Perform the permutation test as described in [Efremova et al., 2020].

gr.spatial_autocorr(adata[, ...])

Calculate Global Autocorrelation Statistic (Moran’s I or Geary's C).

gr.sepal(adata, max_neighs[, genes, n_iter, ...])

Identify spatially variable genes with Sepal.

gr.calculate_niche(data, flavor[, ...])

Calculate niches (spatial clusters) based on a user-defined method in 'flavor'.

Image

im.process(img[, layer, library_id, method, ...])

Process an image by applying a transformation.

im.segment(img[, layer, library_id, method, ...])

Segment an image.

im.calculate_image_features(adata, img[, ...])

Calculate image features for all observations in adata.

im.SegmentationModel(model)

Base class for all segmentation models.

Plotting

pl.spatial_scatter(adata[, shape, color, ...])

Plot spatial omics data with data overlayed on top.

pl.spatial_segment(adata[, color, groups, ...])

Plot spatial omics data with segmentation masks on top.

pl.nhood_enrichment(adata, cluster_key[, ...])

Plot neighborhood enrichment.

pl.centrality_scores(adata, cluster_key[, ...])

Plot centrality scores.

pl.interaction_matrix(adata, cluster_key[, ...])

Plot cluster interaction matrix.

pl.ligrec(adata[, cluster_key, ...])

Plot the result of a receptor-ligand permutation test.

pl.ripley(adata, cluster_key[, mode, ...])

Plot Ripley's statistics for each cluster.

pl.co_occurrence(adata, cluster_key[, ...])

Plot co-occurrence probability ratio for each cluster.

pl.extract(adata[, obsm_key, prefix])

Create a temporary anndata.AnnData object for plotting.

pl.var_by_distance(adata, var, anchor_key[, ...])

Plot a variable using a smooth regression line with increasing distance to an anchor point.

Reading

read.visium(path, *[, counts_file, ...])

Read 10x Genomics Visium formatted dataset.

read.vizgen(path, *, counts_file, meta_file)

Read Vizgen formatted dataset.

read.nanostring(path, *, counts_file, meta_file)

Read Nanostring formatted dataset.

Tools

tl.sliding_window(adata[, library_key, ...])

Divide a tissue slice into regulary shaped spatially contiguous regions (windows).

tl.var_by_distance(adata, groups[, ...])

Build a design matrix consisting of distance measurements to selected anchor point(s) for each observation.

Datasets

datasets.four_i([path])

Pre-processed subset 4i dataset from Gut et al.

datasets.imc([path])

Pre-processed subset IMC dataset from Jackson et al.

datasets.seqfish([path])

Pre-processed subset seqFISH dataset from Lohoff et al.

datasets.merfish([path])

Pre-processed MERFISH dataset from Moffitt et al.

datasets.mibitof([path])

Pre-processed MIBI-TOF dataset from Hartmann et al.

datasets.slideseqv2([path])

Pre-processed SlideseqV2 dataset from Stickles et al.

datasets.sc_mouse_cortex([path])

Pre-processed scRNA-seq mouse cortex.

datasets.visium(sample_id, *[, ...])

Download Visium datasets from 10x Genomics.

datasets.visium_hne_adata([path])

Pre-processed 10x Genomics Visium H&E dataset.

datasets.visium_hne_adata_crop([path])

Pre-processed subset 10x Genomics Visium H&E dataset.

datasets.visium_fluo_adata([path])

Pre-processed 10x Genomics Visium Fluorescent dataset.

datasets.visium_fluo_adata_crop([path])

Pre-processed subset 10x Genomics Visium Fluorescent dataset.

datasets.visium_hne_image([path])

H&E image from 10x Genomics Visium dataset.

datasets.visium_hne_image_crop([path])

Cropped H&E image from 10x Genomics Visium dataset.

datasets.visium_fluo_image_crop([path])

Cropped Fluorescent image from 10x Genomics Visium dataset.

Extensibility

See the extensibility guide for how to implement a custom graph builder.

gr.neighbors.GraphBuilder([transform, ...])

Base class for spatial graph construction strategies.

gr.neighbors.GraphBuilderCSR([transform, ...])

CSR-based graph construction strategy.

gr.neighbors.GraphMatrixT

Type variable.

gr.neighbors.GraphPostprocessor

gr.neighbors.DistanceIntervalPostprocessor(...)

gr.neighbors.PercentilePostprocessor(percentile)

gr.neighbors.TransformPostprocessor(transform)

gr.neighbors.KNNBuilder([n_neighs, ...])

Build a generic k-nearest-neighbor spatial graph.

gr.neighbors.RadiusBuilder(radius[, ...])

Build a generic radius-based spatial graph.

gr.neighbors.DelaunayBuilder([radius, ...])

Build a generic point-cloud graph from a Delaunay triangulation.

gr.neighbors.GridBuilder([n_neighs, ...])

Build a grid-based spatial graph.

Experimental

experimental.tl.calculate_tiling_qc(sdata, ...)

Score cells for tile-boundary segmentation artifacts.

experimental.tl.TilingQCParams([...])

Advanced tuning knobs for calculate_tiling_qc().

experimental.tl.assign_stitch_groups(sdata, ...)

Assign tile-cut cell pieces to stitch groups.

experimental.tl.StitchParams([distance_tol, ...])

Advanced tuning knobs for assign_stitch_groups().

experimental.pl.tiling_qc(sdata, labels_key)

Plot labels coloured by their tiling-artifact score.

experimental.im.fit_stain_reference(sdata, ...)

Fit a stain reference from an image in a SpatialData object.

experimental.im.apply_stain_normalization(...)

Normalize an image to a fitted stain reference.

experimental.im.StainReference(method[, ...])

Container for a fitted stain reference.

experimental.im.ReinhardParams([...])

Tuning knobs for Reinhard stain normalization.