vignettes/SpatialCellExperiment.Rmd
SpatialCellExperiment.RmdLoad the package.
Generate some toy data representing a spatial single-cell RNA-sequencing experiment for 100 cells associated with 3D coordinates:
ncells <- 100
u <- matrix(rpois(20000, 5), ncol=ncells)
v <- log2(u + 1)
coordinates <- matrix(runif(ncells*3), ncells)
colnames(coordinates) <- c("x", "y", "z")Create a SpatialCellExperiment.
Visualize the SpatialCellExperiment.
In the SpatialCellExperiment class, each cell is represented by a point coordinates. This is clearly an over-simplification that does not reflect the geometry of individual cells in a tissue sample. However, this lightweight representation allows rapid calculation of the distance between cells.
The CRAN package sf provides support for simple features, a standardized way to encode spatial vector data. This could be used to implement a SpatialPolygonExperiment class, holding the precise geometry of cells, along with the usual metadata for genes and libraries.
An intermediate modelling approach could be to summarize observations by tile, i.e., regular areas dividing the observed space evenly. Each tile would then summarize the features detected in the correspondig area. Note that tiles could be rectangles, hexagons, or any polygon that can divide a plane into a regular mesh. This could be implemented as a SpatialTileExperiment. Distinct polygons might require specialized sub-classes.