Estimates local cell density by counting neighbours within a radius.
Arguments
- object
An
SpatialCellData-classobject.- radius
Numeric. Radius of the neighbourhood.
- target
Character or
NULL. Restrict to a specific phenotype.
Value
An SpatialCellData-class with density
added to meta_data.
Examples
counts <- matrix(rnorm(100), nrow = 50,
dimnames = list(NULL, c("CD3", "CD8")))
coords <- data.frame(x = runif(50, 0, 100), y = runif(50, 0, 100))
obj <- CreateSpatialObject(counts, coords)
obj <- CellDensity(obj, radius = 20)