Question: How can I use 'geom_taxalink()' with the circular layout in the 'ggtree' package in R?
gravatar for sd.gamboa.t
26 days ago by
sd.gamboa.t50 wrote:


I want to create a figure of an annotated phylogenetic tree in circular layout with ggtree in R. Some tips must be linked by a curve line. I can achieve this with the geom_taxalink() function in the rectangular layout, but it doesn't work in the circular layout. This seems to be because the geom_taxalink() uses geom_curve(), which doesn't support non-linear coordinates. I get the following message:

"Warning message:
geom_curve is not implemented for non-linear coordinates"

Below, example code and output, desired result, and session info.

I'd appreciate any help to get my desired output.



raxml_file <- system.file("extdata/RAxML", 

raxml <- read.raxml(raxml_file)
raxml <- as_tibble(raxml)
raxml$label <- gsub("_.*$", "", raxml$label)
raxml <- as.treedata(raxml)

my_tree <- ggtree(raxml, layout = "circular", branch.length = "none") + 
  geom_tiplab2(size = 3, hjust = 1) +
  geom_taxalink("EU857082",   "YGSIV1534", color = "red") +
  scale_x_reverse(limits = c(100, 0))

ggsave("my_tree.png", my_tree,
       width = 10, height = 10, units = "in",
       dpi = 300)

The result I get:

Desired result:

Session Info

info <- sessionInfo()
toLatex(info, locale = FALSE)

# \begin{itemize}\raggedright
# \item R version 4.0.2 (2020-06-22), \verb|x86_64-pc-linux-gnu|
#   \item Running under: \verb|Ubuntu 18.04.4 LTS|
#   \item Matrix products: default
# \item BLAS:   \verb|/usr/lib/x86_64-linux-gnu/blas/|
#   \item LAPACK: \verb|/usr/lib/x86_64-linux-gnu/lapack/|
#   \item Base packages: base, datasets, graphics, grDevices, methods,
# stats, utils
# \item Other packages: ggplot2~3.3.2, ggtree~2.2.1, treeio~1.12.0
# \item Loaded via a namespace (and not attached): ape~5.4,
# aplot~0.0.4, assertthat~0.2.1, BiocManager~1.30.10, cli~2.0.2,
# colorspace~1.4-1, compiler~4.0.2, crayon~1.3.4, dplyr~1.0.0,
# ellipsis~0.3.1, fansi~0.4.1, farver~2.0.3, generics~0.0.2,
# glue~1.4.1, grid~4.0.2, gtable~0.3.0, jsonlite~1.7.0, labeling~0.3,
# lattice~0.20-41, lazyeval~0.2.2, lifecycle~0.2.0, magrittr~1.5,
# munsell~0.5.0, nlme~3.1-148, parallel~4.0.2, patchwork~1.0.1,
# pillar~1.4.6, pkgconfig~2.0.3, purrr~0.3.4, R6~2.4.1, Rcpp~1.0.5,
# rlang~0.4.7, rstudioapi~0.11, rvcheck~0.1.8, scales~1.1.1,
# tibble~3.0.3, tidyr~1.1.0, tidyselect~1.1.0, tidytree~0.3.3,
# tools~4.0.2, vctrs~0.3.1, withr~2.2.0
# \end{itemize}
rstats ggtree ggplot2 R phylogeny • 208 views
ADD COMMENTlink modified 23 days ago • written 26 days ago by sd.gamboa.t50


ADD REPLYlink written 26 days ago by Kevin Blighe63k

I see what you mean. 'Curvature' is usually controlled by the curvature parameter that is passed to geom_taxalink(); however, it only works for the non-circular layout, as inferred from here:

Note that in your second plot, you have already added that line manually - is that not an option?

ADD REPLYlink written 25 days ago by Kevin Blighe63k

The images I posted were an example of what I need to achieve. Actually, I have a tree with over 8,000 tip nodes and more than 140,000 connections between tips. I can easily create the tree with ITOL (, but I've been having trouble exporting it. I assume it's because of the size of the tree as I have no problem with smaller ones (I'll try with a faster computer and see what happens).

ADD REPLYlink written 25 days ago by sd.gamboa.t50

I see. You could contact ITOL, too, or create an issue / feature request on the ggplot2 GitHub repository. There is always going to be a way to manually add lines, text, etc to any plot - difficult to cater for all end use-cases.

ADD REPLYlink written 25 days ago by Kevin Blighe63k

There now seems to be a solution:

ADD REPLYlink written 23 days ago by Kevin Blighe63k
gravatar for sd.gamboa.t
23 days ago by
sd.gamboa.t50 wrote:

The solution is to upgrade to the version 2.3.2 (last version as for July 15, 2020), which is hosted on github by the author of the package:

ADD COMMENTlink modified 23 days ago by genomax87k • written 23 days ago by sd.gamboa.t50
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 707 users visited in the last hour