heatmap.3(x, diss = inherits(x, "dist"), Rowv = TRUE, Colv = TRUE, dendrogram = c("both", "row", "column", "none"), dist.row, dist.col, dist.FUN = gdist, dist.FUN.MoreArgs = list(method = "euclidean"), hclust.row, hclust.col, hclust.FUN = hclust, hclust.FUN.MoreArgs = list(method = "ward"), scale = c("none", "row", "column"), na.rm = TRUE, cluster.by.row = FALSE, cluster.by.col = FALSE, kr = NA, kc = NA, row.clusters = NA, col.clusters = NA, revR = FALSE, revC = FALSE, add.expr, breaks, x.center, color.FUN = gplots::bluered, sepList = list(NULL, NULL), sep.color = c("gray45", "gray45"), sep.lty = 1, sep.lwd = 2, cellnote, cex.note = 1, notecol = "cyan", na.color = par("bg"), trace = c("none", "column", "row", "both"), tracecol = "cyan", hline, vline, linecol = tracecol, labRow = TRUE, labCol = TRUE, srtRow = NULL, srtCol = NULL, sideRow = 4, sideCol = 1, margin.for.labRow, margin.for.labCol, ColIndividualColors, RowIndividualColors, cexRow, cexCol, labRow.by.group = FALSE, labCol.by.group = FALSE, key = TRUE, key.title = "Color Key", key.xlab = "Value", key.ylab = "Count", keysize = 1.5, mapsize = 9, mapratio = 4/3, sidesize = 3, cex.key.main = 0.75, cex.key.xlab = 0.75, cex.key.ylab = 0.75, density.info = c("histogram", "density", "none"), denscol = tracecol, densadj = 0.25, main = "Heatmap", sub = "", xlab = "", ylab = "", cex.main = 2, cex.sub = 1.5, font.main = 2, font.sub = 3, adj.main = 0.5, mgp.main = c(1.5, 0.5, 0), mar.main = 3, mar.sub = 3, if.plot = TRUE, plot.row.partition = FALSE, plot.col.partition = FALSE, cex.partition = 1.25, color.partition.box = "gray45", color.partition.border = "#FFFFFF", plot.row.individuals = FALSE, plot.col.individuals = FALSE, plot.row.clusters = FALSE, plot.col.clusters = FALSE, plot.row.clustering = FALSE, plot.col.clustering = FALSE, plot.row.individuals.list = FALSE, plot.col.individuals.list = FALSE, plot.row.clusters.list = FALSE, plot.col.clusters.list = FALSE, plot.row.clustering.list = FALSE, plot.col.clustering.list = FALSE, row.data = FALSE, col.data = FALSE, if.plot.info = FALSE, text.box, cex.text = 1, ...)
dist
or dissimilarity
objects),
then x
is assumed to be a dissimilarity matrix. If FALSE,then x
is treated
as a matrix of observations by variables.x
is a dissimilarity matrixdist
object for row observations.dist
object for column observations.gdist
.gdist
hclust
object (as produced by hclust
) for row observations.hclust
object (as produced by hclust
) for column observations.hclust
.hclust
.
Defaults to list(method="ward")
"none"
.row.cluster
is specified.
DEFAULT: NULL.col.cluster
is specified.
DEFAULT: NULL.image
.
Can be used to add components to the plot.x
into colors, or a integer number of
break points to be used, in which case the break points will
be spaced equally between range(x)
. DEFAULT: 16 when not specified.x
for centering colors tolist
of length 2 giving the row and column lines of separation.cellnote
.cellnote
.NA
). Defaults to the plot background color."row"
s or down "column"
s, "both"
or "none"
.
The distance of the line from the center of each color-cell is proportional to the size of
the measurement. Defaults to "none"
.vline
default to the median of the breaks.hline
and vline
. Defaults to the value of 'tracecol'.rownames(x)
.colnames(x)
.help("par", package="graphics")
.help("par", package="graphics")
.labRow
.labCol
.ncol(x)
containing
the color names for a horizontal side bar that may be used to annotate the columns of x
.nrow(x)
containing
the color names for a vertical side bar that may be used to annotate the rows of x
.main
-title of color-key should be
magnified relative to the default.xlab
of color-key should be
magnified relative to the default.ylab
of color-key should be
magnified relative to the default.help("title", package="graphics")
.help("title", package="graphics")
.help("title", package="graphics")
.main
-title should be
magnified relative to the default.sub
-title should be
magnified relative to the default.main
-title.sub
-title.main
-title strings are justified.main
-title.c(bottom, left, top, right)
which gives the
number of lines of margin to be specified on the four sides of the main
-title.c(bottom, left, top, right)
which gives the
number of lines of margin to be specified on the four sides of the sub
-title.partition
should be
magnified relative to the default.partition
box.partition
border.plot.row.individuals
plot.col.individuals
plot.row.clusters
plot.col.clusters
plot.row.clustering
plot.col.clustering
plot.row.individuals
, plot.row.clusters
or plot.row.clustering
plot.col.individuals
, plot.col.clusters
or plot.col.clustering
text.box
.if.plot.info
is TRUE.text.box
should be
magnified relative to the default.heatmap.3
.
e help("image", package="graphics")
.dist
object
and hclust
object.
2) Highlight of specific cells using rectangles. For instance, the cells of clusters of interests.
(Examples should be included in future.)
3) Add-on plots in addition to the heatmap, such as cluster-wise summary plots and
overall clustering summary plots, to the right of or under the heatmap.
## ------------------------------------------------------------------------
## Example1: mtcars
## ------------------------------------------------------------------------
## load library
require("GMD")
## load data
data(mtcars)
## heatmap on raw data
x <- as.matrix(mtcars)
dev.new(width=10,height=8)
heatmap.3(x) # default, with reordering and dendrogram
## Not run:
# heatmap.3(x, Rowv=FALSE, Colv=FALSE) # no reordering and no dendrogram
# heatmap.3(x, dendrogram="none") # reordering without dendrogram
# heatmap.3(x, dendrogram="row") # row dendrogram with row (and col) reordering
# heatmap.3(x, dendrogram="row", Colv=FALSE) # row dendrogram with only row reordering
# heatmap.3(x, dendrogram="col") # col dendrogram
# heatmap.3(x, dendrogram="col", Rowv=FALSE) # col dendrogram with only col reordering
# heatmapOut <-
# heatmap.3(x, scale="column") # sacled by column
# names(heatmapOut) # view the list that is returned
# heatmap.3(x, scale="column", x.center=0) # colors centered around 0
# heatmap.3(x, scale="column",trace="column") # trun "trace" on
# ## End(Not run)
## coloring cars (row observations) by brand
brands <- sapply(rownames(x), function(e) strsplit(e," ")[[1]][1])
names(brands) <- c()
brands.index <- as.numeric(as.factor(brands))
RowIndividualColors <- rainbow(max(brands.index))[brands.index]
heatmap.3(x, scale="column", RowIndividualColors=RowIndividualColors)
## coloring attributes (column features) randomly (just for a test :)
heatmap.3(x, scale="column", ColIndividualColors=rainbow(ncol(x)))
## add a single plot for all row individuals
dev.new(width=12,height=8)
expr1 <- list(quote(plot(row.data[rowInd,"hp"],1:nrow(row.data),
xlab="hp",ylab="",yaxt="n",main="Gross horsepower")),
quote(axis(2,1:nrow(row.data),rownames(row.data)[rowInd],las=2)))
heatmap.3(x, scale="column", plot.row.individuals=TRUE, row.data=x,
plot.row.individuals.list=list(expr1))
## ------------------------------------------------------------------------
## Example2: ruspini
## ------------------------------------------------------------------------
## load library
require("GMD")
require(cluster)
## load data
data(ruspini)
## heatmap on a `dist' object
x <- gdist(ruspini)
main <- "Heatmap of Ruspini data"
dev.new(width=10,height=10)
heatmap.3(x, main=main, mapratio=1) # with a title and a map in square!
## Not run:
# heatmap.3(x, main=main, revC=TRUE) # reverse column for a symmetric look
# heatmap.3(x, main=main, kr=2, kc=2) # partition by predefined number of clusters
# ## End(Not run)
## show partition by elbow
css.multi.obj <- css.hclust(x,hclust(x))
elbow.obj <- elbow.batch(css.multi.obj,ev.thres=0.90,inc.thres=0.05)
heatmap.3(x, main=main, revC=TRUE, kr=elbow.obj$k, kc=elbow.obj$k)
## Not run:
# ## show elbow info as subtitle
# heatmap.3(x, main=main, sub=sub("\n"," ",attr(elbow.obj,"description")),
# cex.sub=1.25,revC=TRUE,kr=elbow.obj$k, kc=elbow.obj$k)
# ## End(Not run)
Run the code above in your browser using DataLab