Andrew Santulli1, Donald E. Mager1,2, Scott Van Wart1
1Enhanced Pharmacodynamics, LLC, Buffalo, NY, USA 2Department of Pharmaceutical Sciences, School of Pharmacy and Pharmaceutical Sciences, University at Buffalo, The State University of New York, Buffalo, NY, USA
Introduction:
Pharmacometricians often utilize multiple software, with NONMEM® (ICON plc, Dublin, Ireland) widely regarded as the current gold standard for population pharmacokinetic (PK) and pharmacokinetic-pharmacodynamic (PK-PD) modeling. While NONMEM has the ability to simulate, it is often more convenient and practical to perform simulations using free open-source software such as R [1] which can also perform post-processing of the output. Two popular pharmacometrics-orientated R packages for solving ODE systems are rxode2 [2] and mrgsolve [3]. The translation of NONMEM models into rxode2 syntax has already been automated by others [4]. Although mrgsolve has built-in functionality to streamline translation, to the best of our knowledge a previously-developed and publicly-available R package for fully automated NONMEM to mrgsolve translation does not exist.
Objectives:
To develop nonmem2mrgsolve [5], an open-source R package, to automate translating the NONMEM control stream code into mrgsolve syntax for most use cases. Secondarily, to use base R functions wherever possible in order to avoid extensive dependencies; which could otherwise be problematic for users without proper package management.
Methods:
Original nonmem2mrgsolve development was conducted using R Version 4.1.0; and the package is hosted on GitHub. NONMEM to mrgsolve model translation requires the NONMEM ctl file, the NONMEM ext (default) or cnv file, and five other R packages as imports (dplyr, magrittr, stringr, stringi, and zoo). Translation is initiated via a single nonmem2mrgsolve function call, with the only required user input being the NONMEM run name (and working directory if the R session is not already pointing to the correct file directory). During the translation several helper functions perform the following tasks: 1) the NONMEM ctl and ext (or cnv) files are loaded into R; 2) NONMEM code blocks within the ctl that are applicable to mrgsolve simulations are identified, while the remaining blocks are discarded; 3) NONMEM syntax is converted to mrgsolve syntax; 4) Final NONMEM-estimated fixed effect parameters and IIV magnitudes are imported from the ext (or cnv) into the newly-created mrgsolve code; 5) By default, the resulting mrgsolve code is written as an R file, which can be loaded for use in simulation scripts.
Results:
The nonmem2mrgsolve package has been successfully adopted internally and used to streamline the workflow of numerous population PK, population PK-PD, physiologically-based PK (PBPK), and quantitative systems pharmacology (QSP) projects. The nonmem2mrgsolve translation adds necessary double precision floating point initializations (i.e., “double” before the first occurrence of each variable), statement terminators (i.e., a semicolon at the end of each line), performs common syntax conversions (ex. “EXP” to “exp”, “THEN ENDIF” to “{ }”, “base**pow” to “pow(base,pow)”, etc.), and imports the final NONMEM parameter estimates. Optional user inputs can prevent writing of the mrgsolve code, request for the mrgsolve code to be returned within the session as an R object, override the default naming of the mrgsolve code file, control the number of significant digits reported in the mrgsolve code for final parameter estimates, and request that the cnv file be used for obtaining final parameter estimates instead of the ext (if stochastic expectation maximization estimation was used during modeling within NONMEM). Current limitations include not translating time variables (although comments within the mrgsolve code will identify lines requiring the user’s attention) and no option to import residual variability estimates.
Conclusions:
The nonmem2mrgsolve R package automates NONMEM to mrgsolve translation and successfully handles most use cases and syntax nuances. This improves time efficiency and removes a potential source for human error, especially for models with many equations such as whole body PBPK models. Users remain responsible for validating the translation, for which there is an intuitive and established framework [6]. Future work will expand upon the accommodated usage scenarios, build in automated validation of the translation, and will explore a potential release to CRAN.
References:
- R Core Team (2024). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. https://www.R-project.org/.
- Mattew L. Fidler and Melissa Hallow and Justin Wilkins and Wenping Wang (2024). RxODE: Facilities for Simulating from ODE-Based Models. R package version 2.1.2. https://CRAN.R-project.org/package=RxODE
- Kyle T Baron (2024). mrgsolve: Simulate from ODE-Based Models. R package version 1.4.1. https://CRAN.R-project.org/package=mrgsolve
- Matthew Fidler and Philip Delff and Gabriel Staples (2023). nonmem2rx: ‘nonmem2rx’ Converts ‘NONMEM’ Models to ‘rxode2’. R package version 0.1.3. https://CRAN.R-project.org/package=nonmem2rx
- Andrew Santulli (2024). nonmem2mrgsolve: Automated NONMEM to mrgsolve Translation. R package version 1.2.0.
- Kyle T Baron (2023, March 6). Update: Validate translation from NONMEM. mrgsolve/blog. https://mrgsolve.org/blog/posts/2023-update-validation.html
Reference: PAGE 32 (2024) Abstr 11067 [www.page-meeting.org/?abstract=11067]
Poster: Methodology - Other topics