This example script is intended to illustrate how to use the 'ddmore' R package to perform a M&S workflow using the DDMoRe Standalone Execution Environment (SEE).
The following steps are implemented in this workflow:
To run a task, select wiht the coursor any code lines you wish to execute and press CTRL+R+R in your keyboard.
Clear workspace and set working directory under 'UsesCasesDemo' project
rm(list=ls(all=F))
mydir <- file.path(Sys.getenv("MDLIDE_WORKSPACE_HOME"),"UseCasesDemo")
setwd(mydir)
Set name of .mdl file and dataset for future tasks
uc <- "UseCase2"
datafile <- "warfarin_conc.csv"
mdlfile <- paste0(uc,".mdl")
Create a new folder to be used as working directory and where results will be stored
wd <- file.path(mydir,uc)
dir.create(wd)
Copy the dataset and the .mdl file available under “models” into the working directory
file.copy(file.path(mydir,"models", datafile),wd)
## [1] TRUE
file.copy(file.path(mydir,"models",mdlfile),wd)
## [1] TRUE
Set the working directory.
setwd(file.path(mydir,uc))
The working directory needs to be set differently when knitr R package is used to spin the file
library(knitr)
opts_knit$set(root.dir = file.path(mydir,uc))
List files available in working directory
list.files()
## [1] "UseCase2.mdl" "warfarin_conc.csv"
Use 'ddmore' function getMDLObjects() to retrieve model object(s) from an existing .mdl file. This function reads the MDL in an .mdl file and parses the MDL code for each MDL Object into an R list of objects of appropriate types with names corresponding to the MDL Object names given in the file.
myMDLObj <- getMDLObjects(mdlfile)
length(myMDLObj)
## [1] 4
names(myMDLObj)
## [1] "warfarin_PK_ANALYTIC_dat" "warfarin_PK_ODE_par"
## [3] "warfarin_PK_ANALYTIC_mdl" "warfarin_PK_ODE_task"
Use 'ddmore' function getDataObjects() to retrieve only data object(s) from an existing .mdl file This function returns a list of Parameter Object(s) from which we select the first element Hover over the variable name to see its structure
myDataObj <- getDataObjects(mdlfile)[[1]]
Use 'ddmore' function getParameterObjects() to retrieve only parameter object(s) from an existing .mdl file
myParObj <- getParameterObjects(mdlfile)[[1]]
Use 'ddmore' function getModelObjects() to retrieve only model object(s) from an existing .mdl file.
myModObj <- getModelObjects(mdlfile)[[1]]
Use 'ddmore' function getTaskPropertiesObjects() to retrieve only task properties object(s) from an existing .mdl file
myTaskObj <- getTaskPropertiesObjects(mdlfile)[[1]]
Recall that getDataObjects only reads the MDL code from the .mdl file. Use 'ddmore' function readDataObj() to create an R object from the MDL data object.
myData <- readDataObj(myDataObj)
Let's look at the first 6 lines of the data set
head(myData)
## ID TIME WT AMT DVID DV MDV logtWT
## 1 1 0.0 66.7 100 0 NA 1 -0.04829029
## 2 1 0.5 66.7 NA 1 0.0 0 -0.04829029
## 3 1 1.0 66.7 NA 1 1.9 0 -0.04829029
## 4 1 2.0 66.7 NA 1 3.3 0 -0.04829029
## 5 1 3.0 66.7 NA 1 6.6 0 -0.04829029
## 6 1 6.0 66.7 NA 1 9.1 0 -0.04829029
Extract only observation records
myEDAData<-myData[myData$MDV==0,]
Open an R window to record and access all your plots
windows(record=TRUE)
Plot the data using xyplot from the lattice library
plot1 <- xyplot(DV~TIME,groups=ID,data=myEDAData,type="b",ylab="Conc. (mg/L)",xlab="Time (h)")
print(plot1)
plot2 <- xyplot(DV~TIME|ID,data=myEDAData,type="b",layout=c(3,4),ylab="Conc. (mg/L)",xlab="Time (h)",scales=list(relation="free"))
print(plot2)
Export the results in a pdf file
pdf(paste0(uc,"_EGA.pdf"))
print(plot1)
print(plot2)
dev.off()
## rj.GD
## 2
The ddmore “estimate” function translates the contents of the .mdl file to a target language and then estimates parameters using the target software. After estimation, the output is converted to a Standard Output object which is saved in a .SO.xml file.
Translated files and Monolix output will be returned in the ./Monolix subfolder. The Standard Output object (.SO.xml) is read and parsed into an R object called “mlx” of (S4) class “StandardOutputObject”.
mlx <- estimate(mdlfile, target="MONOLIX", subfolder="Monolix")
## -- Fri Dec 11 02:15:46 2015
## New
## Submitted
## Job 10c107cb-181d-4c18-802b-027c766a7356 progress:
## Running [ ........ ]
## Importing Results
## Copying the result data back to the local machine for job ID 10c107cb-181d-4c18-802b-027c766a7356...
## From C:\Users\zparra\AppData\Local\Temp\Rtmpkfi8Jd\DDMORE.jobfd0399a3e8f to D:/SEE-1.2-SNAPSHOT-10DEC2015/MDL_IDE/workspace/UseCasesDemo/UseCase2/Monolix
## Done.
##
##
## The following elements were parsed successfully:
## ToolSettings
## RawResults
## TaskInformation
## Estimation:PopulationEstimates
## Estimation:PrecisionPopulationEstimates
## Estimation:IndividualEstimates
## Estimation:Residuals
## Estimation:Predictions
## Estimation:Likelihood
##
## Completed
## -- Fri Dec 11 02:18:31 2015
slotNames(mlx)
## [1] "ToolSettings" "RawResults" "TaskInformation"
## [4] "Estimation" "ModelDiagnostic" "Simulation"
## [7] "OptimalDesign" ".pathToSourceXML"
The ddmore “LoadSOObj” function reads and parses existing Standard Output Objects mlx <- LoadSOObject(“Monolix/UseCase2.SO.xml”) The ddmore function “getPopulationParameters” extracts the Population Parameter values from an R object of (S4) class “StandardOutputObject” and returns the estimates. See documentation for getPopulationParameters to see other arguments and settings for this function.
parameters_mlx <- getPopulationParameters(mlx, what="estimates")$MLE
print(parameters_mlx)
## POP_V BETA_V_WT POP_KA POP_CL BETA_CL_WT
## 8.04520 1.00000 1.44422 0.13407 0.75000
## POP_TLAG PPV_V PPV_KA PPV_CL PPV_TLAG
## 0.94313 0.13562 0.61255 0.26521 0.37358
## ETA_V_ETA_CL RUV_ADD RUV_PROP
## 0.16902 0.30286 0.05022
print(getPopulationParameters(mlx, what="precisions"))
## $MLE
## Parameter MLE SE RSE
## 1 BETA_CL_WT 0.75000 0.00000 0.00
## 2 BETA_V_WT 1.00000 0.00000 0.00
## 3 ETA_V_ETA_CL 0.16902 0.20027 118.49
## 4 POP_CL 0.13407 0.00642 4.79
## 5 POP_KA 1.44422 0.38306 26.52
## 6 POP_TLAG 0.94313 0.17586 18.65
## 7 POP_V 8.04520 0.21996 2.73
## 8 PPV_CL 0.26521 0.03453 13.02
## 9 PPV_KA 0.61255 0.21395 34.93
## 10 PPV_TLAG 0.37358 0.14102 37.75
## 11 PPV_V 0.13562 0.02178 16.06
## 12 RUV_ADD 0.30286 0.04784 15.80
## 13 RUV_PROP 0.05022 0.00910 18.12
print(getEstimationInfo(mlx))
## $Likelihood
## $Likelihood$LogLikelihood
## [1] -323.265
##
## $Likelihood$IndividualContribToLL
## Subject ICtoLL
## 1 1 -21.10
## 2 2 -5.25
## 3 3 -12.87
## 4 4 -12.25
## 5 5 -10.95
## 6 6 -7.72
## 7 7 -17.82
## 8 8 -21.72
## 9 9 -33.12
## 10 10 -5.77
## 11 12 -20.00
## 12 13 -12.10
## 13 14 -17.31
## 14 15 -12.59
## 15 16 -13.42
## 16 17 -5.71
## 17 18 -5.27
## 18 19 -6.44
## 19 20 -5.45
## 20 21 -5.91
## 21 22 -5.91
## 22 23 -8.21
## 23 24 -4.88
## 24 25 -7.09
## 25 26 -7.17
## 26 27 -5.27
## 27 28 -6.79
## 28 29 -5.63
## 29 30 -4.67
## 30 31 -5.04
## 31 32 -4.72
## 32 33 -5.09
##
## $Likelihood$InformationCriteria
## $Likelihood$InformationCriteria$AIC
## [1] 668.53
##
## $Likelihood$InformationCriteria$BIC
## [1] 684.66
##
##
##
## $Messages
## list()
Perform model diagnostics for the base model using Xpose functions Use 'ddmore' function as.xpdb() to create an Xpose database object from the Standard Output object, regardless of target software used for estimation.
mlx.xpdb<-as.xpdb(mlx,datafile)
##
## Removed dose rows in rawData slot of SO to enable merge with Predictions data.
We can then call Xpose functions referencing this mlx.xpdb object as the input. Perform some basic goodness of fit (graphs are exported to PDF file)
print(basic.gof(mlx.xpdb))
print(ind.plots(mlx.xpdb))
Export graphs to a PDF file
pdf("GOF_MLX.pdf")
print(basic.gof(mlx.xpdb))
print(ind.plots(mlx.xpdb))
dev.off()
## rj.GD
## 2
NM <- estimate(mdlfile, target="NONMEM", subfolder="NONMEM")
## -- Fri Dec 11 02:18:44 2015
## New
## Submitted
## Job 2ce53754-ca10-437b-a8ea-9d20d242b155 progress:
## Running [ ..... ]
## Importing Results
## Copying the result data back to the local machine for job ID 2ce53754-ca10-437b-a8ea-9d20d242b155...
## From C:\Users\zparra\AppData\Local\Temp\Rtmpkfi8Jd\DDMORE.jobfd0205f6e3c to D:/SEE-1.2-SNAPSHOT-10DEC2015/MDL_IDE/workspace/UseCasesDemo/UseCase2/NONMEM
## Done.
##
##
## The following elements were parsed successfully:
## RawResults
## TaskInformation
## Estimation:PopulationEstimates
## Estimation:IndividualEstimates
## Estimation:Residuals
## Estimation:Predictions
## Estimation:Likelihood
##
## The following MESSAGEs were raised during the job execution:
## minimization_successful: 1
## covariance_step_run: 0
## rounding_errors: 0
## estimate_near_boundary: 0
## s_matrix_singular: 0
## nmoutput2so_version: This SOBlock was created with nmoutput2so version 4.5.11
##
## Completed
## -- Fri Dec 11 02:20:28 2015
Load previous results NM <- LoadSOObject(“NONMEM/UseCase2.SO.xml”)
Results from NONMEM should be comparable with results from MONOLIX
parameters_nm <- getPopulationParameters(NM, what="estimates")
print(parameters_nm)
## $MLE
## POP_CL POP_V POP_KA POP_TLAG RUV_PROP
## 0.132856000 8.151820000 1.361500000 0.833547000 0.106436000
## RUV_ADD PPV_CL ETA_CL_ETA_V PPV_V PPV_KA
## 0.000100001 0.262829000 0.231478000 0.139007000 0.800165000
## PPV_TLAG BETA_CL_WT BETA_V_WT
## 0.344029000 0.750000000 1.000000000
print(parameters_mlx)
## POP_V BETA_V_WT POP_KA POP_CL BETA_CL_WT
## 8.04520 1.00000 1.44422 0.13407 0.75000
## POP_TLAG PPV_V PPV_KA PPV_CL PPV_TLAG
## 0.94313 0.13562 0.61255 0.26521 0.37358
## ETA_V_ETA_CL RUV_ADD RUV_PROP
## 0.16902 0.30286 0.05022
Covariance step cannot be requested in the current version of the Framework
#print(getPopulationParameters(NM, what="precisions"))
print(getEstimationInfo(NM))
## $Likelihood
## $Likelihood$Deviance
## [1] -284.6856
##
##
## $Messages
## $Messages$Info
## $Messages$Info$minimization_successful
## [1] "1"
##
## $Messages$Info$covariance_step_run
## [1] "0"
##
## $Messages$Info$rounding_errors
## [1] "0"
##
## $Messages$Info$estimate_near_boundary
## [1] "0"
##
## $Messages$Info$s_matrix_singular
## [1] "0"
##
## $Messages$Info$nmoutput2so_version
## [1] "This SOBlock was created with nmoutput2so version 4.5.11"
nm.xpdb<-as.xpdb(NM,datafile)
##
## Removed dose rows in rawData+Predictions slot of SO to enable merge with Residuals data.
##
## Residuals data does not currently contain dose rows in output from Nonmem executions.
Perform some basic goodness of fit
print(basic.gof(nm.xpdb))
print(ind.plots(nm.xpdb))
print(parm.hist(nm.xpdb))
Export graphs to a PDF file
pdf("GOF_NM.pdf")
print(basic.gof(nm.xpdb))
print(ind.plots(nm.xpdb))
print(parm.hist(nm.xpdb))
dev.off()
## rj.GD
## 2
MDL Objects can be manipulated from R to change for example the estimation algorithm
myTaskProperties <- getTaskPropertiesObjects(mdlfile)[[1]]
myNewTaskProperties <- myTaskProperties
myNewTaskProperties@ESTIMATE$algo <- "focei"
Assembling the new Modelling Object Group (MOG). Note that we reuse the data, parameters and model from the MOG.
myNewerMOG <- createMogObj(dataObj = getDataObjects(mdlfile)[[1]],
parObj = getParameterObjects(mdlfile)[[1]],
mdlObj = getModelObjects(mdlfile)[[1]],
taskObj = myNewTaskProperties)
We can then write the MOG back out to an .mdl file.
mdlfile.FOCEI <- paste0(uc,"_FOCEI.mdl")
writeMogObj(myNewerMOG,mdlfile.FOCEI)
Test estimation using this new MOG in NONMEM via PsN
NM.FOCEI <- estimate(mdlfile.FOCEI, target="PsN", subfolder="NONMEM_FOCEI")
## -- Fri Dec 11 02:20:54 2015
## New
## Submitted
## Job 56720b6b-e01c-4f41-9d43-9fad2fd70f7a progress:
## Running [ .... ]
## Importing Results
## Copying the result data back to the local machine for job ID 56720b6b-e01c-4f41-9d43-9fad2fd70f7a...
## From C:\Users\zparra\AppData\Local\Temp\Rtmpkfi8Jd\DDMORE.jobfd066a87d98 to D:/SEE-1.2-SNAPSHOT-10DEC2015/MDL_IDE/workspace/UseCasesDemo/UseCase2/NONMEM_FOCEI
## Done.
##
##
## The following elements were parsed successfully:
## RawResults
## TaskInformation
## Estimation:PopulationEstimates
## Estimation:IndividualEstimates
## Estimation:Residuals
## Estimation:Predictions
## Estimation:Likelihood
##
## The following MESSAGEs were raised during the job execution:
## minimization_successful: 1
## covariance_step_run: 0
## rounding_errors: 0
## hessian_reset: 0
## zero_gradients: 0
## final_zero_gradients: 0
## estimate_near_boundary: 0
## s_matrix_singular: 0
## significant_digits: 3.0
## nmoutput2so_version: This SOBlock was created with nmoutput2so version 4.5.11
##
## Completed
## -- Fri Dec 11 02:22:19 2015
Load previous results NM.FOCEI <- LoadSOObject(“NONMEM_FOCEI/UseCase2_FOCEI.SO.xml”) Results from NONMEM should be comparable to previous results
print(getPopulationParameters(NM.FOCEI, what="estimates"))
## $MLE
## POP_CL POP_V POP_KA POP_TLAG RUV_PROP
## 0.1344280 8.0691200 1.4259600 0.9191610 0.0661158
## RUV_ADD PPV_CL ETA_CL_ETA_V PPV_V PPV_KA
## 0.2605030 0.2638970 0.2255100 0.1368300 0.9662940
## PPV_TLAG BETA_CL_WT BETA_V_WT
## 0.0732954 0.7500000 1.0000000
print(parameters_nm)
## $MLE
## POP_CL POP_V POP_KA POP_TLAG RUV_PROP
## 0.132856000 8.151820000 1.361500000 0.833547000 0.106436000
## RUV_ADD PPV_CL ETA_CL_ETA_V PPV_V PPV_KA
## 0.000100001 0.262829000 0.231478000 0.139007000 0.800165000
## PPV_TLAG BETA_CL_WT BETA_V_WT
## 0.344029000 0.750000000 1.000000000
nmfocei.xpdb<-as.xpdb(NM.FOCEI,datafile)
##
## Removed dose rows in rawData+Predictions slot of SO to enable merge with Residuals data.
##
## Residuals data does not currently contain dose rows in output from Nonmem executions.
Basic diagnostics for NONMEM fit.
print(basic.gof(nmfocei.xpdb))
Export graphs to a PDF file
pdf("GOF_NM_FOCEI.pdf")
print(basic.gof(nmfocei.xpdb))
dev.off()
## rj.GD
## 2
The ddmore “bootstrap.PsN” function is a wrap up function that calls Bootstrap PsN functionality using as input an MDL file that will be translated to NMTRAN as first step. Additional PsN arguments can be specified under the “bootstrapOptions” attribute. After task execution, the output from PsN is converted to a Standard Output object which is saved in a .SO.xml file. Translated files and PsN output will be returned in the ./Bootstrap subfolder
bootstrapResults <- bootstrap.PsN(mdlfile.FOCEI, samples=20, seed=123456,
bootstrapOptions=" -no-skip_minimization_terminated -threads=2",
subfolder="Bootstrap", plot=TRUE)
## -- Fri Dec 11 02:22:27 2015
## New
## Submitted
## Job 1b745841-1d10-42be-b824-3b6aae1b305f progress:
## Running [ ........ ]
## Importing Results
## Copying the result data back to the local machine for job ID 1b745841-1d10-42be-b824-3b6aae1b305f...
## From C:\Users\zparra\AppData\Local\Temp\Rtmpkfi8Jd\DDMORE.jobfd063f9503d to D:/SEE-1.2-SNAPSHOT-10DEC2015/MDL_IDE/workspace/UseCasesDemo/UseCase2/Bootstrap
## Done.
##
##
## The following elements were parsed successfully:
## RawResults
## TaskInformation
## Estimation:PopulationEstimates
## Estimation:PrecisionPopulationEstimates
## Estimation:IndividualEstimates
## Estimation:Residuals
## Estimation:Predictions
## Estimation:Likelihood
##
## The following WARNINGs were raised during the job execution:
## bootstrap_parameter_scale: The parameters PPV_CL, ETA_CL_ETA_V, PPV_V, PPV_KA and PPV_TLAG were requested on the sd/corr scale but are given on the var/cov scale in all bootstrap results.
##
## The following MESSAGEs were raised during the job execution:
## minimization_successful: 1
## covariance_step_run: 0
## rounding_errors: 0
## hessian_reset: 0
## zero_gradients: 0
## final_zero_gradients: 0
## estimate_near_boundary: 0
## s_matrix_singular: 0
## significant_digits: 3.0
## nmoutput2so_version: This SOBlock was created with nmoutput2so version 4.5.11
##
## Completed
## -- Fri Dec 11 02:25:13 2015
## Warning: NAs introduced by coercion
## [[1]]
##
## [[2]]
## NULL
##
## [[3]]
##
## [[4]]
## NULL
##
## [[5]]
## NULL
Load results from a bootstrap previously performed bootstrapResults <- LoadSOObject(“Bootstrap/UseCase2_FOCEI.SO.xml”) Export bootstrap histograms to a pdf
pdf(paste0(uc,"_Bootstrap.pdf"))
print(boot.hist(results.file = file.path("Bootstrap",paste0("raw_results_",uc,"_FOCEI.csv")),
incl.ids.file = file.path("Bootstrap","included_individuals1.csv")))
## [[1]]
##
## [[2]]
## NULL
##
## [[3]]
##
## [[4]]
## NULL
##
## [[5]]
## NULL
dev.off()
## rj.GD
## 2
Extract parameter estimates and precision from bootstrap results.
print(getPopulationParameters(bootstrapResults, what="estimates"))
## $MLE
## POP_CL POP_V POP_KA POP_TLAG RUV_PROP
## 0.1344280 8.0691200 1.4259600 0.9191610 0.0661158
## RUV_ADD PPV_CL ETA_CL_ETA_V PPV_V PPV_KA
## 0.2605030 0.2638970 0.2255100 0.1368300 0.9662940
## PPV_TLAG BETA_CL_WT BETA_V_WT
## 0.0732954 0.7500000 1.0000000
##
## $Bootstrap
## Parameter Mean Median
## POP_CL POP_CL 0.134977100 0.13629550
## POP_V POP_V 8.084488000 8.02689500
## POP_KA POP_KA 1.394247000 1.18184000
## POP_TLAG POP_TLAG 0.831877100 0.85754450
## RUV_PROP RUV_PROP 0.093486870 0.09161010
## RUV_ADD RUV_ADD 0.093066800 0.06518400
## BETA_CL_WT BETA_CL_WT 0.750000000 0.75000000
## BETA_V_WT BETA_V_WT 1.000000000 1.00000000
## PPV_CL PPV_CL 0.071243030 0.06853190
## ETA_CL_ETA_V ETA_CL_ETA_V 0.005422614 0.00630111
## PPV_V PPV_V 0.015298040 0.01523810
## PPV_KA PPV_KA 0.587199000 0.58909800
## PPV_TLAG PPV_TLAG 0.153434300 0.12285400
Extract the information regarding the precision intervals
print(getPopulationParameters(bootstrapResults, what="intervals")$Bootstrap)
## Parameter Mean Median Perc_5 Perc_95
## 1 BETA_CL_WT 0.750000000 0.75000000 0.750000000 0.75000000
## 2 BETA_V_WT 1.000000000 1.00000000 1.000000000 1.00000000
## 3 ETA_CL_ETA_V 0.005422614 0.00630111 -0.005718610 0.01431670
## 4 POP_CL 0.134977100 0.13629550 0.123605100 0.14676260
## 5 POP_KA 1.394247000 1.18184000 0.761158300 3.38496500
## 6 POP_TLAG 0.831877100 0.85754450 0.488957200 0.99999770
## 7 POP_V 8.084488000 8.02689500 7.696565000 8.55505600
## 8 PPV_CL 0.071243030 0.06853190 0.029646000 0.12302510
## 9 PPV_KA 0.587199000 0.58909800 0.011629320 1.35812800
## 10 PPV_TLAG 0.153434300 0.12285400 0.026376440 0.53597920
## 11 PPV_V 0.015298040 0.01523810 0.007392953 0.02801069
## 12 RUV_ADD 0.093066800 0.06518400 0.001099000 0.26528550
## 13 RUV_PROP 0.093486870 0.09161010 0.059302890 0.13499960
When basing VPC on estimation from a target software other than NONMEM we must update the parameter values.
structuralPar <- getPopulationParameters(NM.FOCEI, what="estimates",block='structural')$MLE
variabilityPar <- getPopulationParameters(NM.FOCEI, what="estimates",block='variability')$MLE
In the current version of the SO standard, we need to manually update parameter names for correlation and covariance parameters to match the SO with the MDL. This will not be needed in future releases. The SO object returned from NONMEM has parameter ETA_CL_ETA_V. This needs to be renamed to conform to model Correlation name OMEGA
variabilityNames <- names(myParObj@VARIABILITY)
names(variabilityPar)[names(variabilityPar)=="ETA_CL_ETA_V"] <- grep("OMEGA",variabilityNames,value=T)
names(variabilityPar)
## [1] "PPV_CL" "OMEGA" "PPV_V" "PPV_KA" "PPV_TLAG"
Update the parameter object using the ddmore “updateParObj” function. This function updates an R object of (S4) class “parObj”. The user chooses which block to update, what items within that block, and what to replace those items with. NOTE: that updateParObj can only update attributes which ALREADY EXIST in the MDL Parameter Object for that item. This ensures that valid MDL is preserved.
myParObj <- getParameterObjects(mdlfile)[[1]]
myParObjUpdated <- updateParObj(myParObj,block="STRUCTURAL",
item=names(structuralPar),
with=list(value=structuralPar))
myParObjUpdated <- updateParObj(myParObjUpdated,block="VARIABILITY",
item=names(variabilityPar),
with=list(value=variabilityPar))
Check that the appropriate initial values have been updated to the MLE values from the previous fit.
print(myParObjUpdated@STRUCTURAL)
## $POP_CL
## $POP_CL$value
## [1] "0.134428"
##
## $POP_CL$lo
## [1] "0.001"
##
##
## $POP_V
## $POP_V$value
## [1] "8.06912"
##
## $POP_V$lo
## [1] "0.001"
##
##
## $POP_KA
## $POP_KA$value
## [1] "1.42596"
##
## $POP_KA$lo
## [1] "0.001"
##
##
## $POP_TLAG
## $POP_TLAG$value
## [1] "0.919161"
##
## $POP_TLAG$lo
## [1] "0.001"
##
##
## $BETA_CL_WT
## $BETA_CL_WT$value
## [1] "0.75"
##
## $BETA_CL_WT$fix
## [1] "true"
##
##
## $BETA_V_WT
## $BETA_V_WT$value
## [1] "1"
##
## $BETA_V_WT$fix
## [1] "true"
##
##
## $RUV_PROP
## $RUV_PROP$value
## [1] "0.0661158"
##
## $RUV_PROP$lo
## [1] "0"
##
##
## $RUV_ADD
## $RUV_ADD$value
## [1] "0.260503"
##
## $RUV_ADD$lo
## [1] "1.0E-4"
print(myParObjUpdated@VARIABILITY)
## $PPV_CL
## $PPV_CL$value
## [1] "0.263897"
##
## $PPV_CL$type
## [1] "sd"
##
##
## $PPV_V
## $PPV_V$value
## [1] "0.13683"
##
## $PPV_V$type
## [1] "sd"
##
##
## $PPV_KA
## $PPV_KA$value
## [1] "0.966294"
##
## $PPV_KA$type
## [1] "sd"
##
##
## $PPV_TLAG
## $PPV_TLAG$value
## [1] "0.0732954"
##
## $PPV_TLAG$type
## [1] "sd"
##
##
## $OMEGA
## $OMEGA$parameter
## [1] "[ETA_CL,ETA_V]"
##
## $OMEGA$value
## [1] "0.22551"
##
## $OMEGA$type
## [1] "corr"
A bug in the writeMogObj function means that for now, we must manually add the square bracket around the OMEGA value to signify that this is a vector (of length 1).
myParObjUpdated@VARIABILITY$OMEGA$value<-paste0("[",myParObjUpdated@VARIABILITY$OMEGA$value,"]")
Assembling the new MOG. Note that we reuse the data and model from the previous run.
myVPCMOG <- createMogObj(dataObj = getDataObjects(mdlfile)[[1]],
parObj = myParObjUpdated,
mdlObj = getModelObjects(mdlfile)[[1]],
taskObj = getTaskPropertiesObjects(mdlfile)[[1]])
We can then write the MOG back out to an .mdl file.
mdlfile.VPC <- paste0(uc,"_VPC.mdl")
writeMogObj(myVPCMOG,mdlfile.VPC)
Similarly as above, ddmore “VPC.PsN” function can be used to run a VPC using PsN as target tool
vpcFiles <- VPC.PsN(mdlfile.VPC,samples=20, seed=12345,
vpcOptions ="-n_simulation=10 -auto_bin=10",
subfolder="VPC", plot=TRUE)
## -- Fri Dec 11 02:25:31 2015
## New
## Submitted
## Job cdb73b0b-7976-4a74-b0e4-e04b8dbb072b progress:
## Running [ .... ]
## Importing Results
## Copying the result data back to the local machine for job ID cdb73b0b-7976-4a74-b0e4-e04b8dbb072b...
## From C:\Users\zparra\AppData\Local\Temp\Rtmpkfi8Jd\DDMORE.jobfd071732618 to D:/SEE-1.2-SNAPSHOT-10DEC2015/MDL_IDE/workspace/UseCasesDemo/UseCase2/VPC
## Done.
##
##
## The following elements were parsed successfully:
## RawResults
## TaskInformation
## Simulation
##
## The following MESSAGEs were raised during the job execution:
## nmoutput2so_version: This SOBlock was created with nmoutput2so version 4.5.11
##
## Completed
## -- Fri Dec 11 02:26:56 2015
To replay the visualisation using information from the VPC SO file
pdf(paste0(uc,"_VPC.pdf"))
print(xpose.VPC(vpc.info= file.path("./VPC",vpcFiles@RawResults@DataFiles$PsN_VPC_results$path),
vpctab= file.path("./VPC",vpcFiles@RawResults@DataFiles$PsN_VPC_vpctab$path),
main="VPC warfarin"))
dev.off()
## rj.GD
## 2
The mlxR package has been developed to visualize and explore models that are encoded in MLXTRAN or PharmML The ddmore function as.PharmML translates an MDL file (extension .mdl) to its PharmML representation. The output file (extension .xml) is saved in the working directory.
myPharmML <- as.PharmML(mdlfile)
Use parameter values from the FOCEI estimation
parValues <- getPopulationParameters(NM.FOCEI, what="estimates")$MLE
Simulate for the typical weight of 70. Recall that logtWT = log(WT/70).
p <- c(parValues,WT=70)
Parameter values used in simulation
print(p)
## POP_CL POP_V POP_KA POP_TLAG RUV_PROP
## 0.1344280 8.0691200 1.4259600 0.9191610 0.0661158
## RUV_ADD PPV_CL ETA_CL_ETA_V PPV_V PPV_KA
## 0.2605030 0.2638970 0.2255100 0.1368300 0.9662940
## PPV_TLAG BETA_CL_WT BETA_V_WT WT
## 0.0732954 0.7500000 1.0000000 70.0000000
Simulate PK parameters for individuals
ind <- list(name = c('TLAG','KA','CL','V'))
Simulate predicted (CC) and observed concentration values (Y)
y <- list( name = c('Y'), time = c(0, 0.5, 1, 2, 3, 4, 6, 8, 12, 24, 36, 48))
Simulate for a dose of 100mg given at time 0 into the GUT (oral administration)
adm <- list(time = 0, amount = 100)
Simulate 12 subjects
g <- list( size = 12, level = 'individual', treatment=adm)
Call simulx
res <- simulx(model =myPharmML,
parameter = p,
group = g,
output = list(ind,y))
Simulated parameter values for each individual
print(res$parameter)
## id TLAG KA CL V
## 1 1 0.9751031 1.9734750 0.16392407 8.943269
## 2 2 0.9472053 0.7396406 0.09098205 6.590573
## 3 3 0.8748874 3.3940649 0.21153166 10.207301
## 4 4 0.9940778 2.4683725 0.16226765 8.896298
## 5 5 0.9420058 5.8249249 0.12985450 7.925592
## 6 6 0.9603786 1.4769072 0.19048453 9.667433
## 7 7 0.9574111 1.3119880 0.13865156 8.199591
## 8 8 0.9235718 2.6980526 0.14103527 8.272383
## 9 9 0.9003508 6.0186378 0.14080282 8.265311
## 10 10 0.9215054 1.5459374 0.18442151 9.506644
## 11 11 0.9584692 1.1591302 0.16743251 9.042010
## 12 12 0.9219627 3.7797648 0.15194613 8.598253
Plot simulated results
plot(ggplot() +
geom_line(data=res$Y, aes(x=time, y=Y, colour=id)) +
xlab("time (h)") + ylab("concentration"))
Simulate 1000 subjects - with simulx this is a QUICK process!
g <- list( size = 1000, level = 'individual', treatment = adm)
Call simulx
res.1000 <- simulx(model =myPharmML,
parameter = p,
group = g,
output = list(ind,y))
Plot of observed concentrations (with residual error) band defines the percentile bands displayed level = range of values to examine (in %) 100 = full range of values number = number of bins within the level range.
print(prctilemlx(res.1000$Y,band=list(number=9, level=90)))
Table of the same information
print(prctilemlx(res.1000$Y,band=list(number=10, level=100), plot=F)$y)
## time 0% 10% 20% 30% 40%
## 1 0.0 -0.7391255 -0.42493880 -0.2274938 -0.15530472 -0.09239917
## 2 0.5 -0.4245951 -0.25460315 -0.1364019 -0.06644699 -0.02280089
## 3 1.0 -0.2909170 0.07904086 0.3131799 0.75960591 1.05097461
## 4 2.0 1.9850645 4.76952879 6.6798233 7.91713915 8.74393809
## 5 3.0 3.5017489 7.47145911 8.6523156 9.70043992 10.55461290
## 6 4.0 4.6096900 8.38484527 9.7027257 10.22901903 10.73005463
## 7 6.0 5.5801819 9.28066925 9.8846360 10.39846522 11.22665551
## 8 8.0 7.1107645 9.36189802 9.9572501 10.49884088 10.76994586
## 9 12.0 6.8628038 8.39776997 9.3018386 9.84830106 10.08979624
## 10 24.0 4.7345870 7.11389481 7.8159522 8.25710739 8.62659414
## 11 36.0 2.9232873 5.42297845 5.9157595 6.33828101 6.69750631
## 12 48.0 3.3263595 4.55799880 5.0634908 5.49737983 5.80641319
## 50% 50% 60% 70% 80% 90%
## 1 -0.05318938 -0.05318938 0.01118815 0.04829482 0.1332348 0.2320606
## 2 0.05426018 0.05426018 0.11595701 0.19039761 0.2444507 0.3388918
## 3 1.23947312 1.23947312 1.65954858 2.28284386 2.9859906 3.9973121
## 4 9.56636095 9.56636095 10.50431159 11.24964930 12.0245586 13.1896802
## 5 11.15104710 11.15104710 11.88754637 12.29325490 12.7972446 13.8561111
## 6 11.28493899 11.28493899 11.80163673 12.47542456 13.1937290 14.2499205
## 7 11.74294886 11.74294886 12.40956336 12.94262926 13.4271257 13.8857945
## 8 11.24948430 11.24948430 11.86558807 12.12018439 12.9077470 13.5850201
## 9 10.57882098 10.57882098 11.14579846 11.57652149 12.3339792 13.1873846
## 10 8.83674658 8.83674658 9.21135211 9.55280681 9.9906827 11.2945898
## 11 7.09239680 7.09239680 7.36779448 7.91896885 8.6272688 9.2968454
## 12 6.10485027 6.10485027 6.50306994 6.80907164 7.4668327 8.1443363
## 100%
## 1 0.7510420
## 2 0.6877251
## 3 12.8825932
## 4 17.9225343
## 5 17.0522841
## 6 19.0081558
## 7 17.1672515
## 8 15.5657483
## 9 15.3464507
## 10 14.0674412
## 11 12.0968484
## 12 10.0777345