Hello,
Thank you for the great package. After plotting a tree in which I used scale_fill_manual for coloring node support, I tried to add a heatmap with geografic data. I cannot change the default colours of scale_fill_manual in the gheatmap plotting.
#import tree
ifla.tree <- read.iqtree("ifla_o_dicistro_trim.fasta.treefile")#extract metadata and clean it
ifla.metadata <- tibble(as_tibble(ifla.tree)) %>%
mutate(metadata = label) %>%
separate(metadata, c("accession","taxon","host","continent"), sep = "-") %>%
select(label,accession,taxon,host,continent) %>%
replace(is.na(.), "outgroup")ifla.metadata <- ifla.metadata[c(1:49),]
ifla.metadata$taxon <- gsub("_", " ", ifla.metadata$taxon)
#integrate metadata in tree object
ifla.tibble <- as_tibble(ifla.tree)
ifla.tree <- full_join(ifla.tibble, ifla.metadata, by = "label") %>%
as.treedata
#drop outgroup tip
ifla.tree <- drop.tip(ifla.tree, "NC003005-Taura_syndrome_virus-outgroup")
#color vectors
#colors for host groups
ifla.cols <- c(Arachnida = "purple4", bats = "brown", bats_Diptera = "mediumorchid1",
Crustacea = "salmon1", Diptera = "lightblue", Hemiptera = "steelblue1",
Hymenoptera = "steelblue4", Lepidoptera = "royalblue1", Orthoptera = "darkblue")
#extract distribution info
ifla.continent <- data.frame("continent" = ifla.metadata[, c("continent")])
rownames(ifla.continent) <- ifla.metadata$label
# colors for distribution
ifla.continent.cols <- c(Asia="grey30",Africa="violet",Europe="dodgerblue3",'Central America'="coral", 'South America'="blue",'North America'="firebrick4", Australia="darkslateblue", Cosmopolitan = "seagreen")
#plot tree
ifla.phylo <- ggtree(ifla.tree, aes(color = host), linewidth = 2) +
geom_tiplab(aes(label = taxon), color = "black",size = 6, align = T, linesize = .5) +
geom_point2(aes(subset=!isTip, fill = cut(UFboot, c(0, 70, 85, 100))),
shape = 21, size = 5) +
scale_fill_manual(values=c("black", "grey", "white"), guide='legend',
name='Bootstrap Support (%)',
breaks=c('(85,100]', '(70,85]', '(0,70]'),
labels=c("85-100","70-85", "44-70")) +
geom_treescale(x=.1, y=9, fontsize = 8, linesize = 1.2) +
geom_cladelab(node = 50, label = "Dicistroviridae",
align = F, vjust = 1.5, fontsize = 6, barsize = 0) +
scale_color_manual(values = ifla.cols) +
coord_cartesian(clip = "off") +
theme(plot.margin = margin(1,7,1,1, "cm"),
legend.position = c(.1,.75),
legend.text = element_text(size = 16),
legend.title = element_text(size = 16, face = 2),
legend.key.width = unit(1, "cm"),
legend.key.height = unit(1, "cm")) +
guides(color = guide_legend(order = 1))
#collapse outgroup clade
ifla.phylo <- scaleClade(ifla.phylo, 50, .3)%>%
collapse(50, 'min')
I get the Iflavirus1 plot. Then,
#plot continent info as heatmap annotation
ifla.phylo2 <- ifla.phylo + new_scale_fill()
gheatmap(ifla.phylo2, data = ifla.continent, offset = 1.5, width = .04, font.size = 6,
colnames = F, "Geographic distribution") +
new_scale_fill() +
scale_fill_manual(values = ifla.continent.cols)
and I get Iflavirus_hm.
Q1. How can I control the color fill in gheatmap? I tried viridis and RcolorBrewer, I tried to use scale_color_manual for the node support shape=16 instead of 21, nothing works.
Q2. How can I remove the circles in the Host legend keys? (keep only lines)
Thanks a lot in advance, it's a great package!
Alex Tomazatos