ggtree provides many helper functions for manupulating phylogenetic trees and make it easy to explore tree structure visually.
Here, as examples, I used
ggtree to draw capital character
C, which are first letter of my name :-).
To draw a tree in such shape, we need
fan layout (
circular layout with open angle) and then rotating the tree to let the open space on the correct position. Here are the source codes to produce the
C shapes of tree. I am thinking about using the
G shaped tree as
ggtree logo. Have fun with
OutbreakTools implements basic tools for the analysis of Disease Outbreaks.
obkData to store case-base outbreak data. It also provides a function,
plotggphy, to visualize such data on the phylogenetic tree.
library(OutbreakTools) data(FluH1N1pdm2009) attach(FluH1N1pdm2009) x <- new("obkData", individuals = individuals, dna = FluH1N1pdm2009$dna, dna.individualID = samples$individualID, dna.date = samples$date, trees = FluH1N1pdm2009$trees) plotggphy(x, ladderize = TRUE, branch.unit = "year", tip.color = "location", tip.size = 3, tip.alpha = 0.75)
ggtree can parse many software outputs and the evolution evidences inferred by these software can be used directly for tree annotation. ggtree not only works as an infrastructure that enables evolutionary data that inferred by commonly used software packages to be used in R, but also serves as a general tree visualization and annotation tool for the R community as it supports many S3/S4 objects defined by other R packages.
phyloseq class defined in the phyloseq package was designed for microbiome data.
phyloseq package implemented
plot_tree function using
ggplot2. Although the function was implemented by
ggplot2 and we can use
scale_color_manual etc for customization, the most valuable part of
ggplot2, adding layer, is missing.
plot_tree only provides limited parameters to control the output graph and it is hard to add layer unless user has expertise in both
We are happy to announce that
ggtree supports interactive tree annotation/manipulation by implementing an
identify method. Users can click on a node to highlight a clade, to label or rotate it etc.
Here is an example of highlighting clades using
I extended the subview function to support embed image file in a
set.seed(123) d = data.frame(x=rnorm(10), y=rnorm(10)) imgfile <- tempfile(, fileext=".png") download.file("https://avatars1.githubusercontent.com/u/626539?v=3&u=e731426406dd3f45a73d96dd604bc45ae2e7c36f&s=140", destfile=imgfile, mode='wb') p = ggplot(d, aes(x, y)) subview(p, imgfile, x=d$x, y=d$y) + geom_point(size=5)
Phylip is also a widely used tree format, which contains taxa sequences with Newick tree text.
ggtree, we can use
read.phylip() function to parse the file and use
ggtree() to visualize the tree.
This is a question from
ggtree user. In
phytools, it’s easy to label edge using the
set.seed(1) tr = rtree(30) library(ape) plot(tr, main="ape") edgelabels()