Heatmap: rhtmlHeatmap widget

View source: R/rhtmlHeatmap.R

HeatmapR Documentation

rhtmlHeatmap widget

Description

Creates a D3.js-based heatmap widget. Modified from d3heatmap package.

Usage

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,
  ...
)

Arguments

x

A numeric matrix Defaults to TRUE unless x contains any NAs.

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 xaxis_font_size and will give it a value cexRow*14

cexCol

positive numbers. If not missing, it will override yaxis_font_size and will give it a value cexCol*14

digits

integer indicating the number of decimal places to be used by round for 'label'.

cellnote

(optional) matrix of the same dimensions as x that has the human-readable version of each value, for displaying to the user on hover. If NULL, then x will be coerced using as.character. If missing, it will use x, after rounding it based on the digits parameter.

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 TRUE, print cellnotes in the cells. Defaults to FALSE.

extra_tooltip_info

A list of matrices that contains extra information to show in the tooltips. Dim of each matrix must equal to x.

color_range

A vector of length 2 that specifies the range of values that colors get mapped to. The default is computed from x. If x is a factor, this argument is ignored.

lower_triangle

A logical value to specify if only the lower triangle will be displayed. Defaults to FALSE and will give an error if x is not a square matrix.

cells_to_hide

A boolean matrix with the same dimension as x that specifies which cell to hide. Hidden cells will not trigger tooltips and will be transparent in color.

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 scale is not "none", legend will not be shown.

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. "YlOrRd" or "Blues"), or a vector of colors to interpolate in hexadecimal "#RRGGBB" format, or a color interpolation function like colorRamp.

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 left_columns or right_columns, this parameter must be TRUE.

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, with length same as the number of columns of left_columns. Allowed characters are "l", "c" and "r".

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, with length same as the number of columns of right_columns. Allowed characters are "l", "c" and "r".

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. "#RRGGBB" format expected.

show_grid

TRUE to show gridlines, FALSE to hide them, or a numeric value to specify the gridline thickness in pixels (can be a non-integer).

anim_duration

Number of milliseconds to animate zooming in and out. For large x it may help performance to set this value to 0.

...

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.

Source

The interface was designed based on heatmap and heatmap.2

See Also

heatmap, heatmap.2

Examples

library(rhtmlHeatmap)
Heatmap(mtcars, scale = "column", colors = "Blues")

For more examples see the /examples/examples.R file
in the source package



NumbersInternational/rhtmlHeatmap documentation built on Nov. 2, 2023, 9:48 a.m.