Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

108 dont run nonmem or monolix just create files #109

Merged
merged 4 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]", comment=c(ORCID="0000-0001-8538-6691")),
person("Bill", "Denney", email="[email protected]", role="aut", comment=c(ORCID="0000-0002-5759-428X")),
person("Nook", "Fulloption", role="ctb", comment="goldfish art"))
Expand All @@ -26,7 +26,8 @@ Suggests:
rmarkdown,
spelling,
PopED,
units
units,
vdiffr
Depends:
R (>= 3.5),
nlmixr2 (>= 2.0.8)
Expand Down
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 6 additions & 1 deletion R/monolixControl.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -197,7 +201,8 @@ monolixControl <- function(nbSSDoses=7,
genRxControl=genRxControl,
useLinearization=useLinearization,
modelName=modelName,
muRefCovAlg=muRefCovAlg)
muRefCovAlg=muRefCovAlg,
run=run)
class(.ret) <- "monolixControl"
.ret
}
Expand Down
4 changes: 4 additions & 0 deletions R/monolixNlmixr2est.R
Original file line number Diff line number Diff line change
Expand Up @@ -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, "")) {
Expand Down
22 changes: 15 additions & 7 deletions R/nonmemControl.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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.
#'
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand All @@ -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)
}
Expand Down Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions R/nonmemNlmixr2est.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -262,11 +266,11 @@
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
#'
#'
#' @param ui The nlmixr2 UI object for running
#' @param monolix are we actually running monolix
#' @return NULL
Expand Down
3 changes: 3 additions & 0 deletions man/monolixControl.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions man/nonmemControl.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading