densityHeatmap {ComplexHeatmap} | R Documentation

## Use colors to represent density distribution

### Description

Use colors to represent density distribution

### Usage

    densityHeatmap(data,
        col = rev(brewer.pal(11, "Spectral")),
        density_param = list(na.rm = TRUE),
        color_space = "LAB",
        anno = NULL,
        ylab = deparse(substitute(data)),
        title = paste0("Density heatmap of ", deparse(substitute(data))),
        range = c(-Inf, Inf),
        cluster_columns = FALSE,
        clustering_distance_columns = "euclidean",
        clustering_method_columns = "complete",
        column_dend_side = "top",
        column_dend_height = unit(10, "mm"),
        show_column_dend = FALSE,
        column_dend_gp = gpar(),
        column_dend_reorder = TRUE,
        column_names_side = c("bottom", "top"),
        show_column_names = TRUE,
        column_names_max_height = unit(4, "cm"),
        column_names_gp = gpar(fontsize = 12),
        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.
`density_param` | parameters send to `density`, `na.rm` is enforced to `TRUE`.
`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.
`cluster_columns` | whether cluster columns (here cluster by density distributions)
`clustering_distance_columns` | pass to `Heatmap`
`clustering_method_columns` | pass to `Heatmap`
`column_dend_side` | pass to `Heatmap`
`column_dend_height` | pass to `Heatmap`
`show_column_dend` | pass to `Heatmap`
`column_dend_gp` | pass to `Heatmap`
`column_dend_reorder` | pass to `Heatmap`
`column_names_side` | pass to `Heatmap`
`show_column_names` | pass to `Heatmap`
`column_names_max_height` | pass to `Heatmap`
`column_names_gp` | pass to `Heatmap`
`column_order` | order of columns
`...` | pass to `draw,HeatmapList-method`

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

The density matrix is generated with 500 rows ranging between the maximun and minimal values in all densities. The density values in each row are linearly intepolated between the two density values at the two nearest bounds.

### Value

No value is returned.

### Author(s)

Zuguang Gu <z.gu@dkfz.de>

### Examples

    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)

[Package ComplexHeatmap version 1.20.0 Index]