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<-"UseCase11"
datafile <- "count.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] "count.csv" "UseCase11.mdl"
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] "Poisson_DIST_dat" "Poisson_DIST_par" "Poisson_DIST_mdl"
## [4] "Poisson_DIST_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 CP DV MDV
## 1 1 0.00 0.0000 0 1
## 2 1 0.00 0.0000 7 0
## 3 1 0.25 1.0089 9 0
## 4 1 2.00 5.5795 131 0
## 5 1 6.00 7.5844 332 0
## 6 1 24.00 1.7112 17 0
Extract only observation records
myEDAData<-myData[myData$MDV==0,]
head(myEDAData)
## ID TIME CP DV MDV
## 2 1 0.00 0.0000 7 0
## 3 1 0.25 1.0089 9 0
## 4 1 2.00 5.5795 131 0
## 5 1 6.00 7.5844 332 0
## 6 1 24.00 1.7112 17 0
## 8 2 0.00 0.0000 9 0
Open an R window to record and access all your plots
windows(record=TRUE)
Now plot the data using xyplot from the lattice library
plot1 <- xyplot(DV~TIME,groups=ID,data=myEDAData,type="b",ylab="Counts",xlab="Time (h)")
print(plot1)
plot2 <- xyplot(DV~CP,groups=ID,data=myEDAData,type="b",ylab="Counts",xlab="Conc")
print(plot2)
plot3 <- histogram(~DV, data=myEDAData, xlab="", type="count")
print(plot3)
Export results to a PDF file
pdf(paste0(uc,"_EGA.pdf"))
print(plot1)
print(plot2)
print(plot3)
dev.off()
## rj.GD
## 2
Compute mean and variances for each id
stats <- ddply(myEDAData, .(ID), summarise, mean=mean(DV), var=var(DV))
## Error in eval(expr, envir, enclos): could not find function "ddply"
plot(xyplot(log(var)~log(mean),data=stats,
main="Mean-Variance Plot",ylab="log(Individual variance)",xlab="log(Individual mean)"))
## Error in eval(substitute(groups), data, environment(x)): object 'stats' not found
Compute the frequency of counts up to 10 for the Poissonness plot (Plan et al, CPT:PsP,2014)
library(plyr)
poiss <- count(myEDAData,"DV")
poiss$metameter<- log(poiss$freq) + lfactorial(poiss$DV) -log(sum(poiss$freq))
plot(xyplot(metameter~DV,data=poiss[poiss$DV<1000,],
main="Poissonness plot",ylab="Count metameter",xlab="Count"))
How many observations per ID?
library(tables)
## Loading required package: Hmisc
## Loading required package: survival
## Loading required package: Formula
##
## Attaching package: 'Hmisc'
##
## The following objects are masked from 'package:plyr':
##
## is.discrete, summarize
##
## The following objects are masked from 'package:base':
##
## format.pval, round.POSIXt, trunc.POSIXt, units
tabular(~(ID=as.factor(ID)), data=myEDAData)
##
## ID
## 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
## 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
##
##
## 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
## 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
##
##
## 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
## 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
##
##
## 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
## 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
##
##
## 99 100
## 5 5
tabular(~(DV=as.factor(DV)), data=myEDAData)
##
## DV
## 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
## 2 5 8 8 20 8 10 21 17 15 22 16 14 14 13 10 10 12 5 4 8 6 2 6 8
##
##
## 28 29 30 31 32 33 34 35 37 38 41 45 46 47 49 50 52 54 56 58 59 61 63 69
## 2 6 3 3 6 4 2 3 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1 1
##
##
## 71 73 78 82 83 86 89 90 91 92 93 95 96 97 98 101 103 104 105 109 110 113
## 2 2 2 1 1 1 2 1 3 3 1 1 1 1 2 3 1 1 1 1 2 1
##
##
## 116 117 120 121 123 127 128 131 132 133 135 138 143 147 150 152 154 156
## 1 2 1 1 1 1 1 1 1 2 3 2 1 2 3 2 3 1
##
##
## 157 160 164 165 170 174 176 180 183 184 187 188 192 193 194 195 196 202
## 1 1 1 1 1 1 1 1 1 2 2 1 1 2 1 1 1 1
##
##
## 203 207 215 216 217 218 219 222 223 224 226 228 230 232 238 239 242 243
## 1 1 1 1 2 2 1 1 3 1 1 1 4 2 1 1 1 1
##
##
## 244 245 247 251 252 254 259 268 275 277 278 284 289 290 293 305 319 320
## 2 1 1 2 3 2 1 2 2 1 2 1 1 1 1 1 1 1
##
##
## 321 323 326 331 332 339 344 346 350 354 364 365 373 379 384 390 401 404
## 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
##
##
## 409 435 441 459 465 474 508 517 590 593 597 647 657 665 684 714 716 746
## 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
##
##
## 793 820 933 951 981 1008 1018 1037 1142 1168 1885 1999 2881 3020 4360
## 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
##
##
## 4494
## 1
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")
## -- Fri Dec 11 02:27:22 2015
## New
## Submitted
## Job 4f3a9e6c-880d-4778-ae00-129c17dd960e progress:
## Running [ ....... ]
## Importing Results
## Copying the result data back to the local machine for job ID 4f3a9e6c-880d-4778-ae00-129c17dd960e...
## From C:\Users\zparra\AppData\Local\Temp\Rtmpkfi8Jd\DDMORE.jobfd05baf1ea1 to D:/SEE-1.2-SNAPSHOT-10DEC2015/MDL_IDE/workspace/UseCasesDemo/UseCase11/Monolix
## Done.
##
## Failed
## -- Fri Dec 11 02:29:45 2015
## Error in DDMORE.performExecutionWorkflow(submission, fisServer = fisServer, : Execution of model D:\SEE-1.2-SNAPSHOT-10DEC2015\MDL_IDE\workspace\UseCasesDemo\UseCase11\UseCase11.mdl failed.
## The contents of the working directory D:/SEE-1.2-SNAPSHOT-10DEC2015/MDL_IDE/workspace/UseCasesDemo/UseCase11/Monolix may be useful for tracking down the cause of the failure.
## Additionally, the submission object has been saved to the hidden variable .ddmoreFailedSubmission in the workspace; internal errors should have been captured in .ddmoreFailedSubmission$error$message.
There is a bug in the execution process and the SO is not generated, so the execution fails, however, the raw results from Monolix execution can be seen under the Monolix subfolderslotNames(mlx) The ddmore “LoadSOObj” reads and parsed existing Standardise Output Objects mlx <- LoadSOObject(“Monolix/UseCase11.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)
#print(getPopulationParameters(mlx, what="precisions"))
#print(getEstimationInfo(mlx))
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”.
NM <- estimate(mdlfile, target="NONMEM", subfolder="NONMEM")
## -- Fri Dec 11 02:29:45 2015
## New
## Submitted
## Job 0923097d-fcc9-4482-be3c-617d26886caf progress:
## Running [ ... ]
## Importing Results
## Copying the result data back to the local machine for job ID 0923097d-fcc9-4482-be3c-617d26886caf...
## From C:\Users\zparra\AppData\Local\Temp\Rtmpkfi8Jd\DDMORE.jobfd048163a10 to D:/SEE-1.2-SNAPSHOT-10DEC2015/MDL_IDE/workspace/UseCasesDemo/UseCase11/NONMEM
## Done.
##
##
## The following elements were parsed successfully:
## RawResults
## TaskInformation
## Estimation:PopulationEstimates
## Estimation:IndividualEstimates
## 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: 4.1
## nmoutput2so_version: This SOBlock was created with nmoutput2so version 4.5.11
##
## Completed
## -- Fri Dec 11 02:30:49 2015
Load previous results
NM <- LoadSOObject(“NONMEM/UseCase11.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.
Results from NONMEM should be comparable with results from MONOLIX
parameters_nm <- getPopulationParameters(NM, what="estimates")
print(parameters_nm)
## $MLE
## POP_BASECOUNT POP_BETA PPV_EVENT
## 10.0443000 0.5011100 0.0395245
#print(parameters_mlx)
Covariance step cannot be requested in the current version of the Framework
#print(getPopulationParameters(NM, what="precisions"))
print(getEstimationInfo(NM))
## $Likelihood
## $Likelihood$Deviance
## [1] 3559.859
##
##
## $Messages
## $Messages$Info
## $Messages$Info$minimization_successful
## [1] "1"
##
## $Messages$Info$covariance_step_run
## [1] "0"
##
## $Messages$Info$rounding_errors
## [1] "0"
##
## $Messages$Info$hessian_reset
## [1] "0"
##
## $Messages$Info$zero_gradients
## [1] "0"
##
## $Messages$Info$final_zero_gradients
## [1] "0"
##
## $Messages$Info$estimate_near_boundary
## [1] "0"
##
## $Messages$Info$s_matrix_singular
## [1] "0"
##
## $Messages$Info$significant_digits
## [1] "4.1"
##
## $Messages$Info$nmoutput2so_version
## [1] "This SOBlock was created with nmoutput2so version 4.5.11"
Xpose diagnostics using NONMEM output
There is a bug in the generation of xpose database
nm.xpdb<-as.xpdb(NM,datafile)
## Warning in as.data(SOObject, inputDataPath): No Estimation::Predictions
## found in the SO; the resulting data frame will not contain these
## Warning in as.data(SOObject, inputDataPath): No Estimation::Residuals
## found in the SO; the resulting data frame will not contain these
Perform some basic goodness of fit
print(parm.hist(nm.xpdb, inclZeroWRES=TRUE))
Export graphs to a PDF file
pdf("GOF_NM.pdf")
print(parm.hist(nm.xpdb, inclZeroWRES=TRUE))
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 <- "foce"
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.FOCE <- paste0(uc,"_FOCE.mdl")
writeMogObj(myNewerMOG,mdlfile.FOCE)
Test estimation using this new MOG in NONMEM via PsN
NM.FOCE <- estimate(mdlfile.FOCE, target="PsN", subfolder="NONMEM_FOCE")
## -- Fri Dec 11 02:31:04 2015
## New
## Submitted
## Job 5f86604a-c7be-442b-95b2-4ea7ac590b00 progress:
## Running [ ... ]
## Importing Results
## Copying the result data back to the local machine for job ID 5f86604a-c7be-442b-95b2-4ea7ac590b00...
## From C:\Users\zparra\AppData\Local\Temp\Rtmpkfi8Jd\DDMORE.jobfd045696baa to D:/SEE-1.2-SNAPSHOT-10DEC2015/MDL_IDE/workspace/UseCasesDemo/UseCase11/NONMEM_FOCE
## Done.
##
##
## The following elements were parsed successfully:
## RawResults
## TaskInformation
## Estimation:PopulationEstimates
## Estimation:IndividualEstimates
## 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: 4.1
## nmoutput2so_version: This SOBlock was created with nmoutput2so version 4.5.11
##
## Completed
## -- Fri Dec 11 02:32:08 2015
The ddmore “LoadSOObj” reads and parsed existing Standardise Output Objects NM.FOCE <- LoadSOObject(“NONMEM_FOCE/UseCase11_FOCE.SO.xml”) Results from NONMEM should be comparable to previous results
getPopulationParameters(NM.FOCE, what="estimates")$MLE
## POP_BASECOUNT POP_BETA PPV_EVENT
## 10.0443000 0.5011100 0.0395245
parameters_nm
## $MLE
## POP_BASECOUNT POP_BETA PPV_EVENT
## 10.0443000 0.5011100 0.0395245
#parameters_mlx
Covariance step cannot be requested in the current version of the Framework
#getPopulationParameters(NM, what="precisions")
nmfoce.xpdb<-as.xpdb(NM.FOCE,datafile)
## Warning in as.data(SOObject, inputDataPath): No Estimation::Predictions
## found in the SO; the resulting data frame will not contain these
## Warning in as.data(SOObject, inputDataPath): No Estimation::Residuals
## found in the SO; the resulting data frame will not contain these
Basic diagnostics for NONMEM fit.
print(parm.hist(nmfoce.xpdb, inclZeroWRES=TRUE))
Export graphs to a PDF file
pdf("GOF_NM_FOCE.pdf")
print(parm.hist(nmfoce.xpdb, inclZeroWRES=TRUE))
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
bootstrapResults <- bootstrap.PsN(mdlfile.FOCE, samples=20, seed=12345,
bootstrapOptions=" -no-skip_minimization_terminated -threads=2",
subfolder="Bootstrap", plot=TRUE)
## -- Fri Dec 11 02:32:13 2015
## New
## Submitted
## Job cdd7e3c3-635a-4789-b77d-1686be987cc4 progress:
## Running [ ...... ]
## Importing Results
## Copying the result data back to the local machine for job ID cdd7e3c3-635a-4789-b77d-1686be987cc4...
## From C:\Users\zparra\AppData\Local\Temp\Rtmpkfi8Jd\DDMORE.jobfd02d16052 to D:/SEE-1.2-SNAPSHOT-10DEC2015/MDL_IDE/workspace/UseCasesDemo/UseCase11/Bootstrap
## Done.
##
##
## The following elements were parsed successfully:
## RawResults
## TaskInformation
## Estimation:PopulationEstimates
## Estimation:PrecisionPopulationEstimates
## Estimation:IndividualEstimates
## 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: 4.1
## nmoutput2so_version: This SOBlock was created with nmoutput2so version 4.5.11
##
## Completed
## -- Fri Dec 11 02:34:17 2015
## [[1]]
##
## [[2]]
## NULL
##
## [[3]]
##
## [[4]]
## NULL
##
## [[5]]
## NULL
Load results from a bootstrap previously performed bootstrapResults <- LoadSOObject(“Bootstrap/UseCase11.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,"_FOCE.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.
getPopulationParameters(bootstrapResults, what="estimates")
## $MLE
## POP_BASECOUNT POP_BETA PPV_EVENT
## 10.0443000 0.5011100 0.0395245
##
## $Bootstrap
## Parameter Mean Median
## POP_BASECOUNT POP_BASECOUNT 10.05172000 10.0617500
## POP_BETA POP_BETA 0.50087290 0.5004300
## PPV_EVENT PPV_EVENT 0.03998502 0.0385686
Extract the information regarding the precision intervals
getPopulationParameters(bootstrapResults,what="intervals")$Bootstrap
## Warning in getMLEPopulationParameters(SOObject, what = what): Tried to fetch the parameter interval values, however section PrecisionPopulationEstimates$MLE$AsymptoticCI was not found in the SO Object
## Omitting interval values for MLE section in returned output.
## Parameter Mean Median Perc_5 Perc_95
## 1 POP_BASECOUNT 10.05172000 10.0617500 9.37975200 10.70909000
## 2 POP_BETA 0.50087290 0.5004300 0.49675090 0.50550740
## 3 PPV_EVENT 0.03998502 0.0385686 0.03162865 0.05334042
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.FOCE, what="estimates",block='structural')$MLE
variabilityPar <- getPopulationParameters(NM.FOCE, what="estimates",block='variability')$MLE
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.
myParObjUpdated@STRUCTURAL
## $POP_BASECOUNT
## $POP_BASECOUNT$value
## [1] "10.0443"
##
## $POP_BASECOUNT$lo
## [1] "0"
##
##
## $POP_BETA
## $POP_BETA$value
## [1] "0.50111"
##
## $POP_BETA$lo
## [1] "0"
##
## $POP_BETA$hi
## [1] "10"
myParObjUpdated@VARIABILITY
## $PPV_EVENT
## $PPV_EVENT$value
## [1] "0.0395245"
##
## $PPV_EVENT$type
## [1] "var"
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
# VPC with TIME as idv
vpcFiles_TIME <- VPC.PsN(mdlfile.VPC,samples=20, seed=12345,
vpcOptions ="-n_simulation=10 -flip_comments",
subfolder="VPC_TIME", plot=TRUE)
## -- Fri Dec 11 02:34:35 2015
## New
## Submitted
## Job 026c4331-f783-45da-a864-99f25228d957 progress:
## Running [ .... ]
## Importing Results
## Copying the result data back to the local machine for job ID 026c4331-f783-45da-a864-99f25228d957...
## From C:\Users\zparra\AppData\Local\Temp\Rtmpkfi8Jd\DDMORE.jobfd03a412ce to D:/SEE-1.2-SNAPSHOT-10DEC2015/MDL_IDE/workspace/UseCasesDemo/UseCase11/VPC_TIME
## 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:36:01 2015
CP can also be used as idv to perform a VPC
# VPC with CP as idv
vpcFiles_CP <- VPC.PsN(mdlfile.VPC,samples=20, seed=12345,
vpcOptions ="-n_simulation=10 -flip_comments -idv=CP",
subfolder="VPC_CP", plot=TRUE)
## -- Fri Dec 11 02:36:02 2015
## New
## Submitted
## Job a890a501-ebbf-4141-91b4-e5e294eba1fd progress:
## Running [ ...... ]
## Importing Results
## Copying the result data back to the local machine for job ID a890a501-ebbf-4141-91b4-e5e294eba1fd...
## From C:\Users\zparra\AppData\Local\Temp\Rtmpkfi8Jd\DDMORE.jobfd04a1119c to D:/SEE-1.2-SNAPSHOT-10DEC2015/MDL_IDE/workspace/UseCasesDemo/UseCase11/VPC_CP
## Done.
##
##
## The following elements were parsed successfully:
## RawResults
## TaskInformation
##
## 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:38:05 2015
To replay the visualisation using information from the VPC SO file
library("gridExtra")
pdf(paste0(uc,"_VPC.pdf"))
plot_CP <- xpose.VPC(vpc.info=file.path("./VPC_CP", vpcFiles_CP@RawResults@DataFiles$PsN_VPC_results$path),
vpctab=file.path("./VPC_CP", vpcFiles_CP@RawResults@DataFiles$PsN_VPC_vpctab$path),
main="",
logy=TRUE)
plot_T <- xpose.VPC(vpc.info=file.path("./VPC_TIME", vpcFiles_TIME@RawResults@DataFiles$PsN_VPC_results$path),
vpctab=file.path("./VPC_TIME", vpcFiles_TIME@RawResults@DataFiles$PsN_VPC_vpctab$path),
main="",
logy=TRUE)
grid.arrange(plot_CP,plot_T, ncol=2)
dev.off()
## rj.GD
## 2
Simulx cannot be used for count data in the current version
# #' 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.FOCE, what="estimates")$MLE
# #' Parameter values used in simulation
#print(p)
# #' Simulate PK parameters for individuals
#ind <- list(name = c('indiv_BASECOUNT','BETA'))
# #' 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 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)
# #' 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,f,y))
# #' Plot of predicted concentrations
# #' 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.
# #' Plot of observed concentrations (with residual error)
#prctilemlx(res.1000$Y,band=list(number=9, level=90))
# #' Table of the same information
#prctilemlx(res.1000$Y,band=list(number=10, level=100), plot=F)$y