View source: R/AnnotationFunction-function.R
anno_customize | R Documentation |
Customized annotation
anno_customize(x, graphics = list(), which = c("column", "row"),
border = TRUE, width = NULL, height = NULL, verbose = TRUE)
x |
A categorical variable. |
graphics |
A list of functions that define graphics for each level in |
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. |
Functions in graphics
define simple graphics drawn in each annotation cell. The function takes four arguments:
Center of the annotation cell.
Width and height of the annotation cell.
An annotation function which can be used in HeatmapAnnotation
.
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.