mplot3_heatmap: 'mplot3' Heatmap ('image'; modified 'heatmap')

View source: R/mplot3_heatmap.R

mplot3_heatmapR Documentation

mplot3 Heatmap (image; modified heatmap)

Description

Customized heatmap with optional colorbar

Usage

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,
  ...
)

Arguments

x

Input matrix

colorGrad.n

Integer: Number of distinct colors to generate using colorGrad. Default = 101

colorGrad.col

Character: the colors argument of colorGrad: Character: Acts as a shortcut to defining lo, mid, etc for a number of defaults: "french", "penn", "grnblkred"

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 (cex) for colobar. Default = 1

cb.title.cex

Float: cex for colorbar title. Default = 1

cb.mar

Float, vector, length 4: Margins for colorbar. (passed to colorGrad's cb.add.mar). Default set automatically

Rowv

Logical OR a dendrogram OR integer vector that determines index for reordering OR NA to suppress. Default = TRUE

Colv

See Rowv

distfun

Function: used to compute the distance/dissimilarity matrix between rows and columns. Default = dist

hclustfun

Function: used to determined hierarchical clustering when Rowv or Colv are not dendrograms. Default = hclust (Should take as argument a result of distfun and return an object to which as.dendrogram can be applied)

reorderfun

Function (d, w): function of dendrogram and weights that determines reordering of row and column dendrograms. Default uses reorder.dendrogram

add.expr

Expression: will be evaluated after the call to image. Can be used to add components to the plot

symm

Logical: If TRUE, treat x symmetrically. Can only be used if x is square

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 x

RowSideColors

Color, vector, length = nrow(x): Like ColSideColors, but for rows

cexRow

Float: cex.axis for rows

cexCol

Float: cex.axis for columns

labRow

Character, vector: Row labels to use. Default = rownames(x)

labCol

Character, vector: Column labels to use. Default = colnames(x)

labCol.las

Integer 0:3: par's las argument. Default set by length of labCol

main

Character: Plot title

main.adj

Float: par's adj argument for title

main.line

Float: title's line argument

xlab

Character: x-axis label

ylab

Character: y-axis label

xlab.line

Float: mtext's line argument for x-axis label

ylab.line

Float: mtext's line argument for y-axis label

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 graphics::image. Default = +/- max(abs(x)) if autorange = TRUE, otherwise = range(x).

autorange

Logical: See zlim

filename

Character: If provided, save heatmap to file. Default = NULL

par.reset

Logical: If TRUE, reset par before exit. Default = TRUE

pdf.width

Float: Width of PDF output, if filename is set

pdf.height

Float: Height of PDF output, if filename is set

...

Additional arguments passed to graphics::image

Details

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

Author(s)

E.D. Gennatas modified from original stats::heatmap by Andy Liaw, R. Gentleman, M. Maechler, W. Huber

Examples

## Not run: 
x <- rnormmat(200, 20)
xcor <- cor(x)
mplot3_heatmap(xcor)

## End(Not run)

egenn/rtemis documentation built on May 4, 2024, 7:40 p.m.