Learn R Programming

apcluster (version 1.3.0)

heatmap: Plot Heatmap

Description

Functions for Plotting of Heatmap

Usage

## S3 method for class 'APResult,missing':
heatmap(x, y, ...)
## S3 method for class 'APResult,matrix':
heatmap(x, y, ...)
## S3 method for class 'ExClust,missing':
heatmap(x, y, ...)
## S3 method for class 'ExClust,matrix':
heatmap(x, y, ...)
## S3 method for class 'AggExResult,missing':
heatmap(x, y, ...)
## S3 method for class 'AggExResult,matrix':
heatmap(x, y, ...)
## S3 method for class 'matrix,missing':
heatmap(x, y, ...)
## S3 method for class 'missing,matrix':
heatmap(x, y, ...)

Arguments

x
a clustering result object of class APResult, ExClust, or AggExResult; for compatibility, x may also be a s
y
a similarity matrix
...
all other arguments are passed to the plotting command heatmap.

Value

  • see details above

Details

The heatmap functions provide plotting of heatmaps from several different types of input object. The implementation uses the standard graphics function heatmap. Plotting heatmaps via the plot command as available in previous versions of this package is still available for backward compatibility.

If heatmap is called for objects of classes APResult or ExClust, a heatmap of the similarity matrix in slot sim of the parameter x is created with clusters grouped together and highlighted in different colors. The order of clusters is determined by running aggExCluster on the clustering result x. This variant of heatmap returns an invisible AggExResult object.

If heatmap is called for an AggExResult object that contains all levels of clustering, the heatmap is displayed with the corresponding clustering dendrogram. If the AggExResult object is the result of running aggExCluster on a prior clustering result, the same heatmap plot is produced as if heatmap had been called on this prior clustering result, however, returning the cluster hierarchy's dendrogram.

All variants described above only work if the input object x contains a slot sim with the similarity matrix (which is only the case if the preceding clustering method has been called with includeSim=TRUE). In case the slot sim of x does not contain the similarity matrix, the similarity matrix must be supplied as second argument y.

The two variants with one of the two arguments being a matrix and one being missing are just wrappers around the standard heatmap function with the aim to provide compatibility with this standard case.

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: http://dx.doi.org/10.1093/bioinformatics/btr406{10.1093/bioinformatics/btr406}.

Frey, B. J. and Dueck, D. (2007) Clustering by passing messages between data points. Science 315, 972-976. DOI: http://dx.doi.org/10.1126/science.1136800{10.1126/science.1136800}.

See Also

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

Examples

Run this code
## 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)

## run affinity propagation using negative squared Euclidean
apres <- apcluster(negDistMat(r=2), x, p=-0.1)

## plot heatmap clustering run
heatmap(apres)

## rerun affinity propagation
## reuse similarity matrix from previous run
apres2 <- apcluster(s=apres@sim, q=0.6)

## plot heatmap of second run
heatmap(apres2, apres@sim)

## perform agglomerative clustering of affinity propagation clusters
aggres1 <- aggExCluster(apres@sim, apres2)

## plot heatmap
heatmap(cutree(aggres1, 2), apres@sim)

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

## show heatmap along with dendrogram
heatmap(aggres2)

Run the code above in your browser using DataLab