Description Usage Arguments Value Author(s) Examples
drawing phylogenetic trees from list of phylo objects
1 2 3 4 5 6 7 8 9 |
data |
a list of phylo objects or any object with an as.phylo and fortify method |
mapping |
aesthetic mapping |
layout |
one of 'slanted', 'rectangluar', 'fan', 'circular' or 'radial' (default: 'slanted') |
tip.order |
the order of the tips by a character vector of taxa names; or an integer, N, to order the tips by the order of the tips in the Nth tree; 'mds' to order the tips based on MDS of the path length between the tips; or 'mds_dist' to order the tips based on MDS of the distance between the tips (default: 'mds_dist') |
align.tips |
TRUE to align trees by their tips and FALSE to align trees by their root (default: TRUE) |
jitter |
deviation to jitter tips |
... |
additional parameters passed to fortify, ggtree and geom_tree |
tree layer
Yu Guangchuang, Bradley R. Jones
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | require(ape)
require(dplyr)
# Plot mutliple trees with aligned tips
trees <- list(read.tree(text="((a:1,b:1):1.5,c:2.5);"), read.tree(text="((a:1,c:1):1,b:2);"));
ggdensitree(trees) + geom_tiplab()
# Plot multiple trees with aligmned tips with tip labls and separate tree colors
trees.fort <- list(trees[[1]] %>% fortify %>% mutate(tree="a"), trees[[2]] %>% fortify %>% mutate(tree="b"));
ggdensitree(trees.fort, aes(colour=tree)) + geom_tiplab(colour='black')
# Generate example data
set.seed(1)
trees <- rmtree(5, 10)
time.trees <- lapply(1:length(trees), function(i) {
tree <- trees[[i]]
tree$tip.label <- paste0("t", 1:10)
dates <- estimate.dates(tree, 1:10, mu=1, nsteps=1)
tree$edge.length <- dates[tree$edge[, 2]] - dates[tree$edge[, 1]]
fortify(tree) %>% mutate(tree=factor(i, levels=as.character(1:10)))
})
# Plot multiple trees with aligned tips from muliple time points
ggdensitree(time.trees, aes(colour=tree), tip.order=paste0("t", 1:10)) + geom_tiplab(colour='black')
# Read example data
trees <- read.tree(system.file("examples", "ggdensitree_example.tree", package="ggtree"))
# Compute OTU
grp <- list(A = c("a.t1", "a.t2", "a.t3", "a.t4"), B = c("b.t1", "b.t2", "b.t3", "b.t4"), C = c("c.t1", "c.t2", "c.t3", "c.t4"))
trees <- lapply(trees, groupOTU, grp)
# Plot multiple trees colored by OTU
ggdensitree(trees, aes(colour=group), alpha=1/6) + scale_colour_manual(values=c("black", "red", "green", "blue"))
|
Registered S3 method overwritten by 'treeio':
method from
root.phylo ape
ggtree v2.4.1 For help: https://yulab-smu.top/treedata-book/
If you use ggtree in published research, please cite the most appropriate paper(s):
[36m-[39m Guangchuang Yu. Using ggtree to visualize data on tree-like structures. Current Protocols in Bioinformatics, 2020, 69:e96. doi:10.1002/cpbi.96
[36m-[39m Guangchuang Yu, Tommy Tsan-Yuk Lam, Huachen Zhu, Yi Guan. Two methods for mapping and visualizing associated data on phylogeny using ggtree. Molecular Biology and Evolution 2018, 35(12):3041-3043. doi:10.1093/molbev/msy194
[36m-[39m Guangchuang Yu, David Smith, Huachen Zhu, Yi Guan, Tommy Tsan-Yuk Lam. ggtree: an R package for visualization and annotation of phylogenetic trees with their covariates and other associated data. Methods in Ecology and Evolution 2017, 8(1):28-36. doi:10.1111/2041-210X.12628
Loading required package: ape
Attaching package: ‘ape’
The following object is masked from ‘package:ggtree’:
rotate
Loading required package: dplyr
Attaching package: ‘dplyr’
The following objects are masked from ‘package:stats’:
filter, lag
The following objects are masked from ‘package:base’:
intersect, setdiff, setequal, union
Warning message:
`mutate_()` is deprecated as of dplyr 0.7.0.
Please use `mutate()` instead.
See vignette('programming') for more help
This warning is displayed once every 8 hours.
Call `lifecycle::last_warnings()` to see where this warning was generated.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.