KlausVigo / phangorn

Phylogenetic analysis in R
http://klausvigo.github.io/phangorn/
203 stars 38 forks source link

acctran overestimates branch lengths #118

Closed kbhoehn closed 3 years ago

kbhoehn commented 3 years ago

Hello - thanks for fixing the previous issues with pratchet. I've installed the latest version and have been able to get tree topologies without errors. However, I've also noticed strange behavior from acctran, in which it appears to overestimate the the number mutations in the tree. For instance, using the attached dataset with the following code:

library(phangorn)
data <- readRDS("test_data.rds")
tree <- pratchet(data,trace=FALSE)
tree <- acctran(ape::multi2di(tree,resolve_random=FALSE),data)
print(parsimony(tree, data))
print(sum(tree$edge.length))

Gives a parsimony score of 103, but a sum of branch lengths from acctran of 167. I repeated this with phangorn_2.5.5 and ape_5.4-1, and both values equal 103, which makes sense. The tree topologies inferred are also different between phangorn versions, but both are equally parsimonious (103). This suggests to me that some change between the versions has led acctran to find sub-optimal branch lengths. I've replicated this pattern in other trees as well, so it appears to be a general behavior.

test_data.zip

KlausVigo commented 3 years ago

Hi @kbhoehn, I look into this. It seems it works for some trees, but not for yours.

KlausVigo commented 3 years ago

Hi @kbhoehn, it took me some time and only one line to figure this out 5514200bf8b64f558e48ba97b0f574c7fbcb441f . Thanks for reporting. Should work now. Klaus

kbhoehn commented 3 years ago

That seemed to fix it - thanks!