Skip to content

API index

Everything scimappro exports, in one place. import scimappro as sp throughout.

import scimappro as sp

sp.pp — preprocessing

Function What it does
mcmicro_to_scimap Turn mcmicro-style quantification CSVs into an AnnData.
log1p Chunked, parallel log1p of the expression matrix into a layer.
rescale Rescale each marker to a 0–1 scale around its gate, fitting a GMM when no gate is given.
combat ComBat batch correction across images or any other batch column.
nGraph Build an igraph k-nearest-neighbour graph from the marker matrix.
dropFeatures Drop markers, cells, obs columns, or whole phenotype groups.
mergeAdataObs Merge obs from several objects covering the same cells.
scimapToCsv Export expression plus obs to a flat CSV.
toSpatialData Convert an AnnData into a scverse SpatialData store.

sp.tl — tools

Cell identity

Function What it does
phenotype Hierarchical, prior-knowledge cell typing from a gating workflow.
cluster kmeans / leiden / dbscan over expression, or over a neighbourhood matrix with mode="spatial".
umap UMAP embedding into obsm.
classify Label cells by simple positive/negative marker rules.
rename Collapse or relabel categories into a new obs column.
foldChange Fold change in cell-type abundance between groups, with p-values.

Spatial statistics

Function What it does
spatialDistance Average distance between every pair of cell types.
spatialCooccurrence Adjacency enrichment against a permutation null.
spatialProximityScore Proximity volume and density for a chosen pair of cell types.
spatialAggregate Find local aggregates of one cell type above a purity threshold.
spatialSimilarityLookup Score every cell by similarity to a reference ROI's neighbourhood.

Cellular neighbourhoods

Function What it does
neighCount Per-cell counts of neighbouring cell types (or markers).
neighExp Neighbourhood-weighted expression (spatial lag).
neighLDA Latent Dirichlet Allocation motifs over neighbourhood composition.
neighNMF Non-negative matrix factorisation motifs over neighbourhood composition.

sp.pl — plotting

Expression and composition

Function What it does
heatmap Mean marker expression per group, optionally clustered.
barplot Stacked or grouped composition bars, matplotlib or plotly.
pie Cell-type proportions as pie charts, faceted by group.
distPlot Per-marker intensity distributions with gate lines.
densityPlot2D Two-marker density, the biaxial gating view.
markerCorrelation Marker–marker correlation heatmap.
groupCorrelation Correlation of group composition across a condition.

Embeddings and clusters

Function What it does
clusterPlots UMAP, heatmap, and ranked markers for a set of clusters.
umap Scatter of a UMAP embedding coloured by anything.
foldChange Fold-change heatmap or parallel-coordinates plot.

Spatial

Function What it does
spatialScatterPlot Cells at their real coordinates, coloured by phenotype or marker.
voronoi Voronoi tessellation coloured by cell type.
spatialDistance Dispatcher for the two spatial-distance views.
spatialDistanceHeatmap Cell-type × cell-type distance heatmap.
spatialDistanceDistribution Distance distributions, faceted.
spatialCooccurrence Co-occurrence heatmap with non-significant pairs greyed out.
spatialInteractionNetwork Significant interactions as a node–edge network.
spatialProximityScore Proximity volume/density bars.

Images and ROIs

Function What it does
image_viewer Overlay cells on the raw OME-TIFF in napari. Needs the qt extra.
addRoiScatter Draw ROIs interactively on a scatter of cell positions.
addRoiImage Draw ROIs on the raw image.

sp.helpers

Function What it does
addROI_omero Attach ROIs exported from OMERO to the cell table. Needs the roi extra.

Parameters every function shares

Parameter Meaning
data First argument, always. AnnData, .h5ad path, SpatialData, or .zarr store.
outputDir Write the result here instead of returning it. None returns the object.
streamData Run out of core against an .h5ad path. See Streaming.
sdataTable Last named parameter, always. Which SpatialData table to use. See SpatialData.
maxWorkers Cap on parallel workers. Defaults to max(1, cpu_count() - 1).
verbose Progress messages.
label Key under which results are written to obs, uns, layers, or obsm.

Plotting functions instead share show, returnData, returnFig, dpi, transparent, fileName, and outputDir.

saveDir is deprecated

A few plotting functions (heatmap, pie, foldChange, voronoi, the correlation and spatial-result plots) still accept saveDir alongside outputDir for scripts carried over from scimap. outputDir wins when both are given. Use outputDir.