Closed pawelqs closed 2 years ago
Hi, I suggest you build a separate function that returns the tree from your matrix of 0's and 1's, eg:
f <- function(x) {
x <- phyDat(x, type = "USER", levels = 0:1)
hamming_dist <- dist.hamming(x)
NJ(hamming_dist)
}
Then you get your tree with f(X)
, for instance with some simulated data:
n <- 10
p <- 10
X <- matrix(sample(0:1, n * p, TRUE), n, p)
rownames(X) <- paste0("Sp", 1:n)
tr <- f(X)
The bootstrap is done with:
boot.phylo(tr, X, f)
If you prefer to bootstrap the "phyDat" data, ?bootstrap.phyDat
has an example with a parsimony tree.
Hi!
If you prefer to bootstrap the "phyDat" data,
?bootstrap.phyDat
has an example with a parsimony tree.
Actually bootstrapping for parsimony might not be necessary any more. pratchet
with the argument perturbation = "ratchet"
, which is the default, implicitly does bootstrapping. I should change this example and highlight it more. Set the argument minit
as the minimal number of bootstrap samples, maximum is given by the maxit
argument. Note to myself: I should change the default of minit
.
tree <- pratchet(x, minit=100)
and the tree will have bootstrap values assigned to it.
Best, Klaus
Hi!
Finally, I did bootstrapng using bootstrap.phyDat()
.
What is th pratchet()
function? I cannot find this function in phangorn/ape packages.
Best, Paweł
Hi @pawel125,
pratchet()
is in phangorn
, the help page is together with all the other parsimony functions. It is a more fancy version of optim.parsimony
doing some additional perturbations of the tree during the search. This might result in better trees and does implicit some bootstrapping, but is of course much slower.
Best,
Klaus
Ok, I found it. Thanks! Paweł
Hi!
I have encountered problem when trying to bootstrap my phylogenetic tree using the following code:
parsimony_trees$NJ
is a phylogenetic tree obtained with hamming.distance %>% NJ %>% phyDat flow, but I skipped las lines here to simplify the function while debugging this error.I found that the error is thrown by
ans <- .Call(bitsplits_multiPhylo, x, n, nr)
line inbitsplits()
function, but I cannot find the definition ofbitsplits_multiPhylo
to dig it deeper.What might be the problem?
Best, Paweł