Computes, for each biological sample and each bandwidth sigma, a
Gaussian kernel density estimate of every cell type evaluated at each cell's
location. The resulting cells x cellTypes matrices are stored as
reducedDim(spe, "Niche<sigma>"), one per bandwidth, with a consistent
set of cell-type columns (cell types absent from a sample are set to 0).
Usage
buildNiches(spe, ...)
# S4 method for class 'ANY'
buildNiches(
spe,
sigma = c(10, 30, 50, 70),
cell_type = "cell_type",
sample_id = "sample_id",
edge = TRUE,
diggle = TRUE,
name = "Niche",
BPPARAM = BiocParallel::SerialParam(),
...
)Arguments
- spe
a SpatialExperiment with spatial coordinates, cell type labels, and sample identifiers.
- ...
ignored.
- sigma
a numeric vector of kernel bandwidths (in the units of
spatialCoords), defaultc(10, 30, 50, 70).- cell_type
a character, the colData column holding cell type labels.
- sample_id
a character, the colData column identifying samples.
- edge, diggle
logicals passed to
spatstat.explore::densityfunfor edge correction (default TRUE).- name
a character, the prefix for the stored reducedDims (default "Niche").
- BPPARAM
a BiocParallelParam for parallelising over samples.
Examples
data(toySpiDE)
spe <- toySpiDE
spe <- buildNiches(spe, sigma = c(10, 20))
SingleCellExperiment::reducedDimNames(spe)
#> [1] "Niche10" "Niche20"