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. An HTML file containing the commands in this file and associated output will be provided to allow the user to compare the results
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)
Create a working directory under 'models' folder where results are stored
uc<-"UseCase17"
datafile <- "warfarin_conc_SS.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] "UseCase17.mdl" "warfarin_conc_SS.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_SS_dat" "warfarin_PK_ODE_par" "warfarin_PK_ODE_mdl"
## [4] "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 AGE SEX AMT SS II DVID DV MDV logtWT
## 1 1 0.0 66.7 50 male 5 1 24 0 0.0000 1 -0.04829029
## 2 1 0.5 66.7 50 male 0 0 0 1 1.6404 0 -0.04829029
## 3 1 1.0 66.7 50 male 0 0 0 1 2.0318 0 -0.04829029
## 4 1 2.0 66.7 50 male 0 0 0 1 1.7198 0 -0.04829029
## 5 1 3.0 66.7 50 male 0 0 0 1 2.4068 0 -0.04829029
## 6 1 6.0 66.7 50 male 0 0 0 1 2.4318 0 -0.04829029
Extract only observation records
myEDAData<-myData[myData$AMT==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 Standardised Output object which is saved in a .SO.xml file.
Translated files and Monolix output will be returned in the ./Monolix subfolder. The Standardised 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")
## -- Thu Dec 10 23:57:54 2015
## New
## Submitted
## Job 6b4282d5-9db5-47d2-9d53-b61b53cefbf0 progress:
## Running [ ...... ]
## Importing Results
## Copying the result data back to the local machine for job ID 6b4282d5-9db5-47d2-9d53-b61b53cefbf0...
## From C:\Users\zparra\AppData\Local\Temp\Rtmpkfi8Jd\DDMORE.jobfd057061d05 to D:/SEE-1.2-SNAPSHOT-10DEC2015/MDL_IDE/workspace/UseCasesDemo/UseCase17/Monolix
## Done.
##
##
## The following elements were parsed successfully:
## ToolSettings
## RawResults
## TaskInformation
## Estimation:PopulationEstimates
## Estimation:PrecisionPopulationEstimates
## Estimation:IndividualEstimates
## Estimation:Residuals
## Estimation:Predictions
## Estimation:Likelihood
##
## Completed
## -- Thu Dec 10 23:59:59 2015
slotNames(mlx)
## [1] "ToolSettings" "RawResults" "TaskInformation"
## [4] "Estimation" "ModelDiagnostic" "Simulation"
## [7] "OptimalDesign" ".pathToSourceXML"
The ddmore “LoadSOObj” reads and parsed existing Standardise Output Objects mlx <- LoadSOObject(“Monolix/UseCase17.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
## 5.37458 1.00000 0.31333 0.08748 0.75000
## PPV_V PPV_KA PPV_CL ETA_V_ETA_CL RUV_ADD
## 0.03414 0.05653 0.11481 0.65273 0.07614
## RUV_PROP
## 0.08126
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.65273 5.30073 812.09
## 4 POP_CL 0.08748 0.00239 2.74
## 5 POP_KA 0.31333 0.07081 22.60
## 6 POP_V 5.37458 0.32553 6.06
## 7 PPV_CL 0.11481 0.01886 16.43
## 8 PPV_KA 0.05653 1.47407 2607.44
## 9 PPV_V 0.03414 0.23283 681.95
## 10 RUV_ADD 0.07614 0.08695 114.20
## 11 RUV_PROP 0.08126 0.04494 55.31
print(getEstimationInfo(mlx))
## $Likelihood
## $Likelihood$LogLikelihood
## [1] -22.99
##
## $Likelihood$IndividualContribToLL
## Subject ICtoLL
## 1 1 1.561
## 2 2 -3.377
## 3 3 0.022
## 4 4 -0.006
## 5 5 -0.248
## 6 6 0.408
## 7 7 -2.855
## 8 8 -2.607
## 9 9 -3.657
## 10 10 -0.204
## 11 12 0.556
## 12 13 1.366
## 13 14 -3.008
## 14 15 -3.963
## 15 16 0.724
## 16 17 -3.238
## 17 18 -0.435
## 18 19 -0.513
## 19 20 0.997
## 20 21 1.596
## 21 22 -5.037
## 22 23 0.553
## 23 24 0.060
## 24 25 1.607
## 25 26 1.066
## 26 27 0.298
## 27 28 0.659
## 28 29 -0.273
## 29 30 -3.881
## 30 31 1.078
## 31 32 -3.630
## 32 33 1.390
##
## $Likelihood$InformationCriteria
## $Likelihood$InformationCriteria$AIC
## [1] 63.98
##
## $Likelihood$InformationCriteria$BIC
## [1] 77.17
##
##
##
## $Messages
## list()
Use 'ddmore' function as.xpdb() to create an Xpose database object from the Standardised 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 00:00:19 2015
## New
## Submitted
## Job 82cce1f7-8ace-4a03-9d84-ae512ef22d9e progress:
## Running [ ........................................................................................................................................................................................................................................................................................................ ]
## Importing Results
## Copying the result data back to the local machine for job ID 82cce1f7-8ace-4a03-9d84-ae512ef22d9e...
## From C:\Users\zparra\AppData\Local\Temp\Rtmpkfi8Jd\DDMORE.jobfd01507641b to D:/SEE-1.2-SNAPSHOT-10DEC2015/MDL_IDE/workspace/UseCasesDemo/UseCase17/NONMEM
## Done.
##
##
## The following elements were parsed successfully:
## RawResults
## TaskInformation
## Estimation:PopulationEstimates
## Estimation:IndividualEstimates
## Estimation:Residuals
## Estimation:Predictions
## Estimation:Likelihood
##
## The following WARNINGs were raised during the job execution:
## minimization_successful: 0
##
## The following MESSAGEs were raised during the job execution:
## 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 01:39:11 2015
Load previous results NM <- LoadSOObject(“NONMEM/UseCase17.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 RUV_PROP RUV_ADD
## 0.0974184 6.0163400 0.2142310 0.0000000 0.0818193
## PPV_CL ETA_CL_ETA_V PPV_V PPV_KA BETA_CL_WT
## 0.1037230 0.0137532 0.4938310 0.7913950 0.7500000
## BETA_V_WT
## 1.0000000
print(parameters_mlx)
## POP_V BETA_V_WT POP_KA POP_CL BETA_CL_WT
## 5.37458 1.00000 0.31333 0.08748 0.75000
## PPV_V PPV_KA PPV_CL ETA_V_ETA_CL RUV_ADD
## 0.03414 0.05653 0.11481 0.65273 0.07614
## RUV_PROP
## 0.08126
Covariance step cannot be requested in the current version of the Framework
#print(getPopulationParameters(NM, what="precisions"))
print(getEstimationInfo(NM))
## $Likelihood
## $Likelihood$Deviance
## [1] 199.9518
##
##
## $Messages
## $Messages$Info
## $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"
##
##
## $Messages$Warnings
## $Messages$Warnings$minimization_successful
## [1] "0"
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 (graphs are exported to PDF file)
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 MOG. Note that we reuse the data and model from the previous run.
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.
NM.FOCEI <- estimate(mdlfile.FOCEI, target="PsN", subfolder="NONMEM_FOCEI")
## -- Fri Dec 11 01:39:34 2015
## New
## Submitted
## Job c5952bb9-6533-47ac-a73f-d49ed066d536 progress:
## Running [ .......... ]
## Importing Results
## Copying the result data back to the local machine for job ID c5952bb9-6533-47ac-a73f-d49ed066d536...
## From C:\Users\zparra\AppData\Local\Temp\Rtmpkfi8Jd\DDMORE.jobfd032e850ae to D:/SEE-1.2-SNAPSHOT-10DEC2015/MDL_IDE/workspace/UseCasesDemo/UseCase17/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.3
## nmoutput2so_version: This SOBlock was created with nmoutput2so version 4.5.11
##
## Completed
## -- Fri Dec 11 01:43:00 2015
Load previous results NM.FOCEI <- LoadSOObject(“NONMEM_FOCEI/UseCase17_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 RUV_PROP RUV_ADD
## 0.09856340 5.75372000 0.16700100 0.06472180 0.10357100
## PPV_CL ETA_CL_ETA_V PPV_V PPV_KA BETA_CL_WT
## 0.08795630 -0.99991500 0.14516600 0.00277821 0.75000000
## BETA_V_WT
## 1.00000000
print(parameters_nm)
## $MLE
## POP_CL POP_V POP_KA RUV_PROP RUV_ADD
## 0.0974184 6.0163400 0.2142310 0.0000000 0.0818193
## PPV_CL ETA_CL_ETA_V PPV_V PPV_KA BETA_CL_WT
## 0.1037230 0.0137532 0.4938310 0.7913950 0.7500000
## BETA_V_WT
## 1.0000000
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 Standardised Output object which is saved in a .SO.xml file. Translated files and PsN output will be returned in the ./Bootstrap subfolder
# Bootstrap
bootstrapResults <- bootstrap.PsN(mdlfile.FOCEI, samples=20, seed=123456,
bootstrapOptions=" -no-skip_minimization_terminated -threads=2",
subfolder="Bootstrap", plot=TRUE)
## -- Fri Dec 11 01:43:11 2015
## New
## Submitted
## Job aee006f6-ca54-44b9-8847-8a6b4b4d2c7d progress:
## Running [ ......................................................................................... ]
## Importing Results
## Copying the result data back to the local machine for job ID aee006f6-ca54-44b9-8847-8a6b4b4d2c7d...
## From C:\Users\zparra\AppData\Local\Temp\Rtmpkfi8Jd\DDMORE.jobfd0473f4698 to D:/SEE-1.2-SNAPSHOT-10DEC2015/MDL_IDE/workspace/UseCasesDemo/UseCase17/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 and PPV_KA 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.3
## nmoutput2so_version: This SOBlock was created with nmoutput2so version 4.5.11
##
## Completed
## -- Fri Dec 11 02:12:59 2015
## Warning: NAs introduced by coercion
## [[1]]
##
## [[2]]
## NULL
##
## [[3]]
##
## [[4]]
## NULL
##
## [[5]]
## NULL
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 RUV_PROP RUV_ADD
## 0.09856340 5.75372000 0.16700100 0.06472180 0.10357100
## PPV_CL ETA_CL_ETA_V PPV_V PPV_KA BETA_CL_WT
## 0.08795630 -0.99991500 0.14516600 0.00277821 0.75000000
## BETA_V_WT
## 1.00000000
##
## $Bootstrap
## Parameter Mean Median
## POP_CL POP_CL 0.098720100 0.098279500
## POP_V POP_V 6.018528000 6.675565000
## POP_KA POP_KA 0.182084800 0.207138000
## RUV_PROP RUV_PROP 0.058486460 0.061170650
## RUV_ADD RUV_ADD 0.117251900 0.111729000
## BETA_CL_WT BETA_CL_WT 0.750000000 0.750000000
## BETA_V_WT BETA_V_WT 1.000000000 1.000000000
## PPV_CL PPV_CL 0.006989543 0.006760175
## ETA_CL_ETA_V ETA_CL_ETA_V -0.008543571 -0.008859920
## PPV_V PPV_V 0.022891610 0.016568750
## PPV_KA PPV_KA 0.026886790 0.000001000
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.750000000 0.7500000000 0.75000000
## 2 BETA_V_WT 1.000000000 1.000000000 1.0000000000 1.00000000
## 3 ETA_CL_ETA_V -0.008543571 -0.008859920 -0.0238653350 0.01193438
## 4 POP_CL 0.098720100 0.098279500 0.0959538600 0.10304970
## 5 POP_KA 0.182084800 0.207138000 0.0201843200 0.27711340
## 6 POP_V 6.018528000 6.675565000 0.7113592000 9.11681200
## 7 PPV_CL 0.006989543 0.006760175 0.0009022537 0.01510689
## 8 PPV_KA 0.026886790 0.000001000 0.0000010000 0.32330000
## 9 PPV_V 0.022891610 0.016568750 0.0012426490 0.06350863
## 10 RUV_ADD 0.117251900 0.111729000 0.0010990000 0.22641000
## 11 RUV_PROP 0.058486460 0.061170650 0.0010000000 0.12873610
Before running the VPC with PsN we must update the (initial) values in the MDL Parameter Object MLE estimates from previous step can be used
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"
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.0985634"
##
## $POP_CL$lo
## [1] "0.001"
##
##
## $POP_V
## $POP_V$value
## [1] "5.75372"
##
## $POP_V$lo
## [1] "0.001"
##
##
## $POP_KA
## $POP_KA$value
## [1] "0.167001"
##
## $POP_KA$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.0647218"
##
## $RUV_PROP$lo
## [1] "0"
##
##
## $RUV_ADD
## $RUV_ADD$value
## [1] "0.103571"
##
## $RUV_ADD$lo
## [1] "1.0E-4"
print(myParObjUpdated@VARIABILITY)
## $PPV_CL
## $PPV_CL$value
## [1] "0.0879563"
##
## $PPV_CL$type
## [1] "sd"
##
##
## $PPV_V
## $PPV_V$value
## [1] "0.145166"
##
## $PPV_V$type
## [1] "sd"
##
##
## $PPV_KA
## $PPV_KA$value
## [1] "0.00277821"
##
## $PPV_KA$type
## [1] "sd"
##
##
## $OMEGA
## $OMEGA$parameter
## [1] "[ETA_CL,ETA_V]"
##
## $OMEGA$value
## [1] "-0.999915"
##
## $OMEGA$type
## [1] "corr"
Add square brackets around the correlation parameter
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:13:19 2015
## New
## Submitted
## Job e7afb163-06d3-48d8-884c-84909dff9278 progress:
## Running [ ..... ]
## Importing Results
## Copying the result data back to the local machine for job ID e7afb163-06d3-48d8-884c-84909dff9278...
## From C:\Users\zparra\AppData\Local\Temp\Rtmpkfi8Jd\DDMORE.jobfd07b6e5c23 to D:/SEE-1.2-SNAPSHOT-10DEC2015/MDL_IDE/workspace/UseCasesDemo/UseCase17/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:15:04 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,logtWT=0)
Parameter values used in simulation
print(p)
## POP_CL POP_V POP_KA RUV_PROP RUV_ADD
## 0.09856340 5.75372000 0.16700100 0.06472180 0.10357100
## PPV_CL ETA_CL_ETA_V PPV_V PPV_KA BETA_CL_WT
## 0.08795630 -0.99991500 0.14516600 0.00277821 0.75000000
## BETA_V_WT logtWT
## 1.00000000 0.00000000
Simulate PK parameters for individuals
ind <- list(name = c('KA','CL','V'))
Simulate predicted (CC) and observed concentration values (Y)
f <- list( name = c('CC'), time = seq(0,to=50,by=1))
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(target='GUT', 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,f,y))
Simulated parameter values for each individual
print(res$parameter)
## id KA CL V
## 1 1 0.1676416 0.09553197 5.464588
## 2 2 0.1677613 0.11026896 6.924475
## 3 3 0.1674141 0.11346807 7.259152
## 4 4 0.1679011 0.09175419 5.112545
## 5 5 0.1676249 0.09230628 5.163416
## 6 6 0.1663485 0.10371960 6.258897
## 7 7 0.1671964 0.08043317 4.113842
## 8 8 0.1662909 0.10673511 6.562055
## 9 9 0.1675347 0.09338455 5.263341
## 10 10 0.1667139 0.10455684 6.342501
## 11 11 0.1673885 0.10383611 6.270505
## 12 12 0.1673323 0.09509716 5.423599
Plot simulated results
plot(ggplot() +
geom_line(data=res$CC, aes(x=time, y=CC, colour=id)) +
geom_point(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.2271949 -0.117045 -0.09099564 -0.06551882 -0.04708754
## 2 0.5 0.7867271 1.092011 1.19216465 1.26048813 1.32920572
## 3 1.0 1.8007756 2.133763 2.27849963 2.40560580 2.50131465
## 4 2.0 3.1814587 3.796048 4.20878659 4.42436307 4.60051325
## 5 3.0 4.3954278 5.360571 5.77428160 6.09839656 6.34699302
## 6 4.0 5.6664288 6.412169 6.93166778 7.32095805 7.76084471
## 7 6.0 6.9779476 8.202153 8.79241430 9.15894655 9.67314178
## 8 8.0 7.6854556 9.726391 10.14033823 10.71705379 11.11968520
## 9 12.0 8.7860365 10.434416 11.42729828 11.97925315 12.49650149
## 10 24.0 8.8333969 10.435621 10.80590494 11.33601566 11.73901753
## 11 36.0 7.6263210 8.525023 9.18945457 9.62794675 9.96339664
## 12 48.0 5.4659926 6.796237 7.30166737 7.90397915 8.16586747
## 50% 50% 60% 70% 80% 90%
## 1 -0.01953968 -0.01953968 0.01171477 0.03456146 0.0646686 0.1266739
## 2 1.37291418 1.37291418 1.43424912 1.49462476 1.5888042 1.7252482
## 3 2.56891034 2.56891034 2.67888891 2.80812499 2.8944633 3.2029206
## 4 4.73423237 4.73423237 4.92365385 5.14204972 5.5214924 5.8163330
## 5 6.63523120 6.63523120 6.87563509 7.08354845 7.5409212 8.0311376
## 6 8.08701847 8.08701847 8.30253421 8.70607471 9.1057014 10.0794743
## 7 10.13033844 10.13033844 10.46578408 11.21227829 12.0415388 12.7832977
## 8 11.26257385 11.26257385 11.63340706 12.25390639 12.7713269 13.7006879
## 9 12.81887366 12.81887366 13.35643223 14.04437673 14.5775884 15.5327355
## 10 12.10382734 12.10382734 12.40599429 12.94824303 13.8483183 15.0057187
## 11 10.19166361 10.19166361 10.59660109 11.09832547 11.4446835 12.5693041
## 12 8.42904092 8.42904092 8.60163787 8.89087224 9.1608519 9.6536129
## 100%
## 1 0.3021204
## 2 2.1022072
## 3 4.1478285
## 4 8.2937805
## 5 10.6979617
## 6 13.0238046
## 7 14.9825477
## 8 17.6795218
## 9 19.5806900
## 10 19.2570074
## 11 15.2963055
## 12 12.7296310