ggtree
ggtree copied to clipboard
Add geom_hilight for phyla.
trafficstars
I would like to add a geom_hilight for each phyla from the tip all the way to the root of each phylum. Here is my script and the table below with IDs of the tips and Phyla. Any tips appreciated.
p <- ggtree(tree.HMF.ape,ladderize = T, layout="fan", open.angle=12, size=0.2,right = T)
p1 <- p +
geom_fruit(
data=split.treeoflife,
geom=geom_point,
mapping=aes(y=SGB, colour=Phylum,fill=Phylum),
position="identity",
size=3
) +
scale_size_continuous(
range=c(1, 3), # the range of size.
guide=guide_legend(
keywidth=0.5,
keyheight=0.5,
order=2
)
) +
scale_fill_manual(
values=c("#8c510a","#276419","#b2182b","#2166ac","#fee090","#B0BEC5")
) +
scale_colour_manual(
values=c("#8c510a","#276419","#b2182b","#2166ac","#fee090","#B0BEC5"))
p1
p1 +
new_scale_fill() +
geom_fruit(
data=p.dat2,
geom=geom_tile,
mapping=aes(y=SGB,x=ring_alpha, alpha=MeanPrevalence, fill=ring_alpha),
pwidth=0.05,
axis.params=list(
axis="x", # add axis text of the layer.
text.angle=-45, # the text angle of x-axis.
hjust=0, # adjust the horizontal position of text of axis.
)
) +
scale_fill_manual(
values=c("#081d58", "#67000d"),
guide=guide_legend(keywidth=0.5, keyheight=0.1, order=4,title = "Sample type")
) +
scale_alpha_continuous(
range=c(0, 1), # the range of alpha
guide=guide_legend(keywidth=0.5, keyheight=0.3, order=5,title = "Abundance")
)
> head(split.treeoflife)
Phylum Class Order Family Genus Species SGB
1 Actinobacteria Actinomycetes Actinomycetales Actinomycetaceae Actinomyces Actinomyces_SGB17154 SGB17154
2 Actinobacteria Actinomycetes Actinomycetales Actinomycetaceae Actinomyces Actinomyces_graevenitzii SGB17130
3 Actinobacteria Actinomycetes Actinomycetales Actinomycetaceae Actinomyces Actinomyces_sp_ICM47 SGB17167
4 Actinobacteria Actinomycetes Actinomycetales Actinomycetaceae Actinotignum Actinotignum_timonense SGB17174_group
5 Actinobacteria Actinomycetes Actinomycetales Actinomycetaceae Fannyhessea Fannyhessea_vaginae SGB991
6 Actinobacteria Actinomycetes Actinomycetales Actinomycetaceae Gleimia Gleimia_europaea SGB17196