2022 - Ljubljana - Slovenia

PAGE 2022: Software Demonstration
Stella Belin

Pharmpy: a versatile open-source library for pharmacometrics

Rikard Nordgren (1), Stella Belin (1), Gunnar Yngman (1), Zhe Huang (1), Simon J. Carter (1), Xiaomei Chen (1), Osama Qutishat (1), Alzahra Hamdan (1), Shijun Wang (1), Tianwu Yang (1), Piyanan Assawasuwannakit (1), Simon Buatois (2), João A. Abrantes (2), Andrew C. Hooker (1), Mats O. Karlsson (1)

(1) Department of Pharmacy, Uppsala University, Sweden (2) Roche Pharma Research and Early Development, Roche Innovation Center Basel, Basel, Switzerland

The development of pharmacometric nonlinear mixed effect models is a complex, multi-step process. Generally, it begins with an informed starting model, which is subsequently improved in a stepwise manner. Throughout the process, a modeler needs to master knowledge in multiple domains, including pharmacology and statistics. The technical component, i.e. how to implement and manipulate models, is an additional burden. Furthermore, having traceable and reproducible results is crucial, therefore scripting parts of the model building rather than making manual changes can improve the quality of the overall process.

Pharmpy is an open-source software package for pharmacometric modeling. It has functionality ranging from reading and manipulating model files and datasets, to executing workflows and collecting and presenting subsequent results. Through a plugin mechanism it is possible to support different model languages and tools for estimation and simulation. Currently, NM-TRAN control streams and execution using NONMEM [1] is supported, and there is also partial support for nlmixr [2]. Pharmpy is intended to be useful to tool developers, pharmacometric researchers and modelers, and has different Application Programming Interface (API) layers to cater for the different needs of the groups. Modelers and developers can use Pharmpy in Python, in R [3] via the pharmr package, or the command line interface.

The main design principles of Pharmpy are: modularity, so that parts of the tools can be reused independently, and tool agnosticism, so that multiple model languages and tools for estimation and simulation of models can be used. At the core of Pharmpy lies its abstraction for nonlinear mixed effects models. Models are internally separated into components. The parameters, random variables, differential equations and model statements have their own classes with APIs allowing for low level manipulation. By using this abstraction, a NONMEM model could be written by a modeler, be parsed by Pharmpy into its model components, and then translated into nlmixr and estimated (currently, this is implemented as a proof of concept for some models). Pharmpy uses the main packages from the Python scientific stack with sympy [4] for symbolic manipulations, and pandas [5], numpy [6] and scipy [7] for numeric calculations.

By using the abstraction previously mentioned, Pharmpy can do more high-level transformations of parsed models, i.e. the transformations are not dependent on the type of the input model. The package can do advanced model manipulation of PK models, including changing the absorption rate, absorption delay, elimination rate and distribution. For general models, Pharmpy can add covariate effects, set variability on parameters, manipulate the covariance structure of random effects, fix parameters, update initial estimates and change the error model. It is also possible to fit models via a function directly in Python or R (currently only NONMEM is fully supported). Pharmpy also has a tool to predict outliers and influential individuals using neural networks [8].

One abstraction level above the transformations, Pharmpy has a system to connect these functions into more complex tools. This includes simpler tools such as bootstrap, as well as more complex tools that e.g. decide the structural model [9] and IIV structure, using an exhaustive approach, and the residual error model. The three latter tools are part of the AMD-tool (Automatic Model Development), a tool which aims to automatically build a PK model from a given dataset [10]. All of these tools are implemented for the Pharmpy model object, meaning that even though NONMEM is the only estimation software that is fully supported, other software could be added once those are parsable and writable by Pharmpy. The tools are run using the Dask package [11], which allows for parallelization.

Pharmpy and pharmr are freely available at:

https://pharmpy.github.io

https://github.com/pharmpy/pharmr

Contribution to the Pharmpy-package is welcome!

Acknowledgement: This work was supported by F. Hoffmann-La Roche Ltd., Basel, Switzerland and Bayer AG. A special thanks to Dr. Emilie Schindler, Dr. Sylvie Retout and Dr. Valerie Cosson for conducting testing and providing feedback.



References:

[1] 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.

[2] 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.

[3] 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/.

[4] Meurer A, Smith CP, Paprocki M, Certík O, Kirpichev SB, Rocklin M, Kumar A, Ivanov S, Moore JK, Singh S, Rathnayake T, Vig S, Granger BE, Muller RP, Bonazzi F, Gupta H, Vats S, Johansson F, Pedregosa F, Curry MJ, Terrel AR, Roucka Š, Saboo A, Fernando I, Kulal S, Cimrman R, Scopatz A. (2017) SymPy: symbolic computing in Python. PeerJ Computer Science 3:e103 https://doi.org/10.7717/peerj-cs.103

[5] Jeff Reback, Wes McKinney, jbrockmendel, Joris Van den Bossche, Tom Augspurger, Phillip Cloud, gfyoung, Sinhrks, Adam Klein, Matthew Roeschke, Simon Hawkins, Jeff Tratner, Chang She, William Ayd, Terji Petersen, Marc Garcia, Jeremy Schendel, Andy Hayden, Mortada Mehyar et al. (2020). pandas-dev/pandas: Pandas 1.0.3 (v1.0.3). Zenodo. https://doi.org/10.5281/zenodo.3715232

[6] Harris, C.R., Millman, K.J., van der Walt, S.J. et al. Array programming with NumPy. Nature 585, 357–362 (2020). DOI: 0.1038/s41586-020-2649-2 . (Publisher link).

[7] Pauli Virtanen, Ralf Gommers, Travis E. Oliphant, Matt Haberland, Tyler Reddy, David Cournapeau, Evgeni Burovski, Pearu Peterson, Warren Weckesser, Jonathan Bright, Stéfan J. van der Walt, Matthew Brett, Joshua Wilson, K. Jarrod Millman, Nikolay Mayorov, Andrew R. J. Nelson, Eric Jones, Robert Kern, Eric Larson, CJ Carey, Ilhan Polat, Yu Feng, Eric W. Moore, Jake VanderPlas, Denis Laxalde, Josef Perktold, Robert Cimrman, Ian Henriksen, E.A. Quintero, Charles R Harris, Anne M. Archibald, Antônio H. Ribeiro, Fabian Pedregosa, Paul van Mulbregt, and SciPy 1.0 Contributors. (2020) SciPy 1.0: Fundamental Algorithms for Scientific Computing in Python. Nature Methods, 17(3), 261-272.

[8] Osama Qutishat, Simon J. Carter, Rikard Nordgren, Alzahra Hamdan, Shijun Wang, Tianwu Yang, Xiaomei Chen, Simon Buatois, João A. Abrantes, Andrew C. Hooker and Mats O. Karlsson, The development of artificial neural networks for the prediction of influential individuals and outlying individuals and their application during the model building development process, PAGE 2022

[9] Alzahra Hamdan, Xiaomei Chen, Stella Belin, Rikard Nordgren, Simon Buatois, João A. Abrantes, Andrew C. Hooker and Mats O. Karlsson, Automatic Development of Pharmacokinetic Structural Models – Pharmpy Model Search Tool, PAGE 2022

[10] Xiaomei Chen, Alzahra Hamdan, Shijun Wang, Tianwu Yang, Rikard Nordgren, Stella Belin, Zhe Huang, Simon J. Carter, Simon Buatois, João A. Abrantes, Andrew C. Hooker, Mats O. Karlsson, Development of a tool for fully automatic model development (AMD), PAGE 2022

[11] Dask Development Team (2016). Dask: Library for dynamic task scheduling, https://dask.org


Reference: PAGE 30 (2022) Abstr 10096 [www.page-meeting.org/?abstract=10096]
Software Demonstration
Click to open PDF poster/presentation (click to open)
Top