Search code examples
rheatmapggtree

Remove space between gheatmap tiles


I'm creating a tree with a ggtree and gheatmap. I am trying to work out how to remove the space between the tip tiles and/or merge adjacent tiles with the same value.

Below is the code I used:

library(ape)
library(tidyverse)
library(ggtree)

tree <- rtree(50)
tree_plot <- ggtree(tree, size = 1, layout = "circular", branch.length = "none")

dummy_data <- data.frame(data = c(rep(1,10),rep(2,10),rep(3,10), rep(4,10), rep(5,10)))
row.names(dummy_data) <- tree$tip.label

gheat_Sensitivity <- gheatmap(p = tree_plot, data=dummy_data, width=0.1, colnames = FALSE) +
new_scale(aes(color = dummy_data)) +
scale_fill_gradientn(colors = c("grey", "yellow"), breaks = c(1, 5.0))

plot(gheat_Sensitivity)

This creates the tree I am after: ggtree plot

However I would like to remove the spacing between the heatmap tiles so that there is a continuous look to it. Specifically, I would like adjacent tiles with the same value to look like one larger tile.

Any help would be very appreciated, Cheers, Tom


Solution

  • Bit late, but for anyone else who has the same issue, you can add colour=NA to the gheatmap call, i.e.

    gheatmap(p = tree_plot, data=dummy_data, width=0.1, colnames = FALSE, color=NA) 
    

    See here - heatmap with the left with the row space, right after using color=NA.