Qoala-T / QC

Qoala-T is a supervised-learning tool for quality control of FreeSurfer segmented MRI data
Other
72 stars 15 forks source link

Error when executing R script #18

Closed m4rklar closed 4 years ago

m4rklar commented 5 years ago

Dear Qoala-T experts,

I am having troubles running the script provided in this repository with a test dataset. I tried the online solution with the same input data and it worked fine- great job! This is very useful. I am not a very experienced R programmer and I was running the script called Qoala_T_A_model_based_github.R but I got an error that I cannot work around:

> rf.pred  <- predict(rf.tune,testing)
Error in UseMethod("predict") : 
  no applicable method for 'predict' applied to an object of class "train"

I have installed R v3.4 and running on a ubuntu 18.04 machine. Can you please help me? Thanks

eduardklap commented 5 years ago

Not exactly sure what is happening here. Could you try the following (based on https://stackoverflow.com/questions/38623624/usemethodpredict-no-applicable-method-for-predict-applied-to-an-object-o):

You might have to call the caret package again right before the predict function. > library(caret) rf.pred <- predict(rf.tune,testing)

Or similarly:

library(randomForest) rf.pred <- predict(rf.tune,testing)

Hope this helps! If this doesn't work could you give some more details on how you edited the code?

m4rklar commented 5 years ago

Thank you for your answer, but unfortunately, I get the same error.

how you edited the code?

I have only changed the inputFolder and outputFolder.

Also, this other error was raising: package ‘caret’ is not available (for R version 3.4.4)

And this warning also seems related... > rf.tune <- get(load(url(githubURL))) Warning: namespace ‘caret’ is not available and has been replaced by .GlobalEnv when processing object ‘rf.tune’

I hope it helps clearing the issue, I am quite lost at the moment.

Thank you, Marc.

eduardklap commented 5 years ago

Also, this other error was raising: package ‘caret’ is not available (for R version 3.4.4)

The problem is that the caret package that is needed for Qoala-T generally and the rf.predict and rf.tune functions specifically cannot be loaded. You can either install a newer R version for which caret is available, or you can use the Shiny app (https://qoala-t.shinyapps.io/qoala-t_app/) which does exactly the same for you as the Qoala_T_A_model_based_github.R script.