I am so excited to have this book published. The book is meant as a guide for data integration, manipulation and visualization of phylogenetic trees using a suite of R packages, tidytree, treeio, ggtree and ggtreeExtra. Hence, if you are starting to read this book, we assume you have a working knowledge of how to use R and ggplot2.
The development of the ggtree package started during my PhD study at the University of Hong Kong. I joined the State Key Laboratory of Emerging Infectious Diseases (SKLEID) under the supervision of Yi Guan and Tommy Lam. I was asked to provide assistance to modify the newick tree string to incorporate some additional information, such as amino acid substitutions, in the internal node labels of the phylogeny for visualization. I wrote an R script to do it and soon realized that most phylogenetic tree visualization software can only display one type of data through node labels. Basically, we cannot display two data variables at the same time for comparative analysis. In order to produce tree graphs displaying different types of branch/node associated information, such as bootstrap values and substitutions, people mostly relied on post-processing image software. This situation motivates me to develop ggtree. First of all, I think a good user interface must fully support the ggplot2 syntax, which allows us to draw graphs by superimposing layers. In this way, simple graphs are simple, and complex graphs are just a combination of simple layers, which are easy to generate.
After several years of development, ggtree has evolved into a package suite, including tidytree for manipulating tree with data using the tidy interface; treeio for importing and exporting tree with richly annotated data; ggtree for tree visualization and annotation and ggtreeExtra for presenting data with a phylogeny side-by-side for a rectangular layout or in outer rings for a circular layout. The ggtree is a general tool that supports different types of tree and tree-like structures and can be applied to different disciplines to help researchers presenting and interpreting data in the evolutionary or hierarchical context.
- Part I (Tree data input, output and manipulation) describes treeio package for tree data input and output, and tidytree package for tree data manipulation.
- Part II (Tree data visualization and annotation) introduces tree visualization and annotation using the grammar of graphic syntax implemented in the ggtree package. It emphasizes presenting tree-associated data on the tree.
- Part III (ggtree extensions) introduces ggtreeExtra for presenting data on circular layout trees and other extensions including MicrobiotaProcess and tanggle etc.
- Part IV (Miscellaneous topics) describes utilities provided by the ggtree package suite and presents a set of reproducible examples.
The R and core packages information when compiling this book is as follows:
##  "R version 4.1.2 (2021-11-01)"
## Attaching packages treedataverse 0.0.1
## ape 5.5 treeio 1.18.1
## dplyr 1.0.7 ggtree 3.2.1
## ggplot2 3.3.5 ggtreeExtra 1.4.1
## tidytree 0.3.6
The treedataverse is a meta package to make it easy to install and load core packages for processing and visualizing tree with data using the packages described in this book. The installation guide for treedataverse can be found in FAQ.
The datasets used in this book have three sources:
- Simulation data
- Datasets in the R packages
- Data downloaded from the Internet
In order to make the data downloaded from the Internet more accessible,
we packed the data in an R package,
TDbook, with detailed
documentation of the original source, including URL, authors, and
citation if the information is available. The
TDbook is available on
CRAN and can be installed using
Package names in this book are formatted as bold text (e.g.,
ggtree), and function
names are followed by parentheses (e.g.,
double-colon operator (
::) means accessing an object from a package.
Many people have contributed to this book with spelling and grammar corrections. I’d particularly like to thank Shuangbin Xu, Lin Li and Xiao Luo for their detailed technical reviews of the book, and Tiao You for designing the front cover of the book.
Many others have contributed during the development of the ggtree package suite. I would like to thank Hadley Wickham, for creating the ggplot2 package that ggtree relies on; Tommy Tsan-Yuk Lam and Yi Guan for being great advisors and supporting the development of ggtree during my PhD; Richard Ree for inviting me to catalysis meeting on phylogenetic tree visualization; William Pearson for inviting me to publish a protocol paper of ggtree in the Current Procotols in Bioinformatics journal; Shuangbin Xu, Yonghe Xia, Justin Silverman, Bradley Jones, Watal M. Iwasaki, Ruizhu Huang, Casey Dunn, Tyler Bradley, Konstantinos Geles, Zebulun Arendsee and many others who have contributed source code or given me feedback; and last, but not least, the members of the ggtree mailing list1, for providing many challenging problems that have helped improve the ggtree package suite.