Learn R Programming

heatmaply (version 1.1.1)

heatmapr: Creates a heatmapr object

Description

An object of class heatmapr includes all the needed information for producing a heatmap. The goal is to separate the pre-processing of the heatmap elements from the graphical rendering of the object, which could be done using plotly (but potentially also with other graphical devices).

Usage

heatmapr(
  x,
  Rowv,
  Colv,
  distfun = dist,
  hclustfun = hclust,
  dist_method = NULL,
  hclust_method = NULL,
  distfun_row,
  hclustfun_row,
  distfun_col,
  hclustfun_col,
  dendrogram = c("both", "row", "column", "none"),
  show_dendrogram = c(TRUE, TRUE),
  reorderfun = function(d, w) reorder(d, w),
  k_row = 1,
  k_col = 1,
  symm = FALSE,
  revC,
  scale = c("none", "row", "column"),
  na.rm = TRUE,
  labRow = rownames(x),
  labCol = colnames(x),
  cexRow,
  cexCol,
  digits = 3L,
  cellnote = NULL,
  theme = NULL,
  colors = "RdYlBu",
  width = NULL,
  height = NULL,
  xaxis_height = 80,
  yaxis_width = 120,
  xaxis_font_size = NULL,
  yaxis_font_size = NULL,
  brush_color = "#0000FF",
  show_grid = TRUE,
  anim_duration = 500,
  row_side_colors,
  col_side_colors,
  seriate = c("OLO", "mean", "none", "GW"),
  point_size_mat = NULL,
  custom_hovertext = NULL,
  ...
)

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 (or hclust), 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.

dist_method

default is NULL (which results in "euclidean" to be used). Can accept alternative character strings indicating the method to be passed to distfun. By default distfun. is dist hence this can be one of "euclidean", "maximum", "manhattan", "canberra", "binary" or "minkowski".

hclust_method

default is NULL (which results in "complete" to be used). Can accept alternative character strings indicating the method to be passed to hclustfun By default hclustfun is hclust hence this can be one of "ward.D", "ward.D2", "single", "complete", "average" (= UPGMA), "mcquitty" (= WPGMA), "median" (= WPGMC) or "centroid" (= UPGMC).

distfun_row

distfun for row dendrogram only.

hclustfun_row

hclustfun for col dendrogram only.

distfun_col

distfun for row dendrogram only.

hclustfun_col

hclustfun for col dendrogram only.

dendrogram

character string indicating whether to compute '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.

show_dendrogram

Logical vector of length controlling whether the row and column dendrograms are displayed. If a logical scalar is provided, it is repeated to become a logical vector of length two.

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) If NA then find_k is used to deduce the optimal number of clusters.

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) If NA then find_k is used to deduce the optimal number of clusters.

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 on top of the heatmap cells.

theme

A custom CSS theme to use. Currently the only valid values are "" and "dark". "dark" is primarily intended for standalone visualizations, not R Markdown or Shiny.

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

xaxis_height

Size of axes, in pixels.

yaxis_width

Size of axes, in pixels.

xaxis_font_size

Font size of axis labels, as a CSS size (e.g. "14px" or "12pt").

yaxis_font_size

Font size of axis labels, as a CSS size (e.g. "14px" or "12pt").

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.

row_side_colors, col_side_colors

data.frame of factors to produce row/column side colors in the style of heatmap.2/heatmap.3. col_side_colors should be "wide", ie be the same dimensions as the column side colors it will produce.

seriate

character indicating the method of matrix sorting (default: "OLO"). Implemented options include: "OLO" (Optimal leaf ordering, optimizes the Hamiltonian path length that is restricted by the dendrogram structure - works in O(n^4) ) "mean" (sorts the matrix based on the reorderfun using marginal means of the matrix. This is the default used by heatmap.2), "none" (the default order produced by the dendrogram), "GW" (Gruvaeus and Wainer heuristic to optimize the Hamiltonian path length that is restricted by the dendrogram structure)

point_size_mat

A matrix of values which can be mapped to point size

custom_hovertext

Custom hovertext matrix (the same dimensions as the input).

...

currently ignored

See Also

heatmap, heatmap.2

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
library(heatmaply)
hm <- heatmapr(mtcars, scale = "column", colors = "Blues")
heatmaply(hm)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab