paternogbc / sensiPhy

R package to perform sensitivity analysis for comparative methods
http://onlinelibrary.wiley.com/doi/10.1111/2041-210X.12990/full
GNU General Public License v2.0
12 stars 4 forks source link

Problem with miss.phylo.d #189

Closed orlinst closed 3 years ago

orlinst commented 3 years ago

tree176.zip

function

Which function? e.g. tree_phylolm miss.phylo.d

Problem

briefly describe your issue here. I am using a nwk tree and a dataset that I have used many time with ape/caper/phytools etc, but when I try to run miss.phylo.d I get the following error: Error in if (round(ransocc[1], digits = 6) != round(physocc[1], digits = 6)) stop("Problem with character change calculation in phylo.d") : missing value where TRUE/FALSE needed

Reproducible example

I figured it does not like the tree somehow, but I cant figure out what is the issue. I have made it ultrametric (as there are some 0 branch lengths) but it still does not work. I am attaching the tree that still needs ultrametricising.

library(sensiPhy)
#### your code goes here 
miss.phylo.d(data, tree, binvar=Diet)
caterinap commented 3 years ago

Hi, thanks for reporting this! This error comes from the function caper::phylo.d that is used by miss.phylo.d It happens because there are NAs generated when the function uses caper::contrCalc (linear model using the crunch algorithm) and it seems to me that this is because some node depths are unknown. @paternogbc do you know why this might happen? Is it maybe related to the way that ape::multi2di solves the multichotomies? Here is a working example with some randomly generated data and the phylogeny uploaded above:

library(sensiPhy)
library(ape)
tree<-read.tree("~/tree176.nwk")
tree<-di2multi(tree)
data<-data.frame(Diet=sample(c("herbivore","carnivore",NA),replace=T,size=176),
                 BodySize=sample(1:100,replace=T,size=176))
row.names(data)<-tree$tip.label
DietNaSig<-miss.phylo.d(phy=tree, data, binvar=Diet)
orlinst commented 3 years ago

So far I have figured out that if I remove node.labels it works. I guess there is a different way of addressing this too hopefully?

paternogbc commented 3 years ago

Hi there! I am not 100% sure what really causes this Error besides that it comes from caper::phylo.d function. I will try to dig in caper code but perhaps it would be interesting to contact David Orme (the maintainer of the caper package). cheers

Em ter., 19 de jan. de 2021 às 00:23, Orlin notifications@github.com escreveu:

So far I have figured out that if I remove node.labels it works. I guess there is a different way of addressing this too hopefully?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/paternogbc/sensiPhy/issues/189#issuecomment-762511203, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACJRMOLEFAJEND5BQM4XTMLS2S7GLANCNFSM4WGYUDYA .

-- Gustavo Brant Paterno PhD | Open Science

Chair of Restoration Ecology | School of Life Sciences Technical University of Munich Emil-Ramann-Str. 6, 85354 Freising, Germany

email: paternogbc@gmail.com Site: https://gustavopaterno.com/ http://www.Raprendiz.wordpress.com Citations: https://scholar.google.com/citations?user=uNxyHMkAAAAJ&hl=pt-BR Research Gate: https://www.researchgate.net/profile/Gustavo_Paterno2 https://www.researchgate.net/profile/Gustavo_Paterno2 Github: https://github.com/paternogbc Skype: gustavopaterno Lattes: http://lattes.cnpq.br/3661227833522004