安装

1
2
3
4
if (!requireNamespace("BiocManager", quietly = TRUE))
  install.packages("BiocManager")
BiocManager::install("treeio", version = "3.8")
BiocManager::install("ggtree", version = "3.8")

输入

ggtree可以直接文本输入Newick tree

1
2
3
4
library(ggtree)
tree_text <- "(((((cow, (whale, dolphin)), (pig2, boar)), camel), fish), seedling);"
x <- read.tree(text=tree_text)

也可使用treeio直接入其他程序的标准输出

1
2
library(treeio)
read.r8s()

注意,read.r8s()一次性读入r8s 标准输出中的3种树,

参考来源

https://yulab-smu.github.io/treedata-book/