| AggExResult-class {apcluster} | R Documentation |
Class "AggExResult"
Description
S4 class for storing results of exemplar-based agglomerative clustering
Objects
Objects of this class can be created by calling aggExCluster
for a given similarity matrix.
Slots
The following slots are defined for AggExResult objects:
l:number of samples in the data set
sel:subset of samples used for leveraged clustering (empty for normal clustering)
maxNoClusters:maximum number of clusters in the cluster hierarchy, i.e. it contains clusterings with 1 -
maxNoClustersclusters.exemplars:list of length
maxNoClusters; thei-th component of the list is a vector ofiexemplars (corresponding to the level withiclusters).clusters:list of length
maxNoClusters; thei-th component ofclustersis a list oficlusters, each of which is a vector of sample indices.merge:a
maxNoClusters-1by 2 matrix that contains the merging hierarchy; fully analogous to the slotmergein the classhclust.height:a vector of length
maxNoClusters-1that contains the merging objective of each merge; largely analogous to the slotheightin the classhclustexcept that the slotheightinAggExResultobjects is supposed to be non-increasing, sinceaggExClusteris based on similarities, whereashclustuses dissimilarities.order:a vector containing a permutation of indices that can be used for plotting proper dendrograms without crossing branches; fully analogous to the slot
orderin the classhclust.labels:a character vector containing labels of clustered objects used for plotting dendrograms.
sim:similarity matrix; only available if
aggExClusterwas called with similarity function andincludeSim=TRUE.call:method call used to produce this clustering result
Methods
- plot
signature(x="AggExResult"): seeplot-methods- plot
signature(x="AggExResult", y="matrix"): seeplot-methods- heatmap
signature(x="AggExResult"): seeheatmap-methods- heatmap
signature(x="AggExResult", y="matrix"): seeheatmap-methods- show
signature(object="AggExResult"): seeshow-methods- cutree
signature(object="AggExResult", k="ANY", h="ANY"): seecutree-methods- length
signature(x="AggExResult"): gives the number of clustering levels in the clustering result.- as.hclust
signature(x="AggExResult"): seecoerce-methods- as.dendrogram
signature(object="AggExResult"): seecoerce-methods
Accessors
In the following code snippets, x is an AggExResult object.
- [[
signature(x="AggExResult", i="index", j="missing"):x[[i]]returns an object of classExClustcorresponding to the clustering level withiclusters; synonymous tocutree(x, i).- [
signature(x="AggExResult", i="index", j="missing", drop="missing"):x[i]returns a list ofExClustobjects with all clustering levels specified in vectori. So, the list has as many components as the argumentihas elements. A list is returned even ifiis a single level.- similarity
signature(x="AggExResult"): gives the similarity matrix.
Author(s)
Ulrich Bodenhofer, Johannes Palme, and Johannes Palme
References
https://github.com/UBod/apcluster
Bodenhofer, U., Kothmeier, A., and Hochreiter, S. (2011) APCluster: an R package for affinity propagation clustering. Bioinformatics 27, 2463-2464. DOI: doi:10.1093/bioinformatics/btr406.
See Also
aggExCluster, show-methods,
plot-methods, cutree-methods
Examples
## create two Gaussian clouds
cl1 <- cbind(rnorm(50, 0.2, 0.05), rnorm(50, 0.8, 0.06))
cl2 <- cbind(rnorm(50, 0.7, 0.08), rnorm(50, 0.3, 0.05))
x <- rbind(cl1, cl2)
## compute similarity matrix (negative squared Euclidean)
sim <- negDistMat(x, r=2)
## compute agglomerative clustering from scratch
aggres1 <- aggExCluster(sim)
## show results
show(aggres1)
## plot dendrogram
plot(aggres1)
## plot heatmap along with dendrogram
heatmap(aggres1, sim)
## plot level with two clusters
plot(aggres1, x, k=2)
## run affinity propagation
apres <- apcluster(sim, q=0.7)
## create hierarchy of clusters determined by affinity propagation
aggres2 <- aggExCluster(sim, apres)
## show results
show(aggres2)
## plot dendrogram
plot(aggres2)
## plot heatmap
heatmap(aggres2, sim)
## plot level with two clusters
plot(aggres2, x, k=2)