View source: R/mplot3_heatmap.R
mplot3_heatmap | R Documentation |
mplot3
Heatmap (image
; modified heatmap
)Customized heatmap with optional colorbar
mplot3_heatmap(
x,
colorGrad.n = 101,
colorGrad.col = NULL,
lo = "#18A3AC",
lomid = NULL,
mid = NULL,
midhi = NULL,
hi = "#F48024",
space = "rgb",
theme = getOption("rt.theme", "white"),
colorbar = TRUE,
cb.n = 21,
cb.title = NULL,
cb.cex = NULL,
cb.title.cex = 1,
cb.mar = NULL,
Rowv = TRUE,
Colv = TRUE,
distfun = dist,
hclustfun = hclust,
reorderfun = function(d, w) reorder(d, w),
add.expr,
symm = FALSE,
revC = identical(Colv, "Rowv"),
scale = "none",
na.rm = TRUE,
margins = NULL,
group.columns = NULL,
group.legend = !is.null(group.columns),
column.palette = rtPalette,
group.rows = NULL,
row.palette = rtPalette,
ColSideColors,
RowSideColors,
cexRow = 0.2 + 1/log10(nr),
cexCol = 0.2 + 1/log10(nc),
labRow = NULL,
labCol = NULL,
labCol.las = NULL,
main = "",
main.adj = 0,
main.line = NA,
xlab = NULL,
ylab = NULL,
xlab.line = NULL,
ylab.line = NULL,
keep.dendro = FALSE,
trace = 0,
zlim = NULL,
autorange = TRUE,
autolabel = letters,
filename = NULL,
par.reset = TRUE,
pdf.width = 7,
pdf.height = 7,
...
)
x |
Input matrix |
colorGrad.n |
Integer: Number of distinct colors to generate using colorGrad. Default = 101 |
colorGrad.col |
Character: the |
lo |
Color for low end |
lomid |
Color for low-mid |
mid |
Color for middle of the range or "mean", which will result in colorOp(c(lo, hi), "mean"). If mid = NA, then only lo and hi are used to create the color gradient. |
midhi |
Color for middle-high |
hi |
Color for high end |
space |
Character: Which colorspace to use. Option: "rgb", or "Lab". Default = "rgb". Recommendation: If mid is "white" or "black" (default), use "rgb", otherwise "Lab" |
theme |
Character: Defaults to option "rt.theme", if set, otherwise "light" |
colorbar |
Logical: If TRUE, plot colorbar next to heatmap. Default = TRUE |
cb.n |
Integer: Number of steps in colorbar. Default = 21, which gives 10 above and 10 below midline. If midline is zero, this corresponds to 10 percent increments / decrements |
cb.title |
Character: Title for the colorbar. Default = NULL |
cb.cex |
Float: Character expansion ( |
cb.title.cex |
Float: |
cb.mar |
Float, vector, length 4: Margins for colorbar. (passed to colorGrad's |
Rowv |
Logical OR a dendrogram OR integer vector that determines index for reordering OR NA to suppress. Default = TRUE |
Colv |
See |
distfun |
Function: used to compute the distance/dissimilarity matrix between rows and columns.
Default = |
hclustfun |
Function: used to determined hierarchical clustering when |
reorderfun |
Function (d, w): function of dendrogram and weights that determines reordering of row and column
dendrograms. Default uses |
add.expr |
Expression: will be evaluated after the call to |
symm |
Logical: If TRUE, treat |
revC |
Logical: If TRUE, reverse column order for plotting. Default = TRUE, if Rowv and Colv are identical |
scale |
Character: "row", "column", or "none". Determines whether values are centered and scaled in either the row or column direction. Default = "none" |
na.rm |
Logical: If TRUE, NAs are removed. Default = TRUE |
margins |
Float, vector, length 2: bottom and right side margins. Automatically determined by length of variable names |
ColSideColors |
Color, vector, length = ncol(x): Colors for a horizontal side bar to annotate columns of |
RowSideColors |
Color, vector, length = nrow(x): Like |
cexRow |
Float: |
cexCol |
Float: |
labRow |
Character, vector: Row labels to use. Default = |
labCol |
Character, vector: Column labels to use. Default = |
labCol.las |
Integer 0:3: |
main |
Character: Plot title |
main.adj |
Float: |
main.line |
Float: |
xlab |
Character: x-axis label |
ylab |
Character: y-axis label |
xlab.line |
Float: |
ylab.line |
Float: |
keep.dendro |
Logical: If TRUE, dedrogram is returned invisibly. Default = FALSE |
trace |
Integer: If > 0, print diagnostic messages to console. Default = 0 |
zlim |
Float, vector, length 2: Passed to |
autorange |
Logical: See |
filename |
Character: If provided, save heatmap to file. Default = NULL |
par.reset |
Logical: If TRUE, reset |
pdf.width |
Float: Width of PDF output, if |
pdf.height |
Float: Height of PDF output, if |
... |
Additional arguments passed to |
The main difference from the original stats::heatmap
is the addition of a colorbar on the side.
This is achieved with colorGrad.
Other differences:
Dendrograms are not drawn by default. Set Rowv = T
and Colv = T
to get them.
Column labels are only drawn perpendicular to the x-axis if any one is
longer than two characters.
Otherwise, the arguments are the same as in stats::heatmap
E.D. Gennatas modified from original stats::heatmap
by Andy Liaw, R. Gentleman, M. Maechler, W. Huber
## Not run:
x <- rnormmat(200, 20)
xcor <- cor(x)
mplot3_heatmap(xcor)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.