Partitions the tissue into spatial domains (regions of coherent marker
expression) by clustering cells on their spatially smoothed expression:
each cell's profile is averaged with its k nearest neighbours before
clustering, so neighbouring cells tend to share a domain.
Arguments
- object
A
SpatialCellData-classobject.- n_domains
Integer. Number of domains. Default
6.- k
Integer. Number of neighbours to smooth over. Default
20.- slot
Character.
"data"(default) or"counts".- markers
Character vector or
NULL. Markers to use;NULLuses all.- seed
Integer or
NULL. Random seed for k-means.
Details
Sample identifiers must be complete, nonblank vectors. Counts and k must be positive whole numbers, validated before smoothing or RNG use.
Examples
data(phenoscapR_example)
obj <- NormaliseData(phenoscapR_example, "zscore")
obj <- SpatialDomains(obj, n_domains = 4, k = 15, seed = 1)
table(obj$domain)
#>
#> D1 D2 D3 D4
#> 177 57 186 220