anno_customize {ComplexHeatmap} | R Documentation

## Customized annotation

### Description

Customized annotation

### Usage

    anno_customize(x, graphics = list(), which = c("column", "row"),
        border = TRUE, width = NULL, height = NULL, verbose = TRUE)

### Arguments

`x` | A categorical variable.
`graphics` | A list of functions that define graphics for each level in `x`.
`which` | Is it a row annotation or a column annotation?
`width` | Width of the annotation. The value should be an absolute unit. Width is not allowed to be set for column annotation.
`height` | Height of the annotation. The value should be an absolute unit. Height is not allowed to be set for row annotation.
`border` | Whether to draw border.
`verbose` | Whether to print messages.

### Details

Functions in `graphics` define simple graphics drawn in each annotation cell. The function takes four arguments:

x,y

  Center of the annotation cell.

w,h

  Width and height of the annotation cell.

### Value

An annotation function which can be used in `HeatmapAnnotation`.

### Examples

    x = sort(sample(letters[1:3], 10, replace = TRUE))
    graphics = list(
        "a" = function(x, y, w, h) grid.points(x, y, pch = 16),
        "b" = function(x, y, w, h) grid.rect(x, y, w*0.8, h*0.8, gp = gpar(fill = "red")),
        "c" = function(x, y, w, h) grid.segments(x - 0.5*w, y - 0.5*h, x + 0.5*w, y + 0.5*h, gp = gpar(lty = 2))
    )

    anno = anno_customize(x, graphics = graphics)

    m = matrix(rnorm(100), 10)
    Heatmap(m, top_annotation = HeatmapAnnotation(bar = x, foo = anno))

    # Add legends for `foo`
    ht = Heatmap(m, top_annotation = HeatmapAnnotation(bar = x, foo = anno))
    lgd = Legend(title = "foo", at = names(graphics), graphics = graphics)
    draw(ht, annotation_legend_list = list(lgd))

[Package ComplexHeatmap version 2.10.0 Index]