34 Visualising phylogenies with ggtree
- Visualise and annotate a S. pneumoniae phylogenetic tree with the R library ggtree.
34.1 Plotting phylogenetic trees with R
Plotting phylogenetic trees with ggtree
in R offers a powerful and flexible approach for visualizing evolutionary relationships. The ggtree
package, built on the ggplot2 framework, enables the creation of complex and highly customizable phylogenetic tree plots. With ggtree
, users can easily manipulate tree layouts, annotate nodes and branches, and incorporate additional data layers such as heatmaps or bar charts. The package supports various tree formats, including Newick, Nexus, and PhyloXML, making it versatile for different datasets. Researchers can enhance their plots with a wide array of aesthetic options, such as color coding by clade, adding tip labels, and highlighting specific evolutionary events or traits. This flexibility makes ggtree
an essential tool for evolutionary biologists and bioinformaticians, facilitating the clear and informative presentation of phylogenetic data.
- Copy the preprocessed
sero1.treefile
to the analysis directory so that it’s in the same location aspneumo_metadata.tsv
. - Open the script
06-plot_phylogeny.R
in thescripts
directory in RStudio. - Edit the script so it points to the
sero1.treefile
andpneumo_metadata.tsv
files in the analysis directory. - Run the script to generate the annotated phylogenetic tree.
- We copied
sero1.treefile
to the analysis directory:
cp preprocessed/iqtree/sero1.treefile .
- We edited the script to point to the location of the metadata and tree files:
<- read_tsv("../pneumo_metadata.tsv")
metadata
<- read.tree("../sero1.treefile") pneumo_phylogeny
- We ran the script to generate a rooted phylogenetic tree:
34.2 Summary
- ggtree is a highly customisable R package for generating publication quality images of phylogenetic trees.