Skip to contents

The SpatialCellData Object

S4 class representing a single-cell spatial biology experiment. Stores raw and normalised expression matrices, spatial coordinates, cell metadata, and spatial analysis results. Accessor methods let you interrogate and subset the object without touching slots directly.

SpatialCellData-class
The SpatialCellData Class
CreateSpatialObject()
Create a SpatialCellData Object from Existing Data
ReadSpatial()
Read Cell Segmentation Data into a SpatialCellData Object
NCells()
Get the Number of Cells
NMarkers()
Get the Number of Markers
Markers()
Get Marker Names
Coords()
Get Spatial Coordinates
Meta()
Get or Set Cell Metadata
GetData()
Get Expression Data
Idents()
Get Active Cell Identities
`$`(<SpatialCellData>)
Access Metadata Columns with $
dim(<SpatialCellData>)
Get Dimensions of a SpatialCellData Object
show(<SpatialCellData>)
Show a SpatialCellData Object
`[`(<SpatialCellData>)
Subset a SpatialCellData Object
`[[`(<SpatialCellData>)
Access Metadata Columns with [[

Data Import

Read cell segmentation CSV files from spatial imaging platforms and image analysis software. Three formats are auto-detected: QuPath Full Export, QuPath Minimal, and flat segmentation format.

read_spatial()
Read Single-Cell Spatial Biology Data

Quality Control & Preprocessing

Filter cells by area and intensity thresholds, normalise marker intensities, and inspect QC distributions before downstream analysis.

qc_filter()
Quality Control Filter
QCFilter()
Quality Control Filter (SpatialCellData)
normalise_markers()
Normalise Marker Intensities
NormaliseData()
Normalise Marker Intensities (SpatialCellData)
QCPlot()
QC Scatter Plot

Phenotyping

Assign discrete phenotype labels to cells based on marker intensity thresholds and summarise phenotype composition per sample.

phenotype_cells()
Phenotype Cells by Marker Thresholds
PhenotypeCells()
Phenotype Cells (SpatialCellData)
summarise_phenotypes()
Summarise Phenotype Proportions
PhenotypeSummary()
Phenotype Summary (SpatialCellData)

Spatial Analysis

Compute spatial statistics including nearest-neighbour distances, local cell density, pairwise interaction matrices, spatial clustering, Delaunay networks, neighbourhood enrichment, Ripley’s K, Moran’s I, quadrat analysis, pair correlation, cross-nearest-neighbour distances, and expression-based clustering.

nearest_neighbours()
Compute Nearest Neighbour Distances
FindNeighbours()
Find Nearest Neighbours (SpatialCellData)
cell_density()
Compute Cell Density
CellDensity()
Cell Density (SpatialCellData)
interaction_matrix()
Spatial Interaction Matrix
InteractionMatrix()
Interaction Matrix (SpatialCellData)
spatial_clusters()
Spatial Cell Clustering
SpatialClusters()
Spatial Clusters (SpatialCellData)
DelaunayNetwork()
Delaunay Triangulation Network
NeighbourhoodEnrichment()
Neighbourhood Enrichment Analysis
RipleysK()
Ripley's K Function
MoransI()
Moran's I Spatial Autocorrelation
QuadratAnalysis()
Quadrat Analysis
PairCorrelation()
Pair Correlation Function
CrossNNDistance()
Cross Nearest Neighbour Distance
ExpressionClusters()
Expression-Based Cell Clustering

Visualisation

Publication-ready ggplot2 visualisations for cell maps, marker intensities, phenotype composition, spatial networks, and interaction heatmaps. High-level S4 methods work directly on a SpatialCellData object; lower-level helpers accept data.tables.

CellMap()
Plot Cell Map
FeaturePlot()
Feature Plot in Tissue Space
DensityPlot()
Plot Cell Density
SpatialNetworkPlot()
Plot Spatial Network
InteractionPlot()
Plot Spatial Interaction Heatmap
MarkerHeatmap()
Plot Marker Heatmap
ViolinPlot()
Violin Plot of Marker Expression
BoxPlot()
Box Plot of Marker Expression
DotPlot()
Dot Plot of Marker Expression
CompositionPlot()
Stacked Bar Plot of Phenotype Composition
RidgePlot()
Ridge Plot of Marker Expression
HistogramPlot()
Histogram of Marker Expression
QCPlot()
QC Scatter Plot
plot_cell_map()
Plot Cell Map
plot_density()
Plot Density Map
plot_heatmap()
Plot Marker Heatmap
plot_interactions()
Plot Interaction Heatmap

Colour Palettes

Manage the global colour palette used by all plotting functions. Supports viridis options and custom gradients defined by 2-3 anchor colours.

SetPalette() GetPalette()
Set or Get the Default Colour Palette
PaletteContinuous()
Generate a Continuous Colour Palette Function
PaletteDiscrete()
Generate Discrete Colours
CustomGradient()
Create a Custom Gradient Palette from Anchor Colours