khabbazian / l1ou

Detection of evolutionary shifts in Ornstein-Uhlenbeck models
GNU General Public License v2.0
19 stars 7 forks source link

Error in running estimate_shift_configuration - the condition has length > 1 #50

Closed niming2 closed 2 years ago

niming2 commented 2 years ago

I have a error when running estimate_shift_configuration (): Error in if (class(Y) != "matrix") { : the condition has length > 1 Even with the function example eModel <- estimate_shift_configuration(lizard$tree, lizard$Y) . Possibly because I'm in new R version 4.2.0?

trozelia commented 2 years ago

I hit the same issue! Would love to know if there are any fixes

lschmitz commented 2 years ago

Changing class(Y) != "matrix") to inherits(Y, "matrix") == FALSE in the source code might do the trick? class(Y) also returns "array", along with "matrix"

trozelia commented 2 years ago

I spend a while trying to figure out how to do this but I'm not so adept at coding. I can't find a line about class(Y) in estimate_shift_configuration. Maybe it's in a different function but I'm not sure how to find it. Any other pointers would be much appreciated...

lschmitz commented 2 years ago

I think lines 128-30 cause this error:
if( class(Y) != "matrix"){ Y <- as.matrix(Y) } Changing to if (inherits(Y, "matrix") == FALSE) { Y <- as.matrix(Y) } works

trozelia commented 2 years ago

Ok, I will try again!

cecileane commented 2 years ago

Thank you Lars for the fix! I made a pull request #51 with this change. It looks like it may fix issue #46 also.

trozelia commented 2 years ago

Hi Cecile, It seems like this helped some but there are still errors I don't understand. To test the fixes, I reinstalled l1ou, then copied the versions of tools.R and estimate_shift_configuration.R with your fixes, and tried the example dataset from the manual. For this, I get:

eModel<-estimate_shift_configuration(lizard$tree, lizard$Y) Error in erase_configuration_score_db() : could not find function "erase_configuration_score_db"

Interestingly when I try my own dataset, it starts but then I get a different error:

shapePC1_pBIC <- estimate_shift_configuration(pet_ready$tree, pet_ready$Y, root.model="OUrandomRoot", criterion="pBIC", nCores=4, quietly = TRUE) Starting first LASSO (alpha=0) to find a list of candidate configurations. Starting second LASSO (alpha= 0.9 ) for another list of candidates. Error in get_stored_config_score() : could not find function "get_stored_config_score"

Maybe it's just that I can't just swap out the changed functions by sourcing the new versions?

Thanks! Stacey

cecileane commented 2 years ago

I really don't know where the new errors come from. Perhaps you could try to install l1ou via my fork?

install_github("cecileane/l1ou")
trozelia commented 2 years ago

Ok, yes that worked, at least with the example. Yay!! I will have to try with my own data later tonight. Thank you!!