Learn R Programming

fake (version 1.4.0)

Heatmap: Heatmap visualisation

Description

Produces a heatmap for visualisation of matrix entries.

Usage

Heatmap(
  mat,
  col = c("ivory", "navajowhite", "tomato", "darkred"),
  resolution = 10000,
  bty = "o",
  axes = TRUE,
  cex.axis = 1,
  xlas = 2,
  ylas = 2,
  text = FALSE,
  cex = 1,
  legend = TRUE,
  legend_length = NULL,
  legend_range = NULL,
  cex.legend = 1,
  ...
)

Value

A heatmap.

Arguments

mat

data matrix.

col

vector of colours.

resolution

number of different colours to use.

bty

character string indicating if the box around the plot should be drawn. Possible values include: "o" (default, the box is drawn), or "n" (no box).

axes

logical indicating if the row and column names of mat should be displayed.

cex.axis

font size for axes.

xlas

orientation of labels on the x-axis, as las in par.

ylas

orientation of labels on the y-axis, as las in par.

text

logical indicating if numbers should be displayed.

cex

font size for numbers. Only used if text=TRUE.

legend

logical indicating if the colour bar should be included.

legend_length

length of the colour bar.

legend_range

range of the colour bar.

cex.legend

font size for legend.

...

additional arguments passed to formatC for number formatting. Only used if text=TRUE.

Examples

Run this code
oldpar <- par(no.readonly = TRUE)
par(mar = c(3, 3, 1, 5))

# Data simulation
set.seed(1)
mat <- matrix(rnorm(100), ncol = 10)
rownames(mat) <- paste0("r", 1:nrow(mat))
colnames(mat) <- paste0("c", 1:ncol(mat))

# Generating heatmaps
Heatmap(mat = mat)
Heatmap(mat = mat, text = TRUE, format = "f", digits = 2)
Heatmap(
  mat = mat,
  col = c("lightgrey", "blue", "black"),
  legend = FALSE
)

par(oldpar)

Run the code above in your browser using DataLab