spatialKMeans-methods {Cardinal}R Documentation

Spatially-Aware K-Means Clustering

Description

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.

Usage

## S4 method for signature 'SImageSet'
spatialKMeans(x, r = 1, k = 2,
    method = c("gaussian", "adaptive"),
    weights = 1, iter.max = 100, nstart = 100,
    algorithm = c("Hartigan-Wong", "Lloyd", "Forgy",
        "MacQueen"),
    ncomp = 20, ...)

Arguments

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.

weights

An optional vector of feature weights to be applied to the features during the clustering.

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 kmeans for details.

ncomp

The number of fastmap components to calculate.

...

Ignored.

Value

An object of class SpatialKMeans, which is a ResultSet, where each component 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.

time:

The amount of time the algorithm took to run.

r:

The neighborhood spatial smoothing radius.

k:

The number of clusters.

method:

The method for calculating spatial distances.

weights:

The feature weights (defaults to 1s).

fastmap:

A list with components giving details of the Fastmap projection.

Author(s)

Kylie A. Bemis

References

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.

See Also

spatialShrunkenCentroids

Examples

set.seed(1)
data <- matrix(c(NA, NA, 1, 1, NA, NA, NA, NA, NA, NA, 1, 1, NA, NA, 
    NA, NA, NA, NA, NA, 0, 1, 1, NA, NA, NA, NA, NA, 1, 0, 0, 1, 
    1, NA, NA, NA, NA, NA, 0, 1, 1, 1, 1, NA, NA, NA, NA, 0, 1, 1, 
    1, 1, 1, NA, NA, NA, NA, 1, 1, 1, 1, 1, 1, 1, NA, NA, NA, 1, 
    1, NA, NA, NA, NA, NA, NA, 1, 1, NA, NA, NA, NA, NA), nrow=9, ncol=9)

sset <- generateImage(data, range=c(200, 300), step=1)

clust1 <- spatialKMeans(sset, r=c(1,2), k=c(2,3), method="gaussian")

clust2 <- spatialKMeans(sset, r=c(1,2), k=c(2,3), method="adaptive")

[Package Cardinal version 1.12.1 Index]