Skip to contents

This is a generic function which may be useful outside of this package. It produces a heatmap based on an expression matrix and accompanying experiment data in the form of a frame, using heatmaply::heatmaply().

Usage

interactive_heatmap(
  plotmatrix,
  displaymatrix,
  sample_annotation,
  cluster_rows = TRUE,
  cluster_cols = FALSE,
  scale = "row",
  row_labels,
  colors = viridisLite::viridis(100),
  cexCol = 0.9,
  cexRow = 0.9,
  display_numbers = FALSE,
  hide_colorbar = FALSE,
  grid_gap = 1,
  cor_method = "spearman",
  cluster_method = "ward.D2",
  plot_height = 600,
  ...
)

Arguments

plotmatrix

Expression/ other data matrix

displaymatrix

A matrix of values shown on hover, in addition to the (possibly scaled/ transformed) values in plotmatrix

sample_annotation

A data frame with sample metadata, used to draw column side colors and an accompanying legend

cluster_rows

Cluster rows?

cluster_cols

Cluster columns?

scale

'row', 'column' or none

row_labels

Vector labels to use for rows

colors

A vector of colors for the heatmap

cexCol

Character expansion factor passed to heatmaply()

cexRow

Character expansion factor passed to heatmaply()

display_numbers

Boolean, should the (possibly scaled/ transformed) values in plotmatrix be displayed on the heatmap cells?

hide_colorbar

Boolean, should the color scale legend be hidden?

grid_gap

Pixel gap drawn between cells, passed through to heatmaply(). The default of 1 reads fine for small heatmaps, but on a heatmap with hundreds of rows the gaps can visually dominate and obscure cross-column colour patterns; pass 0 for contiguous cells in that case.

cor_method

Correlation method passed to calculate_dendrogram when clustering rows and/or columns (default: 'spearman'). Match this to the method used by another clustering of the same data (e.g. a ComplexHeatmap::Heatmap() call's clustering_distance_columns) to reproduce its dendrogram topology here.

cluster_method

Clustering method passed to calculate_dendrogram (default: 'ward.D2'). Match this to another clustering's clustering_method_columns/-_rows for the same reason as cor_method.

plot_height

The total rendered height of the plot in pixels. Passed through to heatmaply() as its height argument, and also used to convert the fixed-pixel annotation row height into the fraction heatmaply() expects. When displayed inside a plotlyOutput(), the latter's own height argument should match this value so the container and the widget agree.

...

Additional arguments passed to heatmaply(). For example, heatmaply() reorders dendrogram leaves for visual clarity (seriate = "OLO") by default; pass seriate = "none" here to keep the plain hclust leaf order instead, matching ComplexHeatmap::Heatmap()'s default display.

Value

output A plotly htmlwidget as produced by heatmaply()

Examples

mat <- matrix(rnorm(24), nrow = 6, ncol = 4,
  dimnames = list(paste0("gene", 1:6), paste0("s", 1:4)))
sample_annotation <- data.frame(
  condition = rep(c("treated", "control"), each = 2),
  row.names = colnames(mat)
)
interactive_heatmap(mat, mat, sample_annotation, row_labels = rownames(mat))