coerce-methods {apcluster}R Documentation

Coercion of cluster hierarchies

Description

Functions for coercing clustering object to hclust and dendrogram objects

Usage

## S4 method for signature 'AggExResult'
as.hclust(x, base=0.05)
## S4 method for signature 'ExClust'
as.hclust(x, base=0.05, ...)
## S4 method for signature 'AggExResult'
as.dendrogram(object, base=0.05, useNames=TRUE)
## S4 method for signature 'ExClust'
as.dendrogram(object, base=0.05, useNames=TRUE, ...)

Arguments

x

a clustering result object of class APResult, ExClust, or AggExResult

object

a clustering result object of class APResult, ExClust, or AggExResult

base

fraction of height used for the very first join; defaults to 0.05, i.e. the first join appears at 5% of the total height of the dendrogram (see details below).

useNames

if TRUE (default), the labels of the dendrogram are the sample/cluster names (if available); otherwise, the labels are indices.

...

all other arguments are passed on to aggExCluster (see details below).

Details

If called for an AggExResult object, as.hclust creates an hclust object. The heights are transformed to the interval from base (height of lowest join) to 1 (height of highest join). If called for an ExClust or APResult object, aggExCluster is called internally to create a cluster hierarchy first. This is only possible if the pairwise similarities are included in the sim slot of x (see aggExCluster on how to ensure this).

If x is an AggExResult object obtained by clustering an entire data set, as.hclust produces a complete hierarchy. If, however, x is an ExClust (or APResult) object or an AggExResult obtained by running aggExCluster on an ExClust or APResult object, then as.hclust produces a hierarchy of clusters, not of samples.

If called for an AggExResult object, as.dendrogram creates an dendrogram object. Analogously to as.hclust, the heights are transformed to the interval ranging from base (height of lowest join) to 1 (height of highest join). So, any information about heights of merges is lost. If the original join heights are relevant, call plot on the original AggExResult object directly without coercing it to a dendrogram object first. If called for an ExClust or APResult object, aggExCluster is called first to create a cluster hierarchy. Again this is only possible if the pairwise similarities are included in the sim slot of object.

If object is an AggExResult object obtained by clustering an entire data set, as.dendrogram produces a complete dendrogram. If object is an ExClust (or APResult) object or an AggExResult obtained by previously running aggExCluster on an ExClust or APResult object, then as.dendrogram produces a complete dendrogram of all samples, too, but with the difference that entire clusters of the previous ExClust or APResult object are not further split up hierarchically. Consequently, if x is not a complete cluster hierarchy, but a hierarchy of clusters, as.dendrogram(as.hclust(x)) produces a dendrogram of clusters, whereas as.dendrogram(x) in any case produces a dendrogram of samples (with the special property mentioned above).

Value

see details above

Author(s)

Ulrich Bodenhofer, Andreas Kothmeier & Johannes Palme apcluster@bioinf.jku.at

References

http://www.bioinf.jku.at/software/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

APResult, AggExResult, ExClust, heatmap-methods, apcluster, apclusterL, aggExCluster, cutree-methods

Examples

## create two Gaussian clouds
cl1 <- cbind(rnorm(20, 0.2, 0.05), rnorm(20, 0.8, 0.06))
cl2 <- cbind(rnorm(20, 0.7, 0.08), rnorm(20, 0.3, 0.05))
x <- rbind(cl1, cl2)

## run affinity propagation
apres <- apcluster(negDistMat(r=2), x, q=0.7, details=TRUE)

## perform agglomerative clustering of affinity propagation clusters
aggres1 <- aggExCluster(x=apres)

## compute and plot dendrogram
dend1 <- as.dendrogram(aggres1)
dend1
plot(dend1)

## compute and show dendrogram computed from hclust object
dend2 <- as.dendrogram(as.hclust(aggres1))
dend2
plot(dend2)

## perform agglomerative clustering of whole data set
aggres2 <- aggExCluster(negDistMat(r=2), x)

## compute and plot dendrogram
dend3 <- as.dendrogram(aggres2)
dend3
plot(dend3)

[Package apcluster version 1.4.11 Index]