Annotating phylogenetic tree with images using ggtree and ggimage

With ggimage, we are able to plot images using grammar of graphics. The layers defined in ggimage can be directly applied to ggtree to annotate phylogenetic tree using local/online image files.

ggtree seamlessly work with ggimage. The geom_tiplab and geom_nodelab can accept parameter of geom="image" to parse taxa labels as image files and use them to “label” the taxa using images instead of text strings. Here are some examples for demonstration.

Annotate tips

url <- paste0("",
x <- read.tree(paste0(url, "tree_boots.nwk"))
info <- read.csv(paste0(url, "tip_data.csv"))
p <- ggtree(x) %<+% info + xlim(NA, 6)
p + geom_tiplab(aes(image= imageURL), geom="image", offset=2, align=T, size=.16, hjust=0) +
    geom_tiplab(geom="label", offset=1, hjust=.5)

Annotate internal nodes

## example from
tree <-"")
phylopic_info <- data.frame(node = c(124, 113, 110, 96, 89, 70),
                            phylopic = c("7fb9bea8-e758-4986-afb2-95a2c3bf983d",
                            species = c("galagoids", "lemurs", "tarsiers",
                                        "cebids", "hominoids", "cercopithecoids"))
pg <- ggtree(tree)
pg %<+% phylopic_info + geom_nodelab(aes(image=phylopic), geom="phylopic", alpha=.5, color='steelblue')

d <- data.frame(node = c("70","89","96","110","113","124"),
                images = c("",
pg %<+% d + geom_nodelab(aes(image=images), geom="image")

Use image as background

pg + geom_phylopic(image="79ad5f09-cf21-4c89-8e7d-0c82a00ce728", size=Inf, alpha=.5, color='firebrick')

Here is another example that uses Tabikaeru (known as traveling frog, a popular mobile game) image to decorate a phylogenetic tree of frog, see reproducible source code on

Plea to against BMC
comments powered by Disqus