heatmap {apcluster} | R Documentation |
Plot Heatmap
Description
Functions for Plotting of Heatmap
Usage
## S4 method for signature 'ExClust,missing'
heatmap(x, y, ...)
## S4 method for signature 'ExClust,matrix'
heatmap(x, y, ...)
## S4 method for signature 'ExClust,Matrix'
heatmap(x, y, ...)
## S4 method for signature 'ExClust,sparseMatrix'
heatmap(x, y, ...)
## S4 method for signature 'AggExResult,missing'
heatmap(x, y, ...)
## S4 method for signature 'AggExResult,matrix'
heatmap(x, y, Rowv=TRUE, Colv=TRUE,
sideColors=NULL, col=heat.colors(12),
base=0.05, add.expr, margins=c(5, 5, 2),
cexRow=max(min(35 / nrow(y), 1), 0.1),
cexCol=max(min(35 / ncol(y), 1), 0.1), main=NULL, dendScale=1,
barScale=1, legend=c("none", "col"), ...)
## S4 method for signature 'matrix,missing'
heatmap(x, y, ...)
## S4 method for signature 'missing,matrix'
heatmap(x, y, ...)
Arguments
x |
a clustering result object of class
|
y |
a similarity matrix |
sideColors |
character vector of colors to be used for plotting color
bars that visualize clusters of the finest clustering level in
|
col |
color ramp used for the heatmap image; see
|
Rowv |
determines whether or not a row dendrogram should be
plotted. If |
Colv |
determines whether or not a column dendrogram should be
plotted. Fully analogous to |
base |
fraction of height used for the very first join in
dendrograms; see |
add.expr , margins , cexRow , cexCol , main |
largely analogous to the standard
|
dendScale |
factor scaling the width of vertical and height of
horizontal dendrograms; values have to be larger than 0 and no
larger than 2. The default is 1 which corresponds to the same size
as the dendrograms plot by the standard
|
barScale |
factor scaling the width of color bars; values have to
be larger than 0 and no larger than 4. The default is 1 which
corresponds to half the width of the color bars plot by the standard
|
legend |
if |
... |
see details below |
Details
The heatmap
functions provide plotting of heatmaps from several
different types of input object. The implementation is similar to 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
. In the latter case, color bars are plotted
to visualize the prior clustering result (see description of
argument sideColors
above).
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
.
All variants described above internally use heatmap
with signature
AggExResult,matrix
, so all arguments list above can be used for
all variants, as they are passed through using the ...
argument. All other arguments, analogously to the standard
heatmap
function, are passed on to the
standard function image
. This is
particularly useful for using alternative color schemes via the
col
argument.
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.
Value
see details above
Note
Similarity matrices can be supplied in dense or sparse format. Note, however, that sparse matrices are converted to full dense matrices before plotting heatmaps which may lead to memory and/or performance bottlenecks for larger data sets.
Author(s)
Ulrich Bodenhofer, Andreas Kothmeier, 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
APResult
,
AggExResult
, ExClust
,
apcluster
, apclusterL
,
aggExCluster
, cutree-methods
,
plot-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)
## 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)
## with alternate heatmap coloring, alternating color bars, and no dendrograms
heatmap(apres2, apres@sim, Rowv=NA, Colv=NA,
sideColors=c("darkgreen", "yellowgreen"), col=terrain.colors(12))
## 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)