Rikard Nordgren 1, Stella Belin 1, Xiaomei Chen 1, Andrew C. Hooker 1, Mats O. Karlsson 1
1 Department of Pharmacy, Uppsala University (Uppsala, Sweden)
Pharmpy [1] is an open-source software package for pharmacometric modeling intended for scripting of pharmacometric workflows and automated model development. The package has different application programming interface (API) layers to cater to the different needs of pharmacometric researchers, modelers and tool developers. Key features include:
• Ability to fully script modeling workflows: script various aspects of model building (such as building a model, transforming the dataset, or estimating the model parameters) in Python, R (via the pharmr package [2, 3]), and from the command line
• Independent of modeling language: model abstraction is separate from the estimation language, meaning functions and tools can be used with multiple estimation tools and models can be translated between languages (currently NONMEM, nlmixr2, and rxode2) [4, 5]
• Tools for automatic model building: develop parts of or a full model automatically, with support for PK, PD, PKPD, TMDD, and drug-metabolite models [6]
New features since PAGE 2025
• New tool “pdsearch” to build PD and KPD models
• Support for more distributions in iivsearch
• Support for better fine tuning of the search space in iivsearch
• Support for the N-transits and Weibull absorption models in modelsearch
• Handling of model selection and ranking in separate tool “modelrank”
• Many new modeling functions, e.g. Cholesky decomposition of ETAs, inserting EBEs into dataset, binarizing a dataset and finding mappings between individual parameters, omegas and etas
• Faster parsing of NONMEM models and results
Model representation in Pharmpy
At the heart of Pharmpy lies its model abstraction. When a model is parsed from NONMEM, or when a new model is created from scratch in Pharmpy, it is represented as a general Pharmpy model object. The model is broken down into core components: model statements, parameters, random variables, execution steps, and the dataset, each of which can be manipulated through low level operations and through more complex functions. All functions and tools are agnostic of the original implementation of the model; it is only once the model is written down (e.g. for execution) that the specific tool to use is relevant. For example, a general Pharmpy function changes the absorption model, while the NONMEM specific update machinery chooses the correct ADVAN. By separating the model manipulations from the underlying tool, a function or tool only needs to be implemented once.
Scripting of modeling workflows
Pharmpy has many different functions to simplify the pharmacometric model building process. The use cases for these functions range from using only one function for a task that is tedious to perform manually to fully scripting a workflow, including fitting and presenting results. Examples of types of functions include:
• Model creation
• Model transformations like setting initial estimates, changing model structure, adding covariate effects or adding a BLQ model.
• Data transformations like adding a TAD column or binarizing some covariates
• Model estimation and subsequent analysis
◦ Execute models from Python or R
◦ Create summary tables and plots
• One script workflows
• Detect what was previously run and read in results
Automatic development of models
Pharmpy has multiple tools that can automatically develop different aspects of a model, and a fully automatic model development (AMD) tool that develops a model given a dataset [6]. The AMD tool integrates multiple subtools that selects the structural model [7], the IIV/IOV structure, the RUV model, and covariate effects. These subtools can also be run standalone. All the tools in AMD produce various results, including reports with model quality plots and tables. Pharmpy also has a tool to evaluate estimation methods, solvers, and parameter uncertainty methods.
Contributions to the Pharmpy-package are welcome!
Acknowledgement: This work was supported by F. Hoffmann-La Roche Ltd. A special thanks to Dr. Orwa Albitar and Dr. José Calderin, for conducting testing and providing feedback. Thanks also to Pharmetheus and Dr. Aurélien Ooms for optimizing the NONMEM parsing.
References:
[1] Pharmpy: https://pharmpy.github.io/latest/index.html
[2] R Core Team (2020). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. URL https://www.R-project.org/.
[3] pharmr: https://github.com/pharmpy/pharmr
[4] Bauer RJ. NONMEM Tutorial Part I: Description of Commands and Options, With Simple Examples of Population Analysis. CPT: Pharmacometrics & Systems Pharmacology. 2019;8(8):525–37.
[5] Fidler M, Xiong Y, Schoemaker R, Wilkins J, Trame M, Hooijmaijers R, Post T, Wang W. (2021) nlmixr: Nonlinear Mixed Effects Models in Population Pharmacokinetics and Pharmacodynamics. R package version 2.0.6. https://CRAN.R-project.org/package=nlmixr.
[6] Chen X, Nordgren R, Belin S, et al. A fully automatic tool for development of population pharmacokinetic models. CPT Pharmacomet Syst Pharmacol. 2024;13(10):1784-1797. doi:10.1002/psp4.13222
[7] Hamdan A, Chen X, Belin S, Nordgren R, Buatois S, Abrantes JA, Hooker AC, Karlsson MO, Automatic Development of Pharmacokinetic Structural Models – Pharmpy Model Search Tool, PAGE 2022
Reference: PAGE 34 (2026) Abstr 12275 [www.page-meeting.org/?abstract=12275]
Poster: Software Demonstration