spatialKMeans-methods {Cardinal} | R Documentation |
Performs spatially-aware (SA) or spatially-aware structurally-adaptive (SASA) clustering of imaging data. The data are first projected into an embedded feature space where spatial structure is maintained using the Fastmap algorithm, and then ordinary k-means clustering is performed on the projected dataset.
## S4 method for signature 'SparseImagingExperiment' spatialKMeans(x, r = 1, k = 3, method = c("gaussian", "adaptive"), dist = "chebyshev", tol.dist = 1e-9, iter.max = 10, nstart = 1, algorithm = c("Hartigan-Wong", "Lloyd", "Forgy", "MacQueen"), ncomp = 10, BPPARAM = bpparam(), ...) ## S4 method for signature 'SpatialKMeans2' summary(object, ...) ## S4 method for signature 'SImageSet' spatialKMeans(x, r = 1, k = 3, method = c("gaussian", "adaptive"), iter.max = 10, nstart = 1, algorithm = c("Hartigan-Wong", "Lloyd", "Forgy", "MacQueen"), ncomp = 10, ...)
x |
The imaging dataset to cluster. |
r |
The spatial neighborhood radius of nearby pixels to consider. This can be a vector of multiple radii values. |
k |
The number of clusters. This can be a vector to try different numbers of clusters. |
method |
The method to use to calculate the spatial smoothing kernels for the embedding. The 'gaussian' method refers to spatially-aware (SA) clustering, and 'adaptive' refers to spatially-aware structurally-adaptive (SASA) clustering. |
dist |
The type of distance metric to use when calculating neighboring pixels based on |
tol.dist |
The distance tolerance used for matching pixels when calculating pairwise distances between neighborhoods. This parameter should only matter when the data is not gridded. (Only considers ‘radial’ distance.) |
iter.max |
The maximum number of k-means iterations. |
nstart |
The number of restarts for the k-means algorithm. |
algorithm |
The k-means algorithm to use. See |
ncomp |
The number of fastmap components to calculate. |
... |
Ignored. |
object |
A fitted model object to summarize. |
BPPARAM |
An optional instance of |
An object of class SpatialKMeans2
, which is a ResultImagingExperiment
, or an object of class SpatialKMeans
, which is a ResultSet
. Each element of the resultData
slot contains at least the following components:
cluster
:A vector of integers indicating the cluster for each pixel in the dataset.
centers
:A matrix of cluster centers.
correlation
:A matrix with the feature correlations with each cluster.
Kylie A. Bemis
Alexandrov, T., & Kobarg, J. H. (2011). Efficient spatial segmentation of large imaging mass spectrometry datasets with spatially aware clustering. Bioinformatics, 27(13), i230-i238. doi:10.1093/bioinformatics/btr246
Faloutsos, C., & Lin, D. (1995). FastMap: A Fast Algorithm for Indexing, Data-Mining and Visualization of Traditional and Multimedia Datasets. Presented at the Proceedings of the 1995 ACM SIGMOD international conference on Management of data.
register(SerialParam()) set.seed(1) x <- simulateImage(preset=3, dim=c(10,10), npeaks=10, peakheight=c(4,6,8), representation="centroid") res <- spatialKMeans(x, r=1, k=4, method="adaptive") summary(res) image(res, model=1)