Question: ComplexHeatmap - Annotation without a named vector
0
3.3 years ago by
United Kingdom
andrew.j.skelton73320 wrote:

Hi,

I'm trying to make a few heatmaps dynamically, however I'm having a bit of trouble when trying to make the annotation object.

According to the guides, you need to provide a named vector to the col argument in HeatmapAnnotation function, however I can't do that when generating dynamically, as there's different annotations. I've tried an un-named vector, but I get the following error every time:

Error in ColorMapping(name = name, colors = col, na_col = na_col) :
either provide levels or provide named colors.

Code:

  ha = HeatmapAnnotation(df  = df,
col = list(type = c("black", "red")))

Any suggestions? - I feel like I've missed something obvious but can't seem to nail it down.

Thanks,

complexheatmap • 1.6k views
modified 3.3 years ago by jokergoo130 • written 3.3 years ago by andrew.j.skelton73320
Answer: ComplexHeatmap - Annotation without a named vector
2
3.3 years ago by
jokergoo130
Germany
jokergoo130 wrote:

in following code:

 ha = HeatmapAnnotation(df  = df,
col = list(type = c("black", "red")))

change c("black", "red") to a vector with names that names correspond to the levels in df$type so that we can correctly map colors to df$type.

Hi, I was wanting to do this without a named vector, is there any way for the col argument to automatically take the first element of the vector, for the first level in the data frame column, for example?

1

Hi, now it is supported in the newest version. You can update it by devtools::install_github("jokergoo/ComplexHeatmap")

ADD REPLYlink modified 3.3 years ago • written 3.3 years ago by jokergoo130

En, not in current version, but I will support it in future versions.