Skip to content
Joe Cheng edited this page Aug 13, 2015 · 2 revisions

The current d3heatmap() function slavishly almost-duplicates the API gplots::heatmap.2, to make it a convenient drop-in replacement and also because I didn't feel confident at the time that I could create a sensible API (because I didn't understand what a lot of the parameters meant).

Now that we are further along and are ready to add features that are not in heatmap.2 I think it's time to see about creating a new, modern API. This will be complementary to the existing d3heatmap() function.

# Create heatmap, set global/basic options
hm_heatmap(matrix, colors, width, height,
  scale = c("none", "row", "column"), na.rm = TRUE,
  symmetric, reverse_columns)

# Customize the formatting of the cells
hm_colormap(x, colors, cell_labels = NULL, show_scaled = FALSE,
  show_gridlines = TRUE)

# Add row/col dendrograms
hm_col_dendr(x, dendrogram, dist_fun = dist, hclust_fun = hclust,
  reorder_fun = function(d, w) reorder(d, w), size = NULL)
hm_row_dendr(x, dendrogram, dist_fun = dist, hclust_fun = hclust,
  reorder_fun = function(d, w) reorder(d, w), size = NULL)

# Add row/col color annotations
#
# color and label can be character vectors or matrices (for
# multiple color bands); if they are matrices then title
# can be a character vector of length >1
hm_col_colors(x, color, label = NULL, title = NULL)
hm_row_colors(x, color, label = NULL, title = NULL)

# Customize x/y-axis formatting
hm_xaxis(x, size = 80, font_size = 12)
hm_yaxis(x, size = 120, font_size = 12)

# Add legend
hm_legend(x, legend = TRUE, row_legend = TRUE, col_legend = TRUE)
Clone this wiki locally