Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
KevinLopezReyes opened this issue Sep 25, 2024 · 0 comments

Comments

@KevinLopezReyes
Copy link

KevinLopezReyes commented Sep 25, 2024

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

@KevinLopezReyes KevinLopezReyes changed the title Is there possible to add spaces/separation in the squares using gheatmap? Is it possible to add spaces or separation between the squares using gheatmap? Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant