|||
dir() # 查看工作目录[1] "example_corynebacteria.tree.nwk" [2] "example_corynebacteria.tree.reroot.xml" library(ggplot2) # 加载ggplot2 library(ggtree) # 加载 ggtreetree=read.tree("example_corynebacteria.tree.nwk") # 读取nwk文件 data=fortify(tree) tregraph=ggtree(tree, layout="rectangular", size=0.8, col="deepskyblue3") + # 树体:树文件、树形、粗细、颜色 geom_tiplab(size=3, color="purple4", hjust=-0.05) + # 枝名:大小、颜色、高度 geom_tippoint(size=1.5, color="deepskyblue3") + # 端点:大小、颜色 geom_nodepoint(color="orange", alpha=1/4, size=2) + # 末节点:颜色、透明度、大小 theme_tree2() + # x轴标尺 xlim(NA, max(data$x)*1.3) # x轴宽度 pdf("tregraph.pdf") tregraph dev.off()
转自 https://www.jianshu.com/p/c77fcd4f4111
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-12-9 00:33
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社