ComplexHeatmap (version 1.10.2)

densityHeatmap: Use colors to represent density distribution

Description

Use colors to represent density distribution

Usage

densityHeatmap(data,
    col = rev(brewer.pal(11, "Spectral")),
    color_space = "LAB",
    anno = NULL,
    ylab = deparse(substitute(data)),
    title = paste0("Density heatmap of ", deparse(substitute(data))),
    range = c(-Inf, Inf),
    column_order = NULL,
    ...)

Arguments

data
a matrix or a list. If it is a matrix, density will be calculated by columns.
col
a list of colors that density values are mapped to.
color_space
the color space in which colors are interpolated. Pass to colorRamp2.
anno
annotation for the matrix columns or the list. The value should be a vector or a data frame and colors for annotations are randomly assigned. If you want to customize the annotation colors, use a HeatmapAnnotation-class object directly.
ylab
label on y-axis in the plot
title
title of the plot
range
ranges on the y-axis. By default the range is between 1th quantile and 99th quantile of the data.
column_order
order of columns

Value

  • No value is returned.

Details

To visualize data distribution in a matrix or in a list, sometimes we use boxplot or beanplot. Here we use colors to map the density values and visualize distribution of values in each column (or each vector in the list) through a heatmap. It is useful if you have huge number of columns in data to visualize.

Examples

Run this code
matrix = matrix(rnorm(100), 10); colnames(matrix) = letters[1:10]
densityHeatmap(matrix)
densityHeatmap(matrix, anno = rep(c("A", "B"), each = 5))
densityHeatmap(matrix, col = c("white", "red"), anno = rep(c("A", "B"), each = 5))

ha = HeatmapAnnotation(points = anno_points(runif(10)),
    anno = rep(c("A", "B"), each = 5), col = list(anno = c("A" = "red", "B" = "blue")))
densityHeatmap(matrix, anno = ha)

lt = list(rnorm(10), rnorm(10))
densityHeatmap(lt)

Run the code above in your browser using DataCamp Workspace