简体   繁体   中英

Is it possible to add taxa to a phylogeny by binding them to sister taxa, rather than nodes?

I am trying to create a tree to calculate phylogenetic signal and conduct a phylogenetic generalized least squares analysis. However, some of my taxa are missing from the literature tree I am using for this analysis, mostly because these were taxa at the time of the parent study that were considered subspecies of included taxa have since been raised to species rank. As a result, I know exactly where these taxa need to go (sister to the taxon they were formerly included in), but I am having trouble adding them to the tree.

I have been adding taxa to my tree using the following code.

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)

However, there are several problems with this. On the one hand this adds new taxa by creating a polytomy that I then have to randomly resolve using a package like bifurcatr . However, this is inaccurate to the known phylogeny. This is not a true polytomy, the topology in this case is known: t6a and t6 are sister taxa. This is also a problem if I try to add any fossil taxa into the data, because if the fossil is near the base of two major clades randomly resolving the polytomy could place it as a basal member of the wrong clade.

Additionally I am using trees with variable numbers of nodes, because in some cases data is missing for certain taxa and I have to run subsets of the data with taxa omitted. Therefore, the numbers of then nodes are not always the same between trees. So I would like to figure out a way to add taxa that and is not dependent on the number of a specific node in a specific tree.

I was wondering if there was any way to add taxa to a tree by binding them as a sister taxa to a known tip, rather than creating a polytomy at an internal node? This would allow me to more easily bind taxa to the tree because there is a consistent point at which they can be bound regardless of the tree length (as the sister to whatever tip has a certain label).

You can directly bind your tree on a tip (rather than on a node) by supplying the tip id to ape::bind.tree(..., where = my_tip_id) . This will remove the tip and replace it by the new tree you want to add. I've written a small function that adds cherrys (or polytomies) automatically to a tree:

## 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)

If needed, you can apply this to a list of tips to modify using a for loop:

## 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", "t8b", "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)

This is simple to achieve using the 'TreeTools' function AddTip() .

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')

My experience of bind.tree() is that it can sometimes make a mess of the internal node numbering of trees, causing problems with certain downstream functions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM