From 683e8b7f9506155222bc70bec6a7ab49e62b3f74 Mon Sep 17 00:00:00 2001 From: "Matthew L. Fidler" Date: Sat, 25 May 2024 07:59:23 -0500 Subject: [PATCH 1/4] Add to news and add run=TRUE option --- DESCRIPTION | 2 +- NEWS.md | 8 ++++++++ R/monolixControl.R | 7 ++++++- R/monolixNlmixr2est.R | 4 ++++ R/nonmemControl.R | 22 +++++++++++++++------- R/nonmemNlmixr2est.R | 6 +++++- 6 files changed, 39 insertions(+), 10 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3339a0d7..2880c456 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: babelmixr2 Type: Package Title: Use 'nlmixr2' to Interact with Open Source and Commercial Software -Version: 0.1.2 +Version: 0.1.3 Authors@R: c(person("Matthew","Fidler", role = c("aut", "cre"), email = "matthew.fidler@gmail.com", comment=c(ORCID="0000-0001-8538-6691")), person("Bill", "Denney", email="wdenney@humanpredictions.com", role="aut", comment=c(ORCID="0000-0002-5759-428X")), person("Nook", "Fulloption", role="ctb", comment="goldfish art")) diff --git a/NEWS.md b/NEWS.md index 9ae51423..52d250af 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,11 @@ +# babelmixr2 0.1.3 + +* Changed default NONMEM rounding protection to FALSE + +* Added a `run` option to the `monolixControl()` and `nonemControl()` + in case you only want to export the modeling files and not run the + models. + # babelmixr2 0.1.2 * Handle algebraic `mu` expressions diff --git a/R/monolixControl.R b/R/monolixControl.R index 4a195433..46ea082d 100644 --- a/R/monolixControl.R +++ b/R/monolixControl.R @@ -34,6 +34,8 @@ #' monolix. See details for function usage. #' @param absolutePath Boolean indicating if the absolute path should #' be used for the monolix runs +#' +#' @param run Should monolix be run and the results be imported to nlmixr2? (Default is TRUE) #' @inheritParams nonmemControl #' @inheritParams nlmixr2est::saemControl #' @return A monolix control object @@ -92,6 +94,7 @@ monolixControl <- function(nbSSDoses=7, absolutePath=FALSE, modelName=NULL, muRefCovAlg=TRUE, + run=TRUE, ...) { checkmate::assertLogical(stiff, max.len=1, any.missing=FALSE) checkmate::assertLogical(exploratoryAutoStop, max.len=1, any.missing=FALSE) @@ -109,6 +112,7 @@ monolixControl <- function(nbSSDoses=7, checkmate::assertNumeric(exploratoryAlpha, lower=0.0, upper=1.0) checkmate::assertNumeric(omegaTau, lower=0.0, upper=1.0) checkmate::assertNumeric(errorModelTau, lower=0.0, upper=1.0) + checkmate::assertLogical(run, len=1, any.missing=FALSE) if (!is.null(modelName)) { checkmate::assertCharacter(modelName, len=1, any.missing=FALSE) @@ -197,7 +201,8 @@ monolixControl <- function(nbSSDoses=7, genRxControl=genRxControl, useLinearization=useLinearization, modelName=modelName, - muRefCovAlg=muRefCovAlg) + muRefCovAlg=muRefCovAlg, + run=run) class(.ret) <- "monolixControl" .ret } diff --git a/R/monolixNlmixr2est.R b/R/monolixNlmixr2est.R index 3e05701f..3fb53cdd 100644 --- a/R/monolixNlmixr2est.R +++ b/R/monolixNlmixr2est.R @@ -253,6 +253,10 @@ writeLines(text=.hashMd5, con=.hashFile) write.csv(.dataDf, file=.csv, na = ".", row.names = FALSE) .minfo("done") + if (!rxode2::rxGetControl(.ui, "run", TRUE)) { + .minfo("only exported Monolix mlxtran, txt model and data") + return(invisible()) + } .runLS <- FALSE .cmd <- rxode2::rxGetControl(.ui, "runCommand", "") if (!identical(.cmd, "")) { diff --git a/R/nonmemControl.R b/R/nonmemControl.R index d96c42d1..f6573bd0 100644 --- a/R/nonmemControl.R +++ b/R/nonmemControl.R @@ -27,15 +27,16 @@ #' @param tol NONMEM tolerance for ODE solving advan #' @param atol NONMEM absolute tolerance for ODE solving #' @param sstol NONMEM tolerance for steady state ODE solving -#' @param ssatol NONMEM absolute tolerance for steady state ODE solving +#' @param ssatol NONMEM absolute tolerance for steady state ODE +#' solving #' @param sigl NONMEM sigl estimation option #' @param sigdig the significant digits for NONMEM #' @param print The print number for NONMEM #' @param extension NONMEM file extensions #' @param outputExtension Extension to use for the NONMEM output #' listing -#' @param runCommand Command to run NONMEM (typically the path to "nmfe75") or a -#' function. See the details for more information. +#' @param runCommand Command to run NONMEM (typically the path to +#' "nmfe75") or a function. See the details for more information. #' @param iniSigDig How many significant digits are printed in $THETA #' and $OMEGA when the estimate is zero. Also controls the zero #' protection numbers @@ -45,14 +46,15 @@ #' simulations #' @param mapiter the number of map iterations for IMP method #' @param niter number of iterations in NONMEM estimation methods -#' @param isample Isample argument for NONMEM ITS estimation method +#' @param isample Isample argument for NONMEM ITS estimation method #' @param iaccept Iaccept for NONMEM ITS estimation methods #' @param iscaleMin parameter for IMP NONMEM method (ISCALE_MIN) #' @param iscaleMax parameter for IMP NONMEM method (ISCALE_MAX) #' @param df degrees of freedom for IMP method #' @param seed is the seed for NONMEM methods #' @param mapinter is the MAPINTER parameter for the IMP method -#' @param addProp,sumProd,optExpression,calcTables,compress,ci,sigdigTable +#' @param +#' addProp,sumProd,optExpression,calcTables,compress,ci,sigdigTable #' Passed to \code{nlmixr2est::foceiControl} #' @param readRounding Try to read NONMEM output when NONMEM #' terminated due to rounding errors @@ -62,6 +64,9 @@ #' @param modelName Model name used to generate the NONMEM output. If #' `NULL` try to infer from the model name (could be `x` if not #' clear). Otherwise use this character for outputs. +#' @param run Should NONMEM be run (and the files imported to +#' nlmixr2); default is TRUE, but FALSE will simply create the +#' NONMEM control stream and data file. #' @param ... optional \code{genRxControl} argument controlling #' automatic \code{rxControl} generation. #' @@ -93,7 +98,7 @@ nonmemControl <- function(est=c("focei", "imp", "its", "posthoc"), outputExtension=getOption("babelmixr2.nmOutputExtension", ".lst"), runCommand=getOption("babelmixr2.nonmem", ""), iniSigDig=5, - protectZeros=TRUE, + protectZeros=FALSE, muRef=TRUE, addProp = c("combined2", "combined1"), rxControl=NULL, @@ -117,6 +122,7 @@ nonmemControl <- function(est=c("focei", "imp", "its", "posthoc"), noabort=TRUE, modelName=NULL, muRefCovAlg=TRUE, + run=TRUE, ...) { # nonmem manual slides suggest tol=6, sigl=6 sigdig=2 checkmate::assertIntegerish(maxeval, lower=100, len=1, any.missing=FALSE) @@ -142,6 +148,7 @@ nonmemControl <- function(est=c("focei", "imp", "its", "posthoc"), checkmate::assertIntegerish(seed, lower=1, len=1, any.missing=FALSE) checkmate::assertIntegerish(mapiter, len=1, any.missing=FALSE) checkmate::assertLogical(muRefCovAlg, any.missing=FALSE, len=1) + checkmate::assertLogical(run, any.missing=FALSE, len=1) if (!is.null(modelName)) { checkmate::assertCharacter(modelName, len=1, any.missing=FALSE) } @@ -240,7 +247,8 @@ nonmemControl <- function(est=c("focei", "imp", "its", "posthoc"), seed=seed, mapiter=mapiter, modelName=modelName, - muRefCovAlg=muRefCovAlg + muRefCovAlg=muRefCovAlg, + run=run ) class(.ret) <- "nonmemControl" .ret diff --git a/R/nonmemNlmixr2est.R b/R/nonmemNlmixr2est.R index 71460f45..f9a0db56 100644 --- a/R/nonmemNlmixr2est.R +++ b/R/nonmemNlmixr2est.R @@ -207,6 +207,10 @@ quote=FALSE) .minfo("done") } + if (!rxode2::rxGetControl(.ui, "run", TRUE)) { + .minfo("only exported NONMEM control stream/data") + return(invisible()) + } if (is.na(rxode2::rxGetControl(.ui, "runCommand", ""))) { .minfo("not running NONMEM") return(.ui) @@ -266,7 +270,7 @@ } #' Run NONMEM using either the user-specified command or function -#' +#' #' @param ui The nlmixr2 UI object for running #' @param monolix are we actually running monolix #' @return NULL From d8cd506fc7de7b052c4abe7489001e971485f294 Mon Sep 17 00:00:00 2001 From: "Matthew L. Fidler" Date: Sat, 25 May 2024 07:59:54 -0500 Subject: [PATCH 2/4] ::document() --- man/monolixControl.Rd | 3 +++ man/nonmemControl.Rd | 16 +++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/man/monolixControl.Rd b/man/monolixControl.Rd index a04f3b47..4e175f01 100644 --- a/man/monolixControl.Rd +++ b/man/monolixControl.Rd @@ -31,6 +31,7 @@ monolixControl( absolutePath = FALSE, modelName = NULL, muRefCovAlg = TRUE, + run = TRUE, ... ) } @@ -152,6 +153,8 @@ clear). Otherwise use this character for outputs.} In general, these covariates should be more accurate since it changes the system to a linear compartment model. Therefore, by default this is `TRUE`.} +\item{run}{Should monolix be run and the results be imported to nlmixr2? (Default is TRUE)} + \item{...}{Ignored parameters} } \value{ diff --git a/man/nonmemControl.Rd b/man/nonmemControl.Rd index 8aeb196b..c5f9676e 100644 --- a/man/nonmemControl.Rd +++ b/man/nonmemControl.Rd @@ -20,7 +20,7 @@ nonmemControl( outputExtension = getOption("babelmixr2.nmOutputExtension", ".lst"), runCommand = getOption("babelmixr2.nonmem", ""), iniSigDig = 5, - protectZeros = TRUE, + protectZeros = FALSE, muRef = TRUE, addProp = c("combined2", "combined1"), rxControl = NULL, @@ -44,6 +44,7 @@ nonmemControl( noabort = TRUE, modelName = NULL, muRefCovAlg = TRUE, + run = TRUE, ... ) } @@ -62,7 +63,8 @@ nonmemControl( \item{sstol}{NONMEM tolerance for steady state ODE solving} -\item{ssatol}{NONMEM absolute tolerance for steady state ODE solving} +\item{ssatol}{NONMEM absolute tolerance for steady state ODE +solving} \item{sigl}{NONMEM sigl estimation option} @@ -75,8 +77,8 @@ nonmemControl( \item{outputExtension}{Extension to use for the NONMEM output listing} -\item{runCommand}{Command to run NONMEM (typically the path to "nmfe75") or a -function. See the details for more information.} +\item{runCommand}{Command to run NONMEM (typically the path to +"nmfe75") or a function. See the details for more information.} \item{iniSigDig}{How many significant digits are printed in $THETA and $OMEGA when the estimate is zero. Also controls the zero @@ -99,7 +101,7 @@ due to an apparent failed optimization} \item{niter}{number of iterations in NONMEM estimation methods} -\item{isample}{Isample argument for NONMEM ITS estimation method} +\item{isample}{Isample argument for NONMEM ITS estimation method} \item{iaccept}{Iaccept for NONMEM ITS estimation methods} @@ -139,6 +141,10 @@ clear). Otherwise use this character for outputs.} In general, these covariates should be more accurate since it changes the system to a linear compartment model. Therefore, by default this is `TRUE`.} +\item{run}{Should NONMEM be run (and the files imported to +nlmixr2); default is TRUE, but FALSE will simply create the +NONMEM control stream and data file.} + \item{...}{optional \code{genRxControl} argument controlling automatic \code{rxControl} generation.} } From f0b4f68aeffedabf11594ee8a76e72cf30bf11b4 Mon Sep 17 00:00:00 2001 From: "Matthew L. Fidler" Date: Sat, 25 May 2024 09:13:39 -0500 Subject: [PATCH 3/4] CF fix --- R/nonmemNlmixr2est.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/nonmemNlmixr2est.R b/R/nonmemNlmixr2est.R index f9a0db56..ca9cb3c7 100644 --- a/R/nonmemNlmixr2est.R +++ b/R/nonmemNlmixr2est.R @@ -266,7 +266,7 @@ assign("message", paste(.msg$message, collapse="\n "), envir=.ret$env) qs::qsave(.ret, .qs) } - return(.ret) + .ret } #' Run NONMEM using either the user-specified command or function From f5d318ef762712e1c598f2e834de1c9e3dbe6871 Mon Sep 17 00:00:00 2001 From: "Matthew L. Fidler" Date: Sat, 25 May 2024 09:14:53 -0500 Subject: [PATCH 4/4] Add vdiffr --- DESCRIPTION | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 2880c456..7a081e3f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -26,7 +26,8 @@ Suggests: rmarkdown, spelling, PopED, - units + units, + vdiffr Depends: R (>= 3.5), nlmixr2 (>= 2.0.8)