consensusmatrix {kmed} | R Documentation |
Consensus matrix from A matrix of bootstrap replicates
Description
This function creates a consensus matrix from a matrix of bootstrap replicates. It transforms an n x b matrix into an n x n matrix, where n is the number of objects and b is the number of bootstrap replicates.
Usage
consensusmatrix(bootdata, nclust, reorder = fastclust)
Arguments
bootdata |
A matrix of bootstrap replicate (n x b) (see Details). |
nclust |
A number of clusters. |
reorder |
Any distance-based clustering algorithm function (see Details). |
Details
This is a function to obtain a consensus matrix from a matrix of
bootstrap replicates to evaluate the clustering result. The
bootdata
argument can be supplied directly from a matrix produced
by the clustboot
function. The values of the consensus matrix,
A, are calculated by
a_{ij} = a_{ji} = \frac{\#n \:of \:objects \:i \:and \:j
\:in \:the \:same \:cluster}{\#n \:of \:objects \:i \:and \:j
\:sampled \:at \:the \:same \:time}
where a_{ij}
is the agreement index between objects i and
j. Note that due to the agreement between objects i and
j equal to the agreement between objects j and i,
the consensus matrix is a symmetric matrix.
Meanwhile, the reorder
argument is a function to reorder the objects
in both the row and column of the consensus matrix such that similar objects
are close to each other. This task can be solved by applying a clustering
algorithm in the consensus matrix. The reorder
has to consist of
two input arguments. The two input arguments are a
distance matrix/ object and number of clusters.
The output is only a vector of cluster memberships. Thus,
the algorihtm that can be applied in the reorder
argument is the
distance-based algorithm with a distance as the input.
The default reorder
is fastclust
applying the
fastkmed
function. The code of the fastclust
is
fastclust <- function(x, nclust) {
res <- fastkmed(x, nclust, iterate = 50)
return(res$cluster)
}
For other examples, see Examples. It applies centroid and complete linkage algorithms.
Value
Function returns a consensus/ agreement matrix of n x n dimension.
Author(s)
Weksi Budiaji
Contact: budiaji@untirta.ac.id
References
Monti, S., P. Tamayo, J. Mesirov, and T. Golub. 2003. Consensus clustering: A resampling-based method for class discovery and visualization of gene expression microarray data. Machine Learning 52 pp. 91-118.
Examples
num <- as.matrix(iris[,1:4])
mrwdist <- distNumeric(num, num, method = "mrw")
irisfast <- clustboot(mrwdist, nclust=3, nboot=7)
consensusfast <- consensusmatrix(irisfast, nclust = 3)
centroid <- function(x, nclust) {
res <- hclust(as.dist(x), method = "centroid")
member <- cutree(res, nclust)
return(member)
}
consensuscentroid <- consensusmatrix(irisfast, nclust = 3, reorder = centroid)
complete <- function(x, nclust) {
res <- hclust(as.dist(x), method = "complete")
member <- cutree(res, nclust)
return(member)
}
consensuscomplete <- consensusmatrix(irisfast, nclust = 3, reorder = complete)
consensusfast[c(1:5,51:55,101:105),c(1:5,51:55,101:105)]
consensuscentroid[c(1:5,51:55,101:105),c(1:5,51:55,101:105)]
consensuscomplete[c(1:5,51:55,101:105),c(1:5,51:55,101:105)]