gapmap: Function to draw a gapped cluster heatmap

Description Usage Arguments Value Examples

View source: R/gapmap.R

Description

This function draws a gapped cluster heatmap using the ggplot2 package. The input for the function is the a matrix, two dendrograms, and parameters for gaps.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
gapmap(
  m,
  d_row,
  d_col,
  mode = c("quantitative", "threshold"),
  mapping = c("exponential", "linear"),
  ratio = 0.2,
  scale = 0.5,
  threshold = 0,
  row_threshold = NULL,
  col_threshold = NULL,
  rotate_label = TRUE,
  verbose = FALSE,
  left = "dendrogram",
  top = "dendrogram",
  right = "label",
  bottom = "label",
  col = c("#053061", "#2166AC", "#4393C3", "#92C5DE", "#D1E5F0", "#F7F7F7", "#FDDBC7",
    "#F4A582", "#D6604D", "#B2182B", "#67001F"),
  h_ratio = c(0.2, 0.7, 0.1),
  v_ratio = c(0.2, 0.7, 0.1),
  label_size = 5,
  show_legend = FALSE,
  ...
)

Arguments

m

matrix

d_row

a dendrogram class object for rows

d_col

a dendrogram class object for columns

mode

gap mode, either "threshold" or "quantitative"

mapping

in case of quantitative mode, either "linear" or "exponential" mapping

ratio

the percentage of width allocated for the sum of gaps.

scale

the sclae log base for the exponential mapping

threshold

the height at which the dendrogram is cut to infer clusters

row_threshold

the height at which the row dendrogram is cut

col_threshold

the height at which the column dendrogram is cut

rotate_label

a logical to rotate column labels or not

verbose

logical for whether in verbose mode or not

left

a character indicating "label" or "dendrogram" for composition

top

a character indicating "label" or "dendrogram" for composition

right

a character indicating "label" or "dendrogram" for composition

bottom

a character indicating "label" or "dendrogram" for composition

col

colors used for heatmap

h_ratio

a vector to set the horizontal ratio of the grid. It should add up to 1. top, center, bottom.

v_ratio

a vector to set the vertical ratio of the grid. It should add up to 1. left, center, right.

label_size

a numeric to set the label text size

show_legend

a logical to set whether to show a legend or not

...

ignored

Value

a ggplot object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
set.seed(1234)
#generate sample data
x <- rnorm(10, mean=rep(1:5, each=2), sd=0.4)
y <- rnorm(10, mean=rep(c(1,2), each=5), sd=0.4)
dataFrame <- data.frame(x=x, y=y, row.names=c(1:10))
#calculate distance matrix. default is Euclidean distance
distxy <- dist(dataFrame)
#perform hierarchical clustering. default is complete linkage.
hc <- hclust(distxy)
dend <- as.dendrogram(hc)
#make a cluster heatmap plot
gapmap(m = as.matrix(distxy), d_row= rev(dend), d_col=dend)

gapmap documentation built on April 19, 2021, 5:06 p.m.