Heatmap | R Documentation |
Creates a D3.js-based heatmap widget. Modified from d3heatmap package.
Heatmap(
x,
Rowv = TRUE,
Colv = if (symm) "Rowv" else TRUE,
distfun = dist,
hclustfun = hclust,
dendrogram = c("both", "row", "column", "none"),
reorderfun = function(d, w) reorder(d, w),
k_row,
k_col,
symm = FALSE,
revC,
scale = c("none", "row", "column"),
na.rm = TRUE,
labRow = rownames(x),
labCol = colnames(x),
cexRow,
cexCol,
digits = 3L,
cellnote,
cellnote_scale = FALSE,
cellnote_in_cell = NULL,
show_cellnote_in_cell = FALSE,
extra_tooltip_info = NULL,
color_range = NULL,
lower_triangle = FALSE,
cells_to_hide = NULL,
cell_font_size = 11,
cell_font_family = "sans-serif",
tip_font_size = 11,
tip_font_family = "sans-serif",
show_legend = TRUE,
legend_font_family = "sans-serif",
legend_font_color = "#000000",
legend_width = 60,
legend_digits = NULL,
legend_font_size = 11,
legend_label_format = "normal",
colors = "RdYlBu",
width = NULL,
height = NULL,
title = NULL,
title_font_size = 24,
title_font_family = "sans-serif",
title_font_color = "#000000",
subtitle = NULL,
subtitle_font_size = 18,
subtitle_font_family = "sans-serif",
subtitle_font_color = "#000000",
footer = NULL,
footer_font_size = 11,
footer_font_family = "sans-serif",
footer_font_color = "#000000",
column_label_orientation = "diagonal",
column_label_max_height = 0.25,
row_label_max_width = 0.25,
heatmap_max_height = 1,
heatmap_max_width = 1,
xaxis_hidden = FALSE,
xaxis_font_size = 12,
xaxis_font_family = "sans-serif",
xaxis_font_color = "#000000",
xaxis_location = "bottom",
xaxis_title = NULL,
xaxis_title_font_size = 14,
xaxis_title_font_family = "sans-serif",
xaxis_title_font_color = "#000000",
yaxis_hidden = FALSE,
yaxis_font_size = 11,
yaxis_font_family = "sans-serif",
yaxis_font_color = "#000000",
yaxis_location = "right",
yaxis_title = NULL,
yaxis_title_font_size = 14,
yaxis_title_font_family = "sans-serif",
yaxis_title_font_color = "#000000",
left_columns = NULL,
left_columns_align = NULL,
left_columns_font_size = 11,
left_columns_font_family = "sans-serif",
left_columns_font_color = "#000000",
left_columns_subtitles = NULL,
left_columns_subtitles_font_size = 12,
left_columns_subtitles_font_family = "sans-serif",
left_columns_subtitles_font_color = "#000000",
left_columns_title = NULL,
left_columns_title_font_size = 14,
left_columns_title_font_family = "sans-serif",
left_columns_title_font_color = "#000000",
right_columns = NULL,
right_columns_align = NULL,
right_columns_font_size = 11,
right_columns_font_family = "sans-serif",
right_columns_font_color = "#000000",
right_columns_subtitles = NULL,
right_columns_subtitles_font_size = 12,
right_columns_subtitles_font_family = "sans-serif",
right_columns_subtitles_font_color = "#000000",
right_columns_title = NULL,
right_columns_title_font_size = 14,
right_columns_title_font_family = "sans-serif",
right_columns_title_font_color = "#000000",
brush_color = "#0000FF",
show_grid = TRUE,
anim_duration = 500,
...
)
x |
A numeric matrix
Defaults to |
Rowv |
determines if and how the row dendrogram should be reordered. By default, it is TRUE, which implies dendrogram is computed and reordered based on row means. If NULL or FALSE, then no dendrogram is computed and no reordering is done. If a dendrogram, then it is used "as-is", ie without any reordering. If a vector of integers, then dendrogram is computed and reordered based on the order of the vector. |
Colv |
determines if and how the column dendrogram should be reordered. Has the options as the Rowv argument above and additionally when x is a square matrix, Colv = "Rowv" means that columns should be treated identically to the rows. |
distfun |
function used to compute the distance (dissimilarity) between both rows and columns. Defaults to dist. |
hclustfun |
function used to compute the hierarchical clustering when Rowv or Colv are not dendrograms. Defaults to hclust. |
dendrogram |
character string indicating whether to draw 'none', 'row', 'column' or 'both' dendrograms. Defaults to 'both'. However, if Rowv (or Colv) is FALSE or NULL and dendrogram is 'both', then a warning is issued and Rowv (or Colv) arguments are honoured. |
reorderfun |
function(d, w) of dendrogram and weights for reordering the row and column dendrograms. The default uses statsreorder.dendrogram |
k_row |
an integer scalar with the desired number of groups by which to color the dendrogram's branches in the rows (uses color_branches) |
k_col |
an integer scalar with the desired number of groups by which to color the dendrogram's branches in the columns (uses color_branches) |
symm |
logical indicating if x should be treated symmetrically; can only be true when x is a square matrix. |
revC |
logical indicating if the column order should be reversed for plotting. Default (when missing) - is FALSE, unless symm is TRUE. This is useful for cor matrix. |
scale |
character indicating if the values should be centered and scaled in either the row direction or the column direction, or none. The default is "none". |
na.rm |
logical indicating whether NA's should be removed. |
labRow |
character vectors with row labels to use (from top to bottom); default to rownames(x). |
labCol |
character vectors with column labels to use (from left to right); default to colnames(x). |
cexRow |
positive numbers. If not missing, it will override |
cexCol |
positive numbers. If not missing, it will override |
digits |
integer indicating the number of decimal places to be used by round for 'label'. |
cellnote |
(optional) matrix of the same dimensions as |
cellnote_scale |
logical (default is FALSE). IF cellnote is missing and x is used, should cellnote be scaled if x is also scaled? |
cellnote_in_cell |
Overrides cellnote when the user wish to display texts inside the cells that are different from the tooltips. |
show_cellnote_in_cell |
If |
extra_tooltip_info |
A list of matrices that contains extra information to show in the tooltips. Dim of each matrix must equal to |
color_range |
A vector of length 2 that specifies the range of values that colors get mapped to. The default is computed from |
lower_triangle |
A logical value to specify if only the lower triangle will be displayed. Defaults to FALSE and will give an error if |
cells_to_hide |
A boolean matrix with the same dimension as |
cell_font_size |
Sets the maximum font size of cellnotes. Defauls to 11. |
cell_font_family |
Sets the font family of cellnotes. Defauls to "sans-serif", |
tip_font_size |
Sets the font size of texts in the tooltip. Defaults to 11. |
tip_font_family |
Sets the font size of texts in the tooltip. Defaults to "sans-serif". |
show_legend |
logical. Defaults to TRUE. However, if |
legend_font_family |
character. Sets the font family of the legend, defaults to "sans-serif". |
legend_font_color |
Sets the font color of the legend, defaults to "#000000". |
legend_width |
positive integer. Sets the desired width of the legend bar. Defaults to 60 (pixcels). |
legend_digits |
positive integer. Sets the decimal places of the legend texts. Estimates the decimal places needed by default. |
legend_font_size |
positive integer. Sets the font size of the legend. Defaults to 11 (pixcels). |
legend_label_format |
string. "normal" or "percentage". If percentage, convert legend values to percent (* 100, add "%"). |
colors |
Either a colorbrewer2.org palette name (e.g. |
width |
Width in pixels (optional, defaults to automatic sizing). |
height |
Height in pixels (optional, defaults to automatic sizing). |
title |
character. Sets the title of the chart, defaults to NULL. The title is centred. |
title_font_size |
integer. Font size of the chart title, defaults to 24 pixcels. |
title_font_family |
character. Font family of the chart title, defaults to "sans-serif". |
title_font_color |
An RGB character to set the color of the chart title. Defaults to "#000000". |
subtitle |
character. Sets the subtitle of the chart, defaults to NULL. The subtitle is centred. |
subtitle_font_size |
integer. Font size of the chart subtitle, defaults to 18 pixcels. |
subtitle_font_family |
character. Font family of the chart subtitle, defaults to "sans-serif". |
subtitle_font_color |
An RGB character to set the color of the chart subtitle. Defaults to "#000000". |
footer |
character. Sets the footer of the chart, defaults to NULL. The footer is left-aligned. |
footer_font_size |
integer. Font size of the chart footer_font_size, defaults to 11 pixcels. |
footer_font_family |
character. Font family of the chart footer_font_family, defaults to "sans-serif". |
footer_font_color |
An RGB character to set the color of the chart footer_font_color. Defaults to "#000000". |
xaxis_hidden |
Boolean variable to hide x axis. Defaults to FALSE. |
xaxis_font_size |
Font size of x axis labels, as a CSS size (e.g. "14px" or "12pt"). Defaults to 12. |
xaxis_font_family |
Font family of x axis labels. Defaults to "sans-serif". |
xaxis_font_color |
Font folor of x axis labels. Defaults to "#000000". |
xaxis_location |
Location of the x axis, c("bottom", "top"). Defaults to "bottom". "top" only works when dendrogram is "none". |
xaxis_title |
Title text of the x axis. |
xaxis_title_font_size |
Size of axis title text. Defaults to 14. |
xaxis_title_font_family |
Font family of x axis title. Defaults to "sans-serif". |
xaxis_title_font_color |
Font folor of x axis title. Defaults to "#000000". |
yaxis_hidden |
Boolean variable to hide y axis. Defaults to FALSE. To use a table layout with |
yaxis_font_size |
Font size of axis labels, as a CSS size (e.g. "14px" or "12pt"). Defaults to 11. |
yaxis_font_family |
Font family of y axis labels. Defaults to "sans-serif". |
yaxis_font_color |
Font folor of y axis labels. Defaults to "#000000". |
yaxis_location |
Location of the y axis, c("right", "left"). Defaults to "right". "left" only works when dendrogram is "none". |
yaxis_title |
Title text of the y axis. |
yaxis_title_font_size |
Size of axis title text. Defaults to 14. |
yaxis_title_font_family |
Font family of y axis title. Defaults to "sans-serif". |
yaxis_title_font_color |
Font folor of y axis title. Defaults to "#000000". |
left_columns |
Matrix-like object with N columns, N>0. These columns are put on the left side of the heatmap to replace the y axis. yaxis_hidden must be set to TRUE. |
left_columns_align |
a character vector to set the alignment of |
left_columns_font_size |
Sets the font size of the left_columns. Defaults to 11. |
left_columns_font_family |
Sets the font family of the left_columns. Defaults to "sans-serif". |
left_columns_font_color |
Sets the font color of the left_columns. Defaults to "#000000". |
left_columns_subtitles |
Vector with length N, N>0. Sets the top heading of the left_columns. Will not have an effect if left_columns is NULL. |
left_columns_subtitles_font_size |
Sets the font size of left_columns_subtitles. Defaults to 12. |
left_columns_subtitles_font_family |
Sets the font family of left_columns_subtitles. Defaults to "sans-serif". |
left_columns_subtitles_font_color |
Sets the font color of left_columns_subtitles. Defaults to "#000000". |
left_columns_title |
Character. Sets the title of the left_columns. Will not have an effect if left_columns or left_columns_subtitles is NULL. |
left_columns_title_font_size |
Sets the font size of left_columns_title. Defaults to 14. |
left_columns_title_font_family |
Sets the font family of left_columns_title. Defaults to "sans-serif". |
left_columns_title_font_color |
Sets the font color of left_columns_title. Defaults to "#000000". |
right_columns |
Matrix-like object with N columns, N>0. These columns are put on the right side of the heatmap to replace the y axis. yaxis_hidden must be set to TRUE. |
right_columns_align |
a character vector to set the alignment of |
right_columns_font_size |
Sets the font size of the right_columns. Defaults to 11. |
right_columns_font_family |
Sets the font family of the right_columns. Defaults to "sans-serif". |
right_columns_font_color |
Sets the font color of the right_columns. Defaults to "#000000". |
right_columns_subtitles |
Vector with length N, N>0. Sets the top heading of the right_columns. Will not have an effect if right_columns is NULL. |
right_columns_subtitles_font_size |
Sets the font size of right_columns_subtitles. Defaults to 12. |
right_columns_subtitles_font_family |
Sets the font family of right_columns_subtitles. Defaults to "sans-serif". |
right_columns_subtitles_font_color |
Sets the font color of right_columns_subtitles. Defaults to "#000000". |
right_columns_title |
Character. Sets the title of the right_columns. Will not have an effect if right_columns or right_columns_subtitles is NULL. |
right_columns_title_font_size |
Sets the font size of right_columns_title. Defaults to 14. |
right_columns_title_font_family |
Sets the font family of right_columns_title. Defaults to "sans-serif". |
right_columns_title_font_color |
Sets the font color of right_columns_title. Defaults to "#000000". |
brush_color |
The base color to be used for the brush. The brush will be
filled with a low-opacity version of this color. |
show_grid |
|
anim_duration |
Number of milliseconds to animate zooming in and out.
For large |
... |
currently ignored |
column_label_orientation. |
Enum ['horizontal', 'vertical', 'diagonal']. Defaults to 'diagonal'. |
column_label_max_height. |
Max height used by column labels (xaxis and column subtitles). Specified as proportion of total height. Defaults to 0.25. |
row_label_max_width. |
Max width used by row labels (yaxis and column labels). Specified as proportion of total height. Defaults to 0.25. |
heatmap_max_height. |
Max height used by heatmap grid. Specified as proportion of total height. Defaults to 1. |
heatmap_max_width. |
Max width used by heatmap grid. Specified as proportion of total width. Defaults to 1. |
The interface was designed based on heatmap and heatmap.2
heatmap, heatmap.2
library(rhtmlHeatmap)
Heatmap(mtcars, scale = "column", colors = "Blues")
For more examples see the /examples/examples.R file
in the source package
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.