Script Based 'NONMEM' Model Development

Industrialisation of 'NONMEM' < https://www.iconplc.com/innovation/nonmem/> via fully and rapidly reusable model development 'workflows' entirely within 'RStudio'. Quickly get started with new models by importing 'NONMEM' templates from the built-in code library. Manipulate 'NONMEM' code from within R either via the tracked 'manual edit' interface or 'programmatically' via convenience functions. Script 'workflows' by piping sequences of model building steps from control file creation, to execution, to post-processing and evaluation. Run caching makes 'workflows' R markdown friendly for easy documentation of thoughts and modelling decisions alongside executable code. Share, reuse and recycle 'workflows' for new problems.


NMproject

CRANstatus R-CMD-check Codecov testcoverage Lifecycle:maturing

Script based ‘NONMEM’ model development in RStudio intended for intermediate to advanced R users.

  • NONMEM code library
  • End-to-end script based model development workflows
  • Scale to groups of runs and complex workflows
  • 100% flexibility through tracked manual edits to model files
  • Customisable to multiple infrastructure types

Prerequisites

  • PsN >= 4.4.8
  • NONMEM installed with valid license
  • RStudio

Installation

You can install the released version of NMproject from CRAN with:

install.packages("NMproject")

To install the latest version of NMproject from GitHub:

if(!require("devtools")) install.packages("devtools")
devtools::install_github("tsahota/NMproject")

To install a specific release (e.g. v0.5.1) on GitHub use the following command:

devtools::install_github("tsahota/[email protected]")

Load the package with

library(NMproject)

Getting started with NMproject

Two options:

  1. Running the demo is easiest way to familiarise your with NMproject.
  2. Reading the website vignette.

Code snippets

Use of pipes, %>%, make it easy to code sequences of operations to model objects.

Following snippet adds covariates to model object, m2:

  • create a separate child control file
  • add a covariate relationship to it (using PsN SCM syntax)
  • run
m2WT <- m2 %>% child(run_id = "m2WT") %>%
  add_cov(param = "CL", cov = "WT", state = "power") %>%
  run_nm()

Graphical RStudio ‘Addins’ exist for reviewing the changes that functions like add_cov() make before execution and performing nm_tran() checks.

For more complex operations use fully tracked manual edits.

Apply fully customisable diagnostic reports to one or multiple objects with nm_render() like so:

c(m1, m2) %>% nm_render("Scripts/basic_gof.Rmd")
## Saves html diagnostic reports in "Results" directory

The template Scripts/basic_gof.Rmd can also be run as an R notebook for interactively customising to your specific model evaluation criteria.

Here’s a snippet for producing PPCs and VPCs:

  • create a new (child) control stream
  • updating initial estimates to final estimates
  • convert it to a simulation control file
  • run
  • generate customised PPCs and VPCs from the outputs
m2s <- m2 %>% child(run_id = "m2s") %>%
  update_parameters(m2) %>%
  convert_to_simulation(subpr = 50) %>%
  run_nm()

m2s %>% nm_render("Scripts/basic_vpc.Rmd")
m2s %>% nm_render("Scripts/basic_ppc.Rmd")

Advanced functionality enables groups of runs to be handled with the same concise syntax (no loops). For example:

  • create 5 child runs
  • Randomly perturb the initial estimates of $THETA and $OMEGA
  • run them all in their own subdirectory for tidiness.
m1rep <- m1 %>% child(run_id = 1:5) %>% 
  init_theta(init = rnorm(init, mean = init, sd = 0.3)) %>%
  init_omega(init = runif(init, min = init/2, max = init*2)) %>%
  run_in("Models/m1_perturb_inits") %>%
  run_nm()

See the website vignette for more examples

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("NMproject")

0.6.9 by Tarj Sahota, 4 years ago


https://tsahota.github.io/NMproject/, https://github.com/tsahota/NMproject


Report a bug at https://github.com/tsahota/NMproject/issues


Browse source code at https://github.com/cran/NMproject


Authors: Tarj Sahota [aut, cre, cph] , AstraZeneca [cph] , Nuria Buil Bruna [ctb] , Stein Schalkwijk [ctb]


Documentation:   PDF Manual  


GPL (>= 3) license


Imports shiny, dygraphs, DT, git2r, dplyr, methods, stringr, rlang, diffobj, tidyr, miniUI, rstudioapi, crayon, rprojroot, htmltools, rmarkdown, magrittr, usethis, lifecycle

Suggests testthat, knitr, ggplot2, data.tree, xpose, lubridate, pmxTools, Hmisc, rsample, renv, desc, purrr, digest, covr, devtools, roxygen2, xfun


See at CRAN