1
$\begingroup$

I am trying to use ComplexHeatmap to plot heatmap with annotation. The code that I have tried

library(ComplexHeatmap)
library(circlize)

set.seed(123)
mat = matrix(rnorm(25), 5)
rownames(mat) = paste0("R", 1:5)
colnames(mat) = paste0("C", 1:5)

col_fun = colorRamp2(c(0, 2, 5), c("white", "blue", "red"))
data_foo = c(0.1, 3, 1.6, 2.8, 4)

ha = HeatmapAnnotation(which = "row", foo = data_foo, col = list(foo = col_fun))
Heatmap(mat, name = "mat", right_annotation = ha)

ha1 = HeatmapAnnotation(which = "row", foo = anno_text(data_foo))
Heatmap(mat, name = "mat", right_annotation = ha1)

Can I obtain the annotation with colors varying as per the annotation values and also display the values in the annotation? i.e is it possible to combine the annotation in both figures? HeatMap with color annotation

HeatMap with values as annotation

$\endgroup$
0

1 Answer 1

0
$\begingroup$

Answer from @haci, converted from comment:

You can use the pch parameter in anno_simple() but you can only use a single character or a digit. It is not limited to symbols only, you can provide a vector to pch, but only the first character would be printed. If by chance your values are [0-9] you can use pch as kind of hack for your purposes above.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.