Learn R Programming

ComplexHeatmap (version 1.10.2)

HeatmapAnnotation: Constructor method for HeatmapAnnotation class

Description

Constructor method for HeatmapAnnotation class

Usage

HeatmapAnnotation(df, name, col, na_col = "grey",
    annotation_legend_param = list(),
    show_legend = TRUE,
    ...,
    which = c("column", "row"),
    annotation_height = 1,
    annotation_width = 1,
    height = calc_anno_size(),
    width = calc_anno_size(),
    gp = gpar(col = NA),
    gap = unit(0, "mm"))

Arguments

df
a data frame. Each column will be treated as a simple annotation. The data frame must have column names.
name
name of the heatmap annotation, optional.
col
a list of colors which contains color mapping to columns in df. See SingleAnnotation for how to set colors.
na_col
color for NA values in simple annotations.
annotation_legend_param
a list which contains parameters for annotation legends
show_legend
whether show legend for each column in df.
...
functions which define complex annotations or vectors of simple annotation. Values should be named arguments.
which
are the annotations row annotations or column annotations?
annotation_height
height of each annotation if annotations are column annotations.
annotation_width
width of each annotation if annotations are row annotations.
height
not using currently.
width
width of the whole heatmap annotations, only used for row annotation when appending to the list of heatmaps.
gp
graphic parameters for simple annotations.
gap
gap between each annotation

Value

Details

The simple annotations are defined by df and col arguments. Complex annotations are defined by the function list. So you need to at least to define df or a annotation function.

See Also

There are two shortcut functions: rowAnnotation and columnAnnotation.

Examples

Run this code
df = data.frame(type = c("a", "a", "a", "b", "b", "b"))
ha = HeatmapAnnotation(df = df)

ha = HeatmapAnnotation(df = df, col = list(type = c("a" =  "red", "b" = "blue")))
ha = HeatmapAnnotation(type = c("a", "a", "a", "b", "b", "b"), 
    col = list(type = c("a" =  "red", "b" = "blue")))

ha = HeatmapAnnotation(df = df, col = list(type = c("a" =  "red", "b" = "blue")), 
    which = "row")

ha = HeatmapAnnotation(points = anno_points(1:6))

ha = HeatmapAnnotation(histogram = anno_points(1:6))

mat = matrix(rnorm(36), 6)
ha = HeatmapAnnotation(boxplot = anno_boxplot(mat))

Run the code above in your browser using DataLab