andjar / ALASCA

https://andjar.github.io/ALASCA/
10 stars 0 forks source link

Error in self$model$get_scores(effect_i = effect_i, component = component) : object 'PC' not found #10

Closed MuyaoXi9271 closed 9 months ago

MuyaoXi9271 commented 9 months ago

Hi developer,

I got the ALASCA model successfully but accidentally removed the log file. I met the error as shown in the title when I ran plot(ALASCA_model, component = c(1,2), type = "effect")

I appreciate any help you could provide.

Best, Muyao

andjar commented 9 months ago

Hi @MuyaoXi9271,

Thanks for reporting this issue. I am not able to replicate the error. What version of ALASCA are you using? What settings do you use?

Best, Anders

MuyaoXi9271 commented 9 months ago

Hi Anders,

The version I used is 1.0.14.

ALASCA_model <- ALASCA(df_l, formula = value ~ visit*group + (1|subject), scale_function = "sdall", validate = TRUE, filepath = paste0(path_outputs$POS, "/ALASCA"), save = TRUE)

Thanks for your quick reply.

Best, Muyao

andjar commented 9 months ago

Hi,

Thank you for the additional information. I am still unable to reproduce the error using the Example 2 dataset in our paper and your settings. Is visit a factor variable? Do you get any output with ALASCA_model$get_scores(component = c(1,2))?

Best, Anders

MuyaoXi9271 commented 9 months ago

Hi Anders,

I get the same error. What else can I check also?

Best, Muyao

andjar commented 9 months ago

You can take a look at the score data table itself with ALASCA_model$ALASCA$score which contains all the PCs calculated

MuyaoXi9271 commented 9 months ago

image

I can get the data table after running ALASCA_model$ALASCA$score as shown in the image above.

Best, Muyao

andjar commented 9 months ago

Thank you. I have no experience using the tibble package but perhaps it is interfering in some way (since this print looks like tibble)? I guess you can try mod$ALASCA$score[[1]] <- as.data.table(mod$ALASCA$score[[1]]) and then try to plot again, just to ensure that the data tables actually are data table objects

MuyaoXi9271 commented 9 months ago

I try mod$ALASCA$score[[1]] <- as.data.table(mod$ALASCA$score[[1]]) and mod$ALASCA$score <- as.data.table(mod$ALASCA$score[[1]]) (I use the function as.data.table from package data.table)

I still have the same error when I plot it.

Best, Muyao

andjar commented 9 months ago

Strange! Can you check that it is indeed a data table? is.data.table(ALASCA_model$ALASCA$score[[1]])

So, the issue here is that - with data.table - we can select the appropriate rows with self$ALASCA$score[[effect_i]][PC %in% component] (where self is the model object) - this is the code in the get_scores function that throws the error. But there is something preventing this selection to work. We can, however, see that the data table exists and has a column called PC

MuyaoXi9271 commented 9 months ago

Hi Ander,

It works now.

Thanks for your help

Best, Muyao