Written and maintained by CASRAI Editorial Board
Last updated
ggtree is a Bioconductor package for R that draws phylogenetic trees and other tree-like structures with ggplot2 and lets you layer annotation data onto them. This page is for researchers and analysts who already have a tree (a Newick file or output from a tree-building program) and need to install ggtree, produce a labelled figure, and report it reproducibly. It was checked against the Bioconductor package page and the package author’s book, Data Integration, Manipulation and Visualization of Phylogenetic Trees, on 2026-11-08.
What ggtree is used for in research
The Bioconductor description says ggtree “extends the ggplot2 plotting system which implemented the grammar of graphics” and “is designed for visualization and annotation of phylogenetic trees and other tree-like structures with their annotation data.” In practice that means a tree is drawn as a ggplot2 object, so labels, tip points, colours, scale bars and themes are added with the same + layer syntax used for any other ggplot2 figure.
ggtree displays trees; it does not build them. Inference (alignment, model selection, bootstrap or other support values) is done in other software, and ggtree is used afterwards to present the result. If you still need to build a tree, start with how to make a phylogenetic tree or the IQ-TREE guide, and see rooting a phylogenetic tree and what a clade is for the vocabulary used below.
| Fact (as of 2026-11-08) | Value | Source |
|---|---|---|
| Package title | ggtree: an R package for visualization of tree and annotation data | Bioconductor package page |
| Current Bioconductor release listed | 3.23, ggtree version 4.2.1 | Bioconductor package page |
| In Bioconductor since | release 3.1 (R 3.2) | Bioconductor package page |
| Licence | Artistic-2.0 | Bioconductor package page |
| R requirement | R (>= 4.2.0) | Bioconductor package page |
| Authors / maintainer | Guangchuang Yu (author, creator, maintainer), Tommy Tsan-Yuk Lam, Shuangbin Xu | Bioconductor package page |
| Key imports | ape, ggplot2 (>= 4.0.0), tidytree, treeio (>= 1.8.0) | Bioconductor package page |
Versions change with each Bioconductor release, so confirm the version on the package page before quoting it in a methods section, or record the one you actually used with packageVersion("ggtree").
Install ggtree (official source)
ggtree is distributed through Bioconductor, not installed with a plain install.packages("ggtree"). The Bioconductor page gives this install code:
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("ggtree")
Load it with library(ggtree). For file import (BEAST, NHX, CodeML and others) the companion package treeio is used: library(treeio). Bundled documentation is opened with browseVignettes("ggtree"), and bug reports go to the project’s GitHub issue tracker at github.com/YuLab-SMU/ggtree/issues.
Step-by-step: draw and annotate a tree
These steps use the commands shown in the author’s book. The first tree is a small Newick string given in the book itself, so you can run it without any data file.
- Load the package and read a tree.
library(ggtree) nwk <- '(((((((A:4,B:4):6,C:5):8,D:6):3,E:21):10,((F:4,G:12):14,H:8):13):13,((I:5,J:2):30,(K:11,L:11):2):17):4,M:56);' tree <- read.tree(text = nwk)For your own Newick file, pass the file path instead:
read.tree("my_tree.nwk"). - Draw the tree.
ggtree(tree)is short forggplot(tree) + geom_tree() + theme_tree(). The default layout is rectangular. - Label the tips.
ggtree(tree) + geom_tiplab(size = 3, color = "purple"). Addgeom_tippoint()to mark tips with points (colour, shape and size can be set). - Add a scale bar.
ggtree(tree) + geom_treescale(x = 0, y = 45, width = 1). Callinggeom_treescale()with no arguments uses defaults. - Or add a full x-axis for time-scaled trees.
ggtree(tree) + theme_tree2(). - Change the layout if the tree is large. Use the
layoutargument:ggtree(tree, layout = "circular"),ggtree(tree, layout = "fan", open.angle = 120),"equal_angle"or"daylight". The book also lists"roundrect","slanted"and"ellipse". For circular tip labels, rotate them withgeom_tiplab(aes(angle = angle)). - Show topology only.
ggtree(tree, branch.length = "none")draws a cladogram in which branch lengths are ignored. - Highlight or label a clade. The book names
geom_hilight()for highlighting clades with a rectangle andgeom_cladelab()for annotating a selected clade with a bar and text label. Both take the clade’s internal node number; see the book’s annotation chapters for the arguments before using them in a figure. - Save. Because the result is a ggplot2 object,
ggsave("tree.pdf", width = 6, height = 6)works as for any ggplot2 figure.
Reading other tree formats with treeio
treeio “serves as an infrastructure” for importing phylogenetic data into R; its parsers return treedata objects holding a tree plus its associated data. The book shows read.beast() for BEAST output, read.nhx() for NHX trees and read.codeml() for CodeML output. A BEAST tree can be plotted with branch lengths replaced by a rate variable: ggtree(beast_tree, branch.length = "rate") + theme_tree2(). To overlay many trees (for example posterior samples), the book uses ggdensitree(btrees, alpha = .3, colour = "steelblue").
Output and how to read it
- Horizontal distance means branch length only on a phylogram. In the default rectangular layout the horizontal axis carries branch length; vertical spacing carries no information. With
branch.length = "none"(a cladogram) only the branching order is meaningful. - The scale bar is in the tree’s own units. What the units are (substitutions per site, time) depends on the program that produced the tree, not on ggtree. State the units in the figure legend.
- ggtree does not compute support. Bootstrap or posterior support values appear only if they are already stored in the tree file; ggtree shows them, it does not estimate them. Say in the methods which software produced the tree and the support values.
- Layout changes the picture, not the tree. Rectangular, circular, fan and unrooted layouts (equal-angle, daylight) are different drawings of the same topology. The unrooted layouts do not show a root.
Citing and reporting
The Bioconductor page recommends citation("ggtree") for the current citation text and lists the paper by Yu et al. (2017) in Methods in Ecology and Evolution, doi:10.1111/2041-210X.12628. For reproducibility, record the Bioconductor release, the ggtree and treeio versions (packageVersion() or sessionInfo()) and the R version.
Troubleshooting
| Symptom | Likely cause (documented requirement) | What to do |
|---|---|---|
package 'ggtree' is not available after install.packages("ggtree") |
ggtree is hosted on Bioconductor | Install through BiocManager::install("ggtree") as above |
| Install fails or Bioconductor offers an older ggtree | Current ggtree depends on R (>= 4.2.0) | Check R.version.string and upgrade R if it is older |
| Errors on load that mention ggplot2 or treeio versions | ggtree imports ggplot2 (>= 4.0.0) and treeio (>= 1.8.0) | Update dependencies, ideally with BiocManager::install() so versions stay consistent with the Bioconductor release |
| Circular tip labels overlap or sit upside down | Labels need rotation in polar layouts | Use geom_tiplab(aes(angle = angle)) |
| No x-axis or scale on the plot | ggtree() uses theme_tree(), which has no axis |
Add theme_tree2() or geom_treescale() |
| Behaviour differs from a tutorial | Tutorials may predate the current release | Check the vignettes for your installed version with browseVignettes("ggtree"); report bugs on the GitHub issue tracker |
Free alternatives and related tools
| Tool | What its own documentation says | Where it differs from ggtree |
|---|---|---|
| ape (R package) | Imported by ggtree for tree handling; provides tree reading and base-graphics plotting | Base R graphics rather than the ggplot2 layer system |
| FigTree | “A graphical viewer of phylogenetic trees and … a program for producing publication-ready figures” (project README on GitHub); the README notes it has been superseded by PearTree | Stand-alone viewer, not scriptable inside an R analysis |
| iTOL (Interactive Tree Of Life) | “An online tool for the display, annotation and management of phylogenetic and other trees” (itol.embl.de) | Browser-based; access modes and subscription terms are set out on the iTOL site |
Choose by workflow: ggtree when the figure should be regenerated by a script as part of an R analysis; a viewer when you are exploring a single tree interactively.
Frequently asked questions
What is ggtree?
An R package, distributed by Bioconductor under the Artistic-2.0 licence, that visualises and annotates phylogenetic trees and other tree-like structures using the ggplot2 grammar of graphics.
How do I install ggtree?
Install BiocManager from CRAN if needed, then run BiocManager::install("ggtree"). It requires R 4.2.0 or later on the current Bioconductor release.
Can ggtree build a phylogenetic tree?
No. It reads trees produced elsewhere (through read.tree() or treeio parsers) and draws them. Use dedicated inference software to build the tree.
How do I draw a circular tree?
Set layout = "circular" in ggtree(), for example ggtree(tree, layout = "circular"), and add geom_tiplab(aes(angle = angle)) for rotated tip labels.
How do I cite ggtree?
Run citation("ggtree") in R for the current citation, and cite the package version you used.
Sources
- Bioconductor, ggtree package page, bioconductor.org/packages/release/bioc/html/ggtree.html (read 2026-11-08).
- Yu G. Data Integration, Manipulation and Visualization of Phylogenetic Trees, chapters 2 and 4, yulab-smu.top/treedata-book/ (read 2026-11-08).
- FigTree README, github.com/rambaut/figtree (read 2026-11-08).
- Interactive Tree Of Life, itol.embl.de (read 2026-11-08).







