write_ModelTemplateTokens.Rd
This function generates and writes the model template and tokens files based on the provided inputs.
write_ModelTemplateTokens(
TemplateFilePath = "template.txt",
TokensFilePath = "tokens.json",
Description = "",
Author = "",
DataFilePath,
DataMapping = NULL,
ColDef = "",
PMLParametersSets,
EstArgs = specify_EngineParams(),
SimArgs = "",
Tables = list(),
AppendixRows = "",
OmegaSearchBlocks = list()
)
TemplateFilePath NLME template file path to be written (usually txt).
json file path to be written (usually json).
A problem name to be outputted in Description section.
The author information for the model to be outputted in Author section.
A data file path used by NLME.
A named vector ModelTerm = DataTerm for the used data file.
A character string specifying additional column definitions in NLME column definition format. See https://onlinehelp.certara.com/phoenix/8.4/index.html#t=Phoenix_UserDocs%2FPML%2FColumn_mappings.htm
A list of PML parameters sets (PMLModels
class
instance).
Estimation arguments for the model template. Please use
specify_EngineParams
to specify the arguments passed to NLME.
Simulation arguments for the model template. Please use
specify_SimParams
to specify the arguments passed to NLME.
A list of Table
class instances specifying properties of the
tables to be generated after fitting or during simulation.
Additional rows to include in the model template appendix in NLME column definition format. See https://onlinehelp.certara.com/phoenix/8.4/index.html#t=Phoenix_UserDocs%2FPML%2FColumn_mappings.htm
A list of character vectors representing omega names to try to build block omegas.
Terms <DosepointName>_Duration
or <DosepointName>_Rate
could be
used to map rate/duration columns for the current dosepoints. Term
<ObservationName>BQL
could be used to map BQL flag for the current
observation. AMT
term could be used to map different main dosepoints (i.e.
A1 will be mapped for Gamma
, Aa for First-Order
absorption etc.) If AMT
term is used, additional terms Duration
or Rate
could be used; current
function will map it to the main dosepoint of each Parameter set. But it is
possible to map duration/rate for some dosepoint directly using terms
<DosepointName>_Duration
or <DosepointName>_Rate
, it will override
Duration
or Rate
terms mapping for current dosepoint.
# Write model template and tokens files
PMLParametersSets <- get_PMLParametersSets(CompartmentsNumber = c(1,2))
# write test data frame
TempFolder <- tempdir()
TemplateFilePath <- file.path(TempFolder, "template.txt")
TokensFilePath <- file.path(TempFolder, "tokens.json")
DataFilePath <- file.path(TempFolder, "Data.csv")
write.csv(data.frame(id = 'id',
time = 'time',
AMT = 'AMT',
Conc = 'Conc',
age = 'age',
Weight = 'Weight',
CObsBQL = 'CObsBQL'),
DataFilePath)
write_ModelTemplateTokens(TemplateFilePath = TemplateFilePath,
TokensFilePath = TokensFilePath,
Description = "1-2Cpts try",
Author = "Certara",
DataFilePath = DataFilePath,
DataMapping = c(ID = "id",
time = "time",
CObs = "Conc",
AMT = "AMT",
"age"),
ColDef = "",
PMLParametersSets = PMLParametersSets,
EstArgs = specify_EngineParams(method = "QRPEM"),
SimArgs = specify_SimParams(numReplicates = 1000L),
Tables = list(Table(Name = "simtable1.csv",
KeepSource = TRUE,
VariablesList = "C",
ForSimulation = TRUE)),
OmegaSearchBlocks = list(c("nCl", "nV"), c("nCl2", "nV2")))
#> information stored in C:\Users\jcraig\AppData\Local\Temp\Rtmps7jk7g/template.txt and C:\Users\jcraig\AppData\Local\Temp\Rtmps7jk7g/tokens.json
#> $TokensList
#> $TokensList$PML
#> $TokensList$PML$PK1IVC
#> MAPText
#> " A1 = AMT CObs = Conc"
#> PMLText
#> "test() {\n\tcfMicro(A1, Cl / V)\n\tC = A1 / V\n\tdosepoint(A1, idosevar = A1Dose, infdosevar = A1InfDose, infratevar = A1InfRate)\n\terror(CEps = 0.1)\n\tobserve(CObs = C * (1 + CEps))\n\t\n\tstparm(Cl = tvCl * exp( nCl ))\n\tfixef(tvCl= c(, 1, ))\n\tranef(diag(nCl) = c(1))\n\tstparm(V = tvV * exp( nV ))\n\tfixef(tvV= c(, 1, ))\n\tranef(diag(nV) = c(1))\n\n\t#search_block(nCl, nV)\n}"
#>
#> $TokensList$PML$PK2IVC
#> MAPText
#> " A1 = AMT CObs = Conc"
#> PMLText
#> "test() {\n\tcfMicro(A1, Cl / V, Cl2 / V, Cl2 / V2)\nC = A1 / V\n\tdosepoint(A1, idosevar = A1Dose, infdosevar = A1InfDose, infratevar = A1InfRate)\n\terror(CEps = 0.1)\n\tobserve(CObs = C * (1 + CEps))\n\t\n\tstparm(Cl = tvCl * exp( nCl ))\n\tfixef(tvCl= c(, 1, ))\n\tranef(diag(nCl) = c(1))\n\tstparm(V = tvV * exp( nV ))\n\tfixef(tvV= c(, 1, ))\n\tranef(diag(nV) = c(1))\n\tstparm(Cl2 = tvCl2 * exp( nCl2 ))\n\tfixef(tvCl2= c(, 1, ))\n\tranef(diag(nCl2) = c(1))\n\tstparm(V2 = tvV2 * exp( nV2 ))\n\tfixef(tvV2= c(, 1, ))\n\tranef(diag(nV2) = c(1))\n\n\t#search_block(nCl, nV)\n\t#search_block(nCl2, nV2)\n}"
#>
#>
#>
#> $Template
#> $Template$Description
#> [1] "##Description: 1-2Cpts try"
#>
#> $Template$Author
#> [1] "##Author: Certara"
#>
#> $Template$DATA
#> [1] "##DATA {data_dir}/Data.csv"
#>
#> $Template$MAP
#> [1] "##MAP {PML[1]} ID = id time = time age = age"
#>
#> $Template$MODEL
#> [1] "##MODEL {PML[2]}"
#>
#> $Template$ESTARGS
#> [1] "##ESTARGS\n sort=FALSE method=QRPEM"
#>
#> $Template$SIMARGS
#> [1] "##SIMARGS\n numReplicates=1000 seed=1234 sort=FALSE"
#>
#> $Template$TABLES
#> [1] "##TABLES\nsimtbl(file=\"simtable1.csv\", C, mode = keep)\n"
#>
#>