问题描述
我正在尝试创建一棵树来计算系统发育信号并进行系统发育广义最小二乘分析。然而,我用于此分析的文献树中缺少我的一些分类群,主要是因为这些分类群在父研究时被认为是包含的分类群的亚种,后来被提升到物种等级。因此,我确切地知道这些分类群需要去哪里(它们以前包含的分类群的姐妹),但我无法将它们添加到树中。
library(ape)
library(phytools)
orig_tree<-rtree(n=20)
tip<-list(edge=matrix(c(2,1),1,2),tip.label="t6a",edge.length=1.0,Nnode=1)
class(tip)<-"phylo"
btree<-bind.tree(orig_tree,tip,where=22)
plottree(btree)
然而,这有几个问题。一方面,这通过创建多分法添加了新的分类群,然后我必须使用 bifurcatr
之类的包随机解析。然而,这对于已知的系统发育来说是不准确的。这不是真正的多分体,在这种情况下的拓扑结构是已知的:t6a 和 t6 是姐妹分类群。如果我尝试将任何化石分类群添加到数据中,这也是一个问题,因为如果化石靠近两个主要进化枝的基部,则随机解析多聚体可能会将其作为错误进化枝的基本成员。
另外,我使用节点数可变的树,因为在某些情况下,某些分类群的数据丢失,我必须运行数据的子集,而忽略分类群。因此,树之间的 then 节点的数量并不总是相同的。所以我想找出一种方法来添加分类群,并且不依赖于特定树中特定节点的数量。
我想知道是否有任何方法可以通过将它们作为姐妹分类群绑定到已知尖端而不是在内部节点创建多分体来将分类群添加到树中?这将允许我更容易将分类群绑定到树上,因为有一个一致的点,无论树的长度如何(作为任何尖端的姐妹都有特定标签)。
解决方法
您可以通过将提示 ID 提供给 ape::bind.tree(...,where = my_tip_id)
来直接将树绑定到提示上(而不是节点上)。这将删除提示并将其替换为您要添加的新树。我编写了一个小函数,可以自动将樱桃(或多聚体)添加到树中:
## Function for adding a cherry to a tree where a single tip was before
add.cherry <- function(tree,tip,new.tips) {
## Find the edge leading to the tip
tip_id <- match(tip,tree$tip.label)
## Create the new cherry
tree_to_add <- ape::stree(length(c(tip,new.tips)))
## Naming the tips
tree_to_add$tip.label <- c(tip,new.tips)
## Add 0 branch length
tree_to_add$edge.length <- rep(0,Nedge(tree_to_add))
## Binding both trees
return(bind.tree(tree,tree_to_add,where = tip_id))
}
## Adding a new sister taxon to t6 (with a 0 branch length)
new_tree <- add.cherry(orig_tree,tip = "t6",new.tips = "t6a")
plot(new_tree)
## Adding a bunch of sister taxa to t8
new_tree <- add.cherry(orig_tree,tip = "t8",new.tips = c("t8a","t8b","t8c"))
plot(new_tree)
如果需要,您可以将其应用到使用 for
循环修改的提示列表:
## List of four tips to modify
tips_to_modify <- list("t1","t3","t6","t8")
## List of tips to add to these four tips
tips_to_add <- list("t1a",c("t3.1","t3.2"),"t6a",c("t8a","t8c"))
## Adding the tips all together
new_tree <- orig_tree
for(one_tip in seq_along(tips_to_modify)) {
new_tree <- add.cherry(new_tree,tip = tips_to_modify[[one_tip]],new.tips = tips_to_add[[one_tip]])
}
plot(new_tree)
,
使用“TreeTools”函数 AddTip()
很容易实现这一点。
app.alert(Document.title)
下一版本的包将支持边长;直到这出现在 CRAN 上,您可以使用安装它
orig_tree <- ape::rtree(n = 20)
leaf_labelled_6 <- which(orig_tree$tip.label == 't6')
new_tree <- TreeTools::AddTip(orig_tree,leaf_labelled_6,'t6a')
。
我对 devtools::install_github('ms609/TreeTools')
的经验是,它有时会使树的内部节点编号混乱,从而导致某些下游功能出现问题。