
Cluster neighborhoods
neighborhoodClusters.Rd
Assuming that cellNeighborhoods has been run, clusters the neighborhoods
Usage
neighborhoodClusters(
object,
nn,
feature,
cluster = "km",
k = NULL,
col.name = NULL,
quietly = F
)
Arguments
- object
A SpatialMap object
- nn
A NN graph name
- feature
The name of the cellMetadata feature (e.g. cell type) used for defining neighborhoods.
- cluster
How to cluster the cells' local neighbor composition vectors to create neighborhoods. Currently only k-means is supported (
"km"
).- k
How many clusters to produce using k-means on the neighborhood counts matrix. If NULL (default), then the function will optimize k using the silhouette score. Will also plot the silhouette scores for each tested value of k as a side effect.
- col.name
The desired name of the metadata column for neighborhood clusters. Defaults to something descriptive
- quietly
If true, will not print output messages
Value
A SpatialMap
object with new cell neighborhood memberships added to the cellMetadata
slot as a factor.
The new column in cellMetadata
will be named according to the value passed to col.name
, or will be named by
concatenating "nh_{nn}_{feature}"
.
Details
See vignette("AnalysisGuide6_Neighborhoods")
for a representative workflow that uses this function.