lc_heatmap creates a new heatmap. Unlike charts with axes, heatmaps do not have
1 2 3 4 5 6 7 8
Name-value pairs of properties passed through the
An ID of the container, where to place new chart. It will be ignored if the chart already exists. If not defined, the chart will be appended to the web page's body.
Name-value pairs of properties that will be evaluated only once and then will remain
constant. These properties can still be changed later using the
An ID for the chart. All charts must have unique IDs. If a chart with the same ID already
exists, it will be replaced. If ID is not defined, it will be the same as the
value of the
A dataset or a list from which other properties should be taken. If the dataset doesn't have a
column with the requested name, the variable will be searched for outside of the dataset. Must be
Time in ms between two consecutive calls of an
You can read more about different properties here.
value - matrix of values that will be displayed as a heatmap.
rowLabel, colLabel - vector of labels for all rows or columns.
showDendogramRow, showDendogramCol - whether to show dendrograms when rows or columns are
clustered. Even if these properties are set to
FALSE, rows and columns can still be clustered.
clusterRows, clusterCols - whether rows or columns should be clustered. If these
properties are set to
FALSE, rows and columns can still be clustered later using the instrument
mode - one of
"default", "svg", "canvas". Defines, whether to display heatmap as
an SVG or Canvas object.
"default" mode switches between the two, turning heatmap into Canvas
image, when there are too many cell, and into SVG object otherwise.
rankRows, rankCols - rank of rows and columns of the heatmap. This should be a vector with a
numeric value for each row or column.
showValue - if
TRUE, values will be shown as text in each cell.
valueTextColour - of the value text in each cell. By default, the colour is defined individually
based on the cell colour.
informText - text that appears when the mouse cursor moves over an element. Unlike
completely overwrites the tooltip content with a custom HTML code. Must be a matrix of characters (HTML code
for each cell).
rowTitle, colTilte - titles for rows and columns (similar to axes titles).
palette - a vector of colours to construct a colour scale.
colourDomain - domain of the colour scale. All values outside it will
be clamped to its edges.
on_click - a function, to be called when one of the cells is clicked. Gets a vector of row and column indices
of the clicked cell as its arguments.
on_mouseover - a function, to be called when the mouse hovers over one of the cells.
Gets a vector of row and column indices of the clicked cell as its arguments.
on_mouseout - a function, to be called when the mouse moves away from one of the cells.
on_marked - a function, to be called when any of the cells are selected (marked)
or deselected. Use
getMarked function to get the IDs of the currently marked cells. To mark cells,
select them with your mouse while holding the Shift key.
on_labelClickRow, on_labelClickCol - functions, to be called when a row or a column label is clicked.
By default, a click on a, for instance, row label sorts all columns of the heatmap based on their value in the selected row.
legend_width - width of the legend in pixels. The default value is 200.
legend_height - height of the legend in pixels. By default, it is equal to the height of the chart.
legend_sampleHeight - height of a single key of the legend in pixels. The default value is 20.
legend_ncol - number of columns to order several legends. By default, this is defined from the number
of legends to reach close to a square shape.
legend_container - a DOM element of the web page where to place the legend. By default, the legend is
positioned to the right from the chart in a table cell specifically made for it. This should be a valid CSS selector.
If the specified element does not exist, the legend will be added to the web page's body.
Global chart settings
width - width of the chart in pixels.
heigth - height of the chart in pixels.
plotWidth - width of the plotting area in pixels.
plotHeight - height of the plotting area in pixels.
paddings - padding sizes in pixels. Must be a list with all the following fields:
"top", "bottom", "left", "right".
title - a title of the chart.
titleX, titleY - coordinates of the chart title.
titleSize - font-size of the chart title.
showLegend - whether or not to show the legend.
showPanel - whether of not to show the instrument panel (grey triangle in the upper-left corner of the chart).
transitionDuration - duration of the transitions between any two states of the chart. If 0,
no animated transition is shown. It can be useful to turn the transition off, when lots of frequent
changes happen to the chart.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
library(RColorBrewer) #create a test matrix test <- cbind(sapply(1:10, function(i) c(rnorm(10, mean = 1, sd = 3), rnorm(6, mean = 5, sd = 2), runif(14, 0, 8))), sapply(1:10, function(i) c(rnorm(10, mean = 3, sd = 2), rnorm(6, mean = 1, sd = 2), runif(14, 0, 8)))) test[test < 0] <- 0 rownames(test) <- paste0("Gene", 1:30) colnames(test) <- paste0("Sample", 1:20) lc_heatmap(dat(value = test)) # when you want to cluster rows or columns, it can be # a good idea to make bottom and right paddings larger to # fit labels lc_heatmap(dat(value = test), clusterRows = TRUE, clusterCols = TRUE, paddings = list(top = 50, left = 30, bottom = 75, right = 75)) lc_heatmap(dat(value = cor(test), colourDomain = c(-1, 1), palette = brewer.pal(11, "RdYlBu")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.