consensusmatrix: Consensus matrix from A matrix of bootstrap replicates

Description Usage Arguments Details Value Author(s) References Examples

View source: R/consensusmatrix.R

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

1
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 \:\emph{i} \:and \:\emph{j} \:in \:the \:same \:cluster}{\#n \:of \:objects \:\emph{i} \:and \:\emph{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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
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)]

kmed documentation built on Jan. 8, 2021, 2:40 a.m.