要在进化树上标记取样的样本
总样本的进化树,这个是随便构造的
library(ggtree)
library(phytools)
tree <- read.tree("data/20220829/fig2.nwk")
plotTree(tree)
假如我选了 "A","H","J" 这三个样本要测序
获取这这三个样本的 node label
lapply(c("A","H","J"),grep,tree$tip.label) -> tips
获取这三个样本的所有父节点
lapply(tips,phangorn::Ancestors,x=tree,type="all") %>%
unlist() %>% unique() -> parents
c(tips %>% unlist(),parents) -> nodes
## 可以把根节点去掉
setdiff(nodes,Ntip(tree)+1) -> nodes
在进化树上进行标记
paintBranches(tree,
nodes,
state = "1",
anc.state = "0") -> tree03
画进化树
cols<-setNames(c("gray","black"),0:1)
plot(tree03,
lend=1,
add=TRUE,
split.vertical=TRUE,
color=cols)
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有