ggPMXdevelopment / ggPMX

ggPMX R package
37 stars 11 forks source link

No VPC graph with Monolix project #48

Closed TheKazan closed 2 years ago

TheKazan commented 4 years ago

Using an already fitted monolix project with pmx_mlxtran(), the controller output does not show any VPC object whereas the VPC files exist in the Monolix project folder. All other diagnostic plots are present in the controller.

I also tried with a random monolix project from the demo of Monolix and I got the same result, no VPC.

agstudy commented 4 years ago

pmx_mlxtran can not guess the simulation file . you should set it when you call pmx or pmx_mlxtran constructors.

for example:

`pmx_mlxtran(mlxtran_file, sim = pmx_sim(file = vpc_file,irun ="rep",idv="TIME"))

where :

mlxtran : is the path to your monolox model file vpc_file : is the path to your simulation file

take a look at ?pmx_sim for more details on how to set simulation file.

`

TheKazan commented 4 years ago

thanks for your answer.

When I look at ?pmx_sim, the teophylline example uses a file "sim.csv" to set the simulation file (with 20 simulated repetitions).

However, for the exported chart data from Monolix, we get 3 files for VPC :

There is no file with the simulated data. Do you know how to export from Monolix a file in the same format as "sim.csv" which then could be used with ggPMX ?

agstudy commented 4 years ago

Sorry I can not help. I am not a monolix user. Surely other monloix users will help on how to create a simulation file.

baltcir1 commented 4 years ago

Hello TheKazan,

To get the VPC, you need to provide a simulation file containing (at least) the following columns: ID: individual identifiers REP: simulation replicate number TIME: time DV: dependent variable

Use your preferred simulation software/package to create the simulation dataset (I an provide an example code using simulix, if needed).

baltcir1 commented 4 years ago

Library setting

library(dplyr) library(mlxR)  

Path and filename of the mlxtran project

myprojfilename <- '...../myprojfile.mlxtran'  

Path and filename of the to-be-created simulation file

mysimfilename <- '...../mysimfile.csv’  

NN - Create vpc file and store it

mysim <- simulx(project=myprojfilename,nrep=200)

with simulx, ids are changed to a new ID, starting at 1. one should modify the simulated file to revert the original IDs:

simdata = mysim$y3 #use the variable needed simdata <- simdata %>% left_join(., mysim$originalId) %>% mutate(id = oriId) %>% select(-oriId, -newId) write.csv(mysim$dv, file=mysimfilename, quote=F, row.names = F)

TheKazan commented 4 years ago

Hello baltcir1,

many thanks for your reply !

Unfortunately I still have troubles to generate VPC plots despite all the steps you described. I've generated a controller object : ctr<- pmx_mlxtran(mlxtran_file, sim = pmx_sim(file = vpc_file,irun ="rep",idv="TIME"))

with vpc_file coming from simulx following your explanation.

When I'm exploring this controller (ctr), it seems that it can't integrate correctly my simulated file ==> ctr[["data"]][["sim"]] is an empty data.frame

I've tried with a monolix model available in the demo ressources and will detail all the steps here, if you could help.

R code

warfarin_model <- '..../monolix2019R2/demos/5.models_for_individual_parameters/5.2.covariate_model/warfarin_covariate3_project.mlxtran'

(I first run this model with monolix to get estimation of parameters).

Generating VPC file

mysim_warfarin <- simulx (project=warfarin_model , nrep=10)

data_id<- as_tibble(mysim_warfarin $originalId)

simdata = mysim_warfarin $concentration simdata <- as_tibble(simdata) simdata$id<-as.integer(simdata$id) simdata<-rename(simdata,newId=id)

simdata<- simdata %>% left_join(data_id) %>% mutate(ID = oriId) %>% select(-oriId, -newId)

write.csv(x = simdata , file = "VPC_warfarin.csv",quote=F, row.names = F)

VPC_file <- '....../VPC_warfarin.csv'

Creating a controller object

ctr<- pmx_mlxtran(warfarin_model , sim = pmx_sim(file =VPC_file,irun ="rep",idv="time"))

==> I get this error use concentration_residuals.txt as residuals file. use concentration_fits.txt as finegrid file . Error in get(ind) : object 'dv' not found

With my own model and dataset, it was this error message: Warning message: In eval(jsub, SDenv, parent.frame()) : NAs introduced by coercion

Hope you can help.

Thanks