Learn R Programming

Cardinal (version 1.4.0)

spatialShrunkenCentroids-methods: Spatially-Aware Shrunken Centroid Clustering and Classification

Description

Performs spatially-aware nearest shrunken centroid clustering or classification on an imaging dataset. These methods use statistical regularization to shrink the t-statistics of the features toward 0 so that unimportant features are removed from the analysis. A Gaussian spatial kernel or an adaptive kernel based on bilateral filtering are used for spatial smoothing.

Usage

"spatialShrunkenCentroids"(x, y, r = 1, k = 2, s = 0, method = c("gaussian", "adaptive"), iter.max=10, ...)
"spatialShrunkenCentroids"(x, y, r = 1, s = 0, method = c("gaussian", "adaptive"), priors = table(y), ...)
"spatialShrunkenCentroids"(x, y, ...)
"predict"(object, newx, newy, ...)

Arguments

x
The imaging dataset to cluster.
y
A factor or character response.
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.
s
The sparsity thresholding parameter by which to shrink the t-statistics.
method
The method to use to calculate the spatial smoothing kernels for the embedding. The 'gaussian' method refers to spatially-aware (SA) weights, and 'adaptive' refers to spatially-aware structurally-adaptive (SASA) weights.
iter.max
The maximum number of clustering iterations.
priors
Prior probabilities on the classes for classification. Improper priors will be normalized automatically.
...
Ignored.
object
The result of a previous call to spatialShrunkenCentroids.
newx
An imaging dataset for which to calculate the predicted response from shrunken centroids.
newy
Optionally, a new response from which residuals should be calculated.

Value

An object of class SpatialShrunkenCentroids, which is a ResultSet, where each component of the resultData slot contains at least the following components:
classes:
A factor indicating the predicted class for each pixel in the dataset.
centers:
A matrix of shrunken class centers.
time:
The amount of time the algorithm took to run.
r:
The neighborhood spatial smoothing radius.
k:
The number of clusters.
s:
The sparsity parameter.
method:
The type of spatial kernel used.
scores:
A matrix of discriminant scores.
probabilities:
A matrix of class probabilities.
tstatistics:
A matrix of shrunken t-statistics of the features.
sd:
The pooled within-class standard deviations for each feature.
iter:
The number of iterations performed.

References

Tibshirani, R., Hastie, T., Narasimhan, B., & Chu, G. (2003). Class Prediction by Nearest Shrunken Centroids, with Applications to DNA Microarrays. Statistical Science, 18, 104-117.

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

See Also

spatialKMeans

Examples

Run this code
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 <- spatialShrunkenCentroids(sset, r=c(1,2), k=c(2,3), s=c(0,1), method="gaussian")

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

y <- factor(data[!is.na(data)], labels=c("black", "red"))

class1 <- spatialShrunkenCentroids(sset, y, r=c(1,2), s=c(0,1), method="gaussian")

class1 <- spatialShrunkenCentroids(sset, y, r=c(1,2), s=c(0,1), method="adaptive")

Run the code above in your browser using DataLab