Skip to content

Commit

Permalink
Merge pull request #16 from nlmixr2/articles
Browse files Browse the repository at this point in the history
Articles
  • Loading branch information
mattfidler authored Sep 18, 2024
2 parents 4dd0878 + 456fdc0 commit 0be2437
Show file tree
Hide file tree
Showing 30 changed files with 785 additions and 172 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
^README\.Rmd$
^bad-library.md$
^pkgdown$
^_pkgdown.yml$
^.github$
^vignettes/articles$
^cran-comments\.md$
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: monolix2rx
Title: 'monolix2rx' Converts 'Monolix' Models to 'rxode2'
Version: 0.0.0.9000
Version: 0.0.1
Authors@R:
c(person("Matthew","Fidler", role = c("aut", "cre"), email = "[email protected]", comment=c(ORCID="0000-0001-8538-6691")),
person("Justin", "Wilkins", role = "ctb", email = "[email protected]", comment=c(ORCID="0000-0002-7099-9396")))
Expand Down Expand Up @@ -40,7 +40,7 @@ Imports:
crayon,
lotri,
magrittr,
rxode2 (> 2.0.13),
rxode2 (>= 3.0.0),
Suggests:
devtools,
testthat (>= 3.0.0),
Expand Down
5 changes: 0 additions & 5 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,8 @@ export(logit)
export(lotri)
export(mlxTxt)
export(mlxtran)
export(mlxtranGetMutate)
export(model)
export(monolix2rx)
export(monolixDataImport)
export(monolixEndpoints)
export(monolixEtaImport)
export(monolixPredIpred)
export(rxRename)
export(rxSolve)
export(rxUiGet)
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# monolix2rx 0.0.1

* Initial CRAN submission.
2 changes: 1 addition & 1 deletion R/dataCov.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#'
#' @param mlxtran input mlxtran file
#' @return mlxtran string that can be applied to a model (by evaluating it)
#' @export
#' @noRd
#' @author Matthew L. Fidler
#' @examples
#'
Expand Down
2 changes: 1 addition & 1 deletion R/dataImport.R
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
#' @inheritParams utils::read.table
#' @return Dataset appropriate for using with the rxode2 model for
#' simulations
#' @export
#' @noRd
#' @author Matthew L. Fidler
#' @examples
#'
Expand Down
2 changes: 1 addition & 1 deletion R/endpointInfo.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' @param mlxtran This is the parsed mlxtran or imported rxode2 model from monolix
#'
#' @return nothing, called for side effects
#' @export
#' @noRd
#' @author Matthew L. Fidler
monolixEndpoints <- function(mlxtran) {
mlxtran <- .monolixGetMlxtran(mlxtran)
Expand Down
2 changes: 1 addition & 1 deletion R/etaImport.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' @param mlxtran mlxtran file where data input is specified
#' @inheritParams utils::read.table
#' @author Matthew L Fidler
#' @export
#' @noRd
monolixEtaImport <- function(mlxtran, na.strings=c("NA", ".")) {
mlxtran <- .monolixGetMlxtran(mlxtran)
if (is.null(mlxtran)) return(NULL)
Expand Down
22 changes: 13 additions & 9 deletions R/indDef.R
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,7 @@
return(.c)
})
.ret$cov <- .monolix2rx$cov
.ret$coef <- lapply(seq_along(.coef),
function(i) {
.cur <- .coef[[i]]
.w <- which(grepl("^rxCov_", .cur))
if (length(.w) >= 1) .cur <- .cur[-.w]
.cur
})
.ret$coef <- .coef
.rx <- paste0(.rx, " + ",
paste(vapply(seq_along(.ret$coef),
function(i) {
Expand All @@ -184,10 +178,20 @@
.coef[.w])
.coef <- .coef[-.w]
.ref <- .ref[-.w]
.w <- which(grepl("^rxCov_", .coef))
if (length(.w) > 0) {
.coef <- .coef[-.w]
.ref <- .ref[-.w]
}
return(paste(paste0(.coef, " * (", .cov, " == '", .ref, "')"), collapse=" + "))
}
}
paste(paste0(.ret$coef[[i]], "*", .ret$cov[i]), collapse=" + ")
}
.coef <- .ret$coef[[i]]
.w <- which(grepl("^rxCov_", .coef))
if (length(.w) > 0) {
.coef <- .coef[-.w]
}
paste(paste0(.coef, "*", .ret$cov[i]), collapse=" + ")
}, character(1), USE.NAMES=FALSE),
collapse=" + "))
}
Expand Down
2 changes: 1 addition & 1 deletion R/ipredImport.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#' @param mlxtran mlxtran file where data input is specified
#' @inheritParams utils::read.table
#' @author Matthew L Fidler
#' @export
#' @noRd
monolixPredIpred <- function(mlxtran, na.strings=c("NA", ".")) {
mlxtran <- .monolixGetMlxtran(mlxtran)
withr::with_dir(.monolixGetPwd(mlxtran), {
Expand Down
2 changes: 1 addition & 1 deletion R/rxSolve.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ rxSolve.monolix2rx <- function(object, params = NULL, events = NULL,
maxsteps = 70000L, hmin = 0, hmax = NA_real_, hmaxSd = 0,
hini = 0, maxordn = 12L, maxords = 5L, ..., cores, covsInterpolation = c("locf",
"linear", "nocb", "midpoint"), naInterpolation = c("locf",
"nocb"), keepInterpolation = c("locf", "nocb", "na"),
"nocb"), keepInterpolation = c("na", "locf", "nocb"),
addCov = TRUE, sigma = NULL, sigmaDf = NULL, sigmaLower = -Inf,
sigmaUpper = Inf, nCoresRV = 1L, sigmaIsChol = FALSE, sigmaSeparation = c("auto",
"lkj", "separation"), sigmaXform = c("identity", "variance",
Expand Down
13 changes: 13 additions & 0 deletions R/validate.R
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,22 @@
.qai <- stats::quantile(with(.both, abs(ipred-monolixIpred)), .q, na.rm=TRUE)
.qp <- stats::quantile(with(.both, 100*abs((pred-monolixPred)/monolixIpred)), .q, na.rm=TRUE)
.qap <- stats::quantile(with(.both, abs(pred-monolixPred)), .q, na.rm=TRUE)

.qw <- stats::quantile(with(.both, 100*abs((iwres-monolixIwres)/monolixIwres)), .q, na.rm=TRUE)
.qaw <- stats::quantile(with(.both, abs(iwres-monolixIwres)), .q, na.rm=TRUE)

.ui$ipredAtol <- .qai[3]
.ui$ipredRtol <- .qi[3]/100
.ui$ipredCompare <- .both[,grepl("(id|time|monolixIpred|ipred|cmt)", names(.both), ignore.case=TRUE)]

.ui$predAtol <- .qap[3]
.ui$predRtol <- .qp[3]/100
.ui$predCompare <- .both[,grepl("^(id|time|monolixPred|pred|cmt)$", names(.both), ignore.case=TRUE)]

.ui$iwresAtol <- .qaw[3]
.ui$iwresRtol <- .qw[3]/100
.ui$iwresCompare <- .both[,grepl("(id|time|monolixIwres|iwres|cmt)", names(.both), ignore.case=TRUE)]

.msg <- c(paste0("ipred relative difference compared to Monolix ipred: ", round(.qi[3], 2),
"%; ", .ci0 * 100,"% percentile: (",
round(.qi[2], 2), "%,", round(.qi[4], 2), "%); rtol=",
Expand Down
31 changes: 31 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,37 @@ You can install the development version of monolix2rx from
# install.packages("devtools")
devtools::install_github("nlmixr2/monolix2rx")
```
## What you can do with `monolix2rx`/`babelmixr2`

You can do many useful tasks directly converting between nlmixr2 and
NONMEM models; you can:

- [Convert a Monolix model to a rxode2/nlmixr2 model](https://nlmixr2.github.io/monolix2rx/articles/convert-nlmixr2.html)

Then with nlmixr2 fit models and monolix2rx models coming from both conversions, you can:

- [Perform simulations of new
dosing](https://nlmixr2.github.io/monolix2rx/articles/simulate-new-dosing.html) from the Monolix model or even [simulate using the uncertainty in your model to simulate new scenarios](https://nlmixr2.github.io/monolix2rx/articles/simulate-uncertainty.html)

- [Modify the model to calculate derived parameters](https://nlmixr2.github.io/monolix2rx/articles/simulate-extra-items.html) (like AUC). These parameters slow down Monolix’s optimization, but can help in your simulation scenario.

- [Simulating with Covariates/Input PK
parameters](https://nlmixr2.github.io/monolix2rx/articles/simulate-new-dosing-with-covs.html). This example shows approaches to resample from the input dataset for covariate selection.

With nonmem2rx and babelmixr2, convert the imported rxode2 model to a nlmixr2 object, allowing:

- [Generation of Word and PowerPoint plots with
nlmixr2rpt](https://nlmixr2.github.io/monolix2rx/articles/create-office.html)

- [Easy VPC
creation](https://nlmixr2.github.io/monolix2rx/articles/create-vpc.html)
(with `vpcPlot()`)

- [Easy Individual plots with extra solved
points](https://nlmixr2.github.io/monolix2rx/articles/create-augPred.html). This
will show the curvature of individual and population fits for
sparse data-sets (with `augPred()`)


## Example

Expand Down
44 changes: 44 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
url: ~
template:
bootstrap: 5
params:
bootswatch: flatly
reference:
- title: Importing Monolix to rxode2
contents:
- monolix2rx
- title: Reading in `mlxtran`
contents:
- mlxtran
- mlxTxt
navbar:
left:
- text: Converting
icon: fa-arrow-right
href: articles/convert-nlmixr2.html
- text: "Qualify"
icon: fa-check
href: articles/rxode2-validate.html
- text: "Simulation"
icon: fa-dice
menu:
- text: "New Dosing Scenarios"
href: articles/simulate-new-dosing.html
- text: "Simulating with Uncertainty"
href: articles/simulate-uncertainty.html
- text: "Simulating with Derived Variables"
href: articles/simulate-extra-items.html
- text: "Reporting"
menu:
- text: "Creating word and powerpoint documents"
href: articles/create-office.html
- text: "Easily create VPC plots"
href: articles/create-vpc.html
- text: "Create enriched Individual plots"
href: articles/create-augPred.html
- text: "Functions"
icon: fa-file-code-o
href: reference/index.html
- text: "News"
icon: fas fa-rss
href: news/index.html
8 changes: 8 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

This adds monolix import to the nlmixr2 ecosystem

## R CMD check results

0 errors | 0 warnings | 1 note

* This is a new release.
28 changes: 0 additions & 28 deletions man/mlxtranGetMutate.Rd

This file was deleted.

52 changes: 0 additions & 52 deletions man/monolixDataImport.Rd

This file was deleted.

20 changes: 0 additions & 20 deletions man/monolixEndpoints.Rd

This file was deleted.

24 changes: 0 additions & 24 deletions man/monolixEtaImport.Rd

This file was deleted.

Loading

0 comments on commit 0be2437

Please sign in to comment.