ggtree icon indicating copy to clipboard operation
ggtree copied to clipboard

Curved clade labels in ggtree using geom_cladelab

Open megaraptor1 opened this issue 4 years ago • 3 comments
trafficstars

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

  • [x] Have you read Feedback and follow the guide?
    • [x] make sure your are using the latest release version
    • [x] read the documents
    • [x] google your question/issue

Describe you issue

  • [x] Make a reproducible example (e.g. 1)
  • [x] your code should contain comments to describe the problem (e.g. what expected and actually happened?)

Ask in right place

  • [x] for bugs or feature requests, post here (github issue)
  • [ ] for questions, please post to google group

megaraptor1 avatar Apr 04 '21 22:04 megaraptor1

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.

xiangpin avatar Apr 14 '21 11:04 xiangpin

Was this functionality ever fully implemented?

aast242 avatar Feb 22 '24 02:02 aast242