I just discovered heatmaply and I was trying to use produced a grouped heatmap. I checked the documentation and noticed the "heatmap_layers" option, which can be used to add ggplot code to the heatmap, so I figured a working solution:
df <- mtcars %>%
select(-vs) %>%
t()
group_names <- mtcars %>%
mutate(vs = ifelse(vs == 0, "v-shaped", "straight"))
group_names[] <- as.character(group_names$vs)
group_names <- group_names %>%
select(-vs) %>%
t()
heatmaply(df,
scale = "row",
heatmap_layers = facet_grid(cols = vars({as.vector(group_names)})
)
)
This separates the two categories "straight" and "v-shaped" as expected. The problem is the dendrogram produced doesn't match the heatmap and also overlaps with the strip element produced by ggplot. I tried with the option "dendrogram_layers" but can't find a solution.