YuLab-SMU / ggtree

:christmas_tree:Visualization and annotation of phylogenetic trees
https://yulab-smu.top/contribution-tree-data/
839 stars 173 forks source link

Curved clade labels in ggtree using geom_cladelab #389

Open megaraptor1 opened 3 years ago

megaraptor1 commented 3 years ago

In the phytools package there is an option to plot clade names as an arc using the arc.cladelabels function.

library(ape)
library(phytools)
library(ggplot2)
library(ggtree)
set.seed(200)
tree<-force.ultrametric(rtree(100))
plot(tree,type="fan",cex=0.5,lwd=0.6)
arc.cladelabels(text="This Is A Very Long Clade Name",node=mrca(tree)["t41","t6"],mark.node=TRUE,
                  ln.offset=1.135,lab.offset = 1.22,fsize=1.,orientation="curved")

tree1

I have previously plotted trees in this manner using phytools, however I wish to try and start doing it in ggtree because I find the ggplot language more flexible in its application. However, I noticed that there doesn't seem to be an option to create arced clade labels using geom_cladelab. The closest I have been able to do to replicate the tree above is as shown below.

ggtree(tree,layout="circular")+
  geom_tiplab()+
  geom_cladelab(offset=1,label="This Is A Very Long Clade Name",node=mrca(tree)["t41","t6"],horizontal=FALSE, angle="auto",vjust=1,hjust=0.5,colour="blue")

tree2

The auto angle function is nice, but it would be nice to have the clade names arched in order to save space when there are very long clade names and it is not desired to have the clade names extend significantly away from the graph. Phytools' function also always has the clade labels facing the same direction (with the bottom towards the root of the tree), but it does not seem to be possible to do this using ggtree. I have checked online through Google and Stack Overflow and through the ggtree handbook and vignettes and there does not seem to be any option to plot a curved clade label in ggtree. Do you know if such a function exists, or if it could be added to a later release?

Prerequisites

Describe you issue

Ask in right place

xiangpin commented 3 years ago

This feature might need to update the base element, which is different from the element of phytools. We will try our best to complete it.

aast242 commented 8 months ago

Was this functionality ever fully implemented?