Provides functions to render ‘ggtree’ objects as interactive graphics using the ‘ggiraph’ package. Adds support for interactive tooltips, data point selection, and click events to phylogenetic trees.
Shuangbin Xu and Guangchuang Yu
School of Basic Medical Sciences, Southern Medical University
#It can be installed via GitHub.
if (!requireNamespace("remotes", quietly=TRUE))
install.packages("remotes")
remotes::install_github("YuLab-SMU/iggtree")
library(ggplot2)
library(ggiraph)
library(iggtree)
# Note: the ggtree should be re-installed via
# remotes::install_github("xiangpin/ggtree@use_iggtree_ggiraph")
library(ggtree)
set.seed(123)
tr <- rtree(20)
dt <- data.frame(id = c(36, 38), type=c("A", "B"))
p <- ggtree(
tr,
mapping = aes(
tooltip = round(branch.length, 2),
data_id = node
)
) +
geom_hilight(
data = dt,
mapping = aes(
node = id,
fill = type,
tooltip = paste0("clade of node ", id),
data_id = type
),
to.bottom = TRUE
)
girafe(ggobj = p)
We welcome any contributions! By participating in this project you agree to abide by the terms outlined in the Contributor Code of Conduct.