A user reports the following problem (here):
I am using your anc.Bayes function in phytools with a nexus tree and continuous data. When I run the line "anc.Bayes(tree,data,ngen=10000,control=list())" I get an error message:
"Error in if (post.odds > runif(n = 1)) { : missing value where TRUE/FALSE needed"
I still have not identified the specific cause of this error, but the problem seems to be fixed by converting the input data (originally stored as a data frame) into a vector. Of course, as always, one has to be careful to preserve the species names which were row names in the data frame, and must be names in the vector.
I.e.,
# x is a data frame
x<-as.matrix(x)[,1] # now x is a named vector
result<-anc.Bayes(tree,x) # for instance
I hope this helps.
Hi Liam,
ReplyDeleteI have this issue while using contMap to map a continuous trait on a tree. I made sure that my trait is a vector (d) with species names, and even made up a fake a vector named with the species names to test. Here's what I get:
> contMap(arch_tree,d)
Error in while (x > trans[i]) { : missing value where TRUE/FALSE needed
For the same tree and trait vector, I get a different error with anc.Bayes:
anc.Bayes(arch_tree,d)
Error in solve.default(C) :
system is computationally singular: reciprocal condition number = 3.79057e-21
There should be no singularity for my fake trait vector drawing values from a uniform distribution, so I'm not sure what's going on.
Help please?
Thanks!
Hi Deepa. Tough to figure this out without your data & tree; however, if I had to guess, I'd speculate that you may have zero-length internal branches in your tree (see here for more information). You can use the ape function multi2di to collapse zero-length internal branches. Let me know if this works - and feel free to email me again if it does not! All the best, Liam
Delete