Skip to content

Is it possible to add spaces or separation between the squares using gheatmap? #632

Open
@kevinlopezreyes

Description

@kevinlopezreyes

Dear Dr. Guangchuang Yu,

I have a question, and I hope you can help me. Thank you.

I am trying to plot a heatmap on a phylogeny, but I want the squares representing my traits to be separated, not connected.

Here is an reproducible example

Load the libraries

library(ggtreeExtra)
library(ggplot2)
library(ggtree)

random data

set.seed(123)
tr <- rtree(5)

tip_ranges <- data.frame(row.names = tr$tip.label, Attribute1 = c("A", "B", "C", "A", "B"),
Attribute2 = c("High", "Low", "Medium", "High", "Medium"))

plot the tree

Fig_1 <- ggtree(tr) +
geom_tiplab()

Fig_1 <- gheatmap(Fig_1, tip_ranges, offset = 0.5, width = 0.5, font.size = 3,
colnames_angle = 0, hjust = 0.5, color = "black",
colnames_position = "top") +
scale_fill_manual(values = c("A" = "blue", "B" = "red", "C" = "green",
"High" = "gold", "Medium" = "lightgreen", "Low" = "gray")) +
theme(legend.position = "none")

print(Fig_1)
fig_1
fig_1_mod

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions