Bootstrapped tree values differ from PAST

你。 提交于 2019-12-11 07:55:40

问题


When I compute a bootstrapped tree in R I get different values to when I use PAST (http://folk.uio.no/ohammer/past/). How can I get the output to match from the two programs?

Here's what I'm doing in R (data below):

library("ape")
library("phytools")
library("phangorn")
library("cluster")

# compute neighbour-joined tree
f <- function(xx) nj(daisy(xx))
nj_tree <- f(tab) 
nj_tree_root <- root(nj_tree, 1, r = TRUE)

## bootstrap
# bootstrap values do not match PAST output - why is that?

nj_tree_root_boot <- boot.phylo(nj_tree, FUN = f, tab,  rooted = TRUE)

# Are bootstrap values stable?
for (i in 1:10){
  print(boot.phylo(nj_tree, FUN = f, tab,  rooted = TRUE, quiet = TRUE))
}
# yes, they seem ok

# plot tree with bootstrap values
plot(nj_tree_root, use.edge.length = FALSE)
nodelabels(nj_tree_root_boot, adj = c(1.2, 1.2), frame = "none")

Typical output for the bootstrap is [1] 100 6 39 27 23 57 53 75 71 and here's the plot (far LHS value should be 100, it was cropped somehow):

I transform the data to send it to PAST like so:

tab1 <- t(apply(tab, 1, as.numeric))
write.table(tab1, "tab.txt")

In PAST I open the tab.txt file, do multivariate -> cluster -> Neighbour Joining with Euclidian and 100 bootstrap replications, using an outgroup. From PAST I get this plot:

And the values are very different. What do I need to do with R to make the output match that from PAST? Is PAST wrong?

The data:

tab <- structure(list(X1 = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
                                1L, 2L, 2L), .Label = c("0", "1"), class = "factor"), X2 = structure(c(1L, 
                                                                                                       1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L), .Label = c("0", "1"), class = "factor"), 
               X3 = structure(c(1L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 
                                2L), .Label = c("0", "1"), class = "factor"), X4 = structure(c(2L, 
                                                                                               2L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 2L), .Label = c("0", 
                                                                                                                                                   "1"), class = "factor"), X5 = structure(c(1L, 1L, 1L, 1L, 
                                                                                                                                                                                             2L, 2L, 1L, 2L, 1L, 2L, 1L), .Label = c("0", "1"), class = "factor"), 
               X6 = structure(c(1L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 
                                2L), .Label = c("0", "1"), class = "factor"), X7 = structure(c(1L, 
                                                                                               2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L), .Label = c("0", 
                                                                                                                                                   "1"), class = "factor"), X8 = structure(c(2L, 2L, 2L, 2L, 
                                                                                                                                                                                             1L, 1L, 2L, 2L, 1L, 2L, 2L), .Label = c("0", "1"), class = "factor"), 
               X9 = structure(c(1L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 
                                1L), .Label = c("0", "1"), class = "factor"), X10 = structure(c(1L, 
                                                                                                1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L), .Label = c("0", 
                                                                                                                                                    "1"), class = "factor"), X11 = structure(c(1L, 2L, 1L, 1L, 
                                                                                                                                                                                               1L, 1L, 2L, 2L, 2L, 1L, 2L), .Label = c("0", "1"), class = "factor"), 
               X12 = structure(c(2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
                                 1L), .Label = c("0", "1"), class = "factor"), X13 = structure(c(2L, 
                                                                                                 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("0", 
                                                                                                                                                     "1"), class = "factor"), X14 = structure(c(2L, 2L, 1L, 1L, 
                                                                                                                                                                                                1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("0", "1"), class = "factor"), 
               X15 = structure(c(2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
                                 2L), .Label = c("0", "1"), class = "factor"), X16 = structure(c(2L, 
                                                                                                 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L), .Label = c("0", 
                                                                                                                                                     "1"), class = "factor"), X17 = structure(c(2L, 1L, 1L, 1L, 
                                                                                                                                                                                                1L, 1L, 1L, 2L, 1L, 1L, 2L), .Label = c("0", "1"), class = "factor"), 
               X18 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 
                                 1L), .Label = c("0", "1"), class = "factor"), X19 = structure(c(1L, 
                                                                                                 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L), .Label = c("0", 
                                                                                                                                                     "1"), class = "factor"), X20 = structure(c(1L, 1L, 1L, 1L, 
                                                                                                                                                                                                1L, 1L, 1L, 1L, 1L, 2L, 2L), .Label = c("0", "1"), class = "factor"), 
               X21 = structure(c(1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 
                                 1L), .Label = c("0", "1"), class = "factor"), X22 = structure(c(2L, 
                                                                                                 2L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 2L), .Label = c("0", 
                                                                                                                                                     "1"), class = "factor"), X23 = structure(c(1L, 1L, 2L, 1L, 
                                                                                                                                                                                                1L, 1L, 1L, 2L, 1L, 2L, 2L), .Label = c("0", "1"), class = "factor"), 
               X24 = structure(c(1L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 
                                 2L), .Label = c("0", "1"), class = "factor"), X25 = structure(c(1L, 
                                                                                                 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 1L), .Label = c("0", 
                                                                                                                                                     "1"), class = "factor"), X26 = structure(c(1L, 1L, 2L, 2L, 
                                                                                                                                                                                                2L, 1L, 2L, 2L, 1L, 1L, 1L), .Label = c("0", "1"), class = "factor")), .Names = c("X1", 
                                                                                                                                                                                                                                                                                  "X2", "X3", "X4", "X5", "X6", "X7", "X8", "X9", "X10", "X11", 
                                                                                                                                                                                                                                                                                  "X12", "X13", "X14", "X15", "X16", "X17", "X18", "X19", "X20", 
                                                                                                                                                                                                                                                                                  "X21", "X22", "X23", "X24", "X25", "X26"), row.names = c("a", 
                                                                                                                                                                                                                                                                                                                                           "b", "c", "d", "e", "f", "g", "h", "i", "j", "k"), class = "data.frame")

回答1:


After much searching around, it turn out the answer is in the ape package FAQ Q14:

I have done a bootstrap analysis with boot.phylo but some bootstrap values seem at the wrong place after rooting the tree. This is because the bootstrap values are counted as the frequencies of clades, and not as actual bipartitions. So these values are really associated to the nodes, not to the edges. A consequence is that some of the bootstrap values are lilely to loose their meaning after (re)rooting the tree since this will affect the definition of the clades in the tree. A simple solution is to include the rooting process in the definition of the function FUN that is given as argument to boot.phylo. Obviously the estimated tree must also be rooted in the same way before doing the bootstrap. In this situation, it is more convenient to define FUN beforehand. An example code would be:

outgroup <- 1 # may be several tips, numeric or tip labels
foo <- function(xx) root(nj(dist.dna(xx)), outgroup)
tr <- foo(X) # X is the matrix of DNA sequences
bp <- boot.phylo(tr, X, foo)
plot(tr)
nodelabels(bp) # will have "100" at the root

In the specific case of my question:

nj_tree_root_boot <- boot.phylo(nj_tree, FUN = f, tab,  rooted = TRUE)
plot(nj_tree_root, use.edge.length = FALSE)
nodelabels(nj_tree_root_boot, adj = c(1.2, 1.2), frame = "none")

Which matches the PAST output quite well.



来源:https://stackoverflow.com/questions/27526522/bootstrapped-tree-values-differ-from-past

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!