-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01_intro.qmd
141 lines (69 loc) · 16.4 KB
/
01_intro.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Introduction {#intro}
## Pharmacokinetics and Pharmacodynamics
In the vast landscape of medical science and pharmaceutical development, understanding the intricate relationship between drugs, the body, and their interactions is paramount. Before we start delving into the meat and potatos of this book, two fundamental concepts in pharmacology need to be touched on: pharmacokinetics and pharmacodynamics.
Pharmacokinetics (PK) and pharmacodynamics (PD) form the dual pillars of pharmacology, elucidating the journey of a drug from its initial administration to its final effect on the body. These disciplines are tightly intertwined, and indispensable for developing effective, safe, and personalized treatments.
### Pharmacokinetics (PK)
Pharmacokinetics is the study of how drugs are absorbed, distributed, metabolized, and eliminated from the body. It examines the kinetics — rates and patterns — of the passage of drugs through the body and their interactions with biological systems. It is, colloquially put, the study of what the body does to the drug.
The **absorption** phase involves the uptake of drugs into the bloodstream from various routes of administration (oral, intravenous, subcutaenous, *et cetera*). Factors like solubility, pH, and the integrity of the gastrointestinal tract influence this process.
**Distribution** takes place once the drug enters the bloodstream, and describes the processes by which it is distributed to different tissues and organs. The *volume of distribution (Vd)* is a convenient measure of how extensively a drug is distributed in the body, reflecting the drug's affinity for different tissues.
**Metabolism** encompasses the processes whereby drugs are transformed from one form to another by enzymes in the liver and other organs. Hepatic and renal function, genetic polymorphisms, and the presence and effects of other drugs in the system can affect metabolic rates.
Finally, **elimination** refers to the processes that remove the drug from the body, including excretion in urine and feces, and *clearance* rates. Factors such as body size and health status can influence elimination pathways.
### Pharmacodynamics (PD)
Pharmacodynamics, by contrast, focuses on what the drug does to the body. It investigates how drugs interact with biological systems to produce therapeutic or adverse effects. Understanding how drugs bind to receptors on cell surfaces is fundamental to PD; the nature of the binding, whether it's competitive, non-competitive, or allosteric, dictates how the drug functions.
Once bound, drugs can alter cellular processes such as gene expression, enzyme activity, and ion channel function, leading to physiological changes. PD also considers the impact of drugs on organ function, including metabolic processes, immune responses, and neurotransmitter systems.
Finally, PD provides a toolkit for translating these biological interactions into clinical outcomes, including therapeutic benefits, side effects, and drug interactions, amongst others.
### Interplay between PK and PD
The efficacy and safety of a drug are fundamentally determined by the interplay between PK and PD. A drug's pharmacokinetic properties dictate its availability and duration of effect, while its pharmacodynamic profile determines the therapeutic response and potential adverse effects. A drug with rapid absorption and rapid metabolism, for instance, might require frequent dosing to maintain therapeutic levels. Similarly, a drug with a narrow therapeutic index (a small difference between therapeutic and toxic doses) would need to be carefully dosed to avoid toxicity. A good idea of the PK and PD of both of these drugs would be essential in order to be able to use them effectively, and being able to predict how they behave in people of differing physical characteristics and backgrounds would be even better.
Enter pharmacometrics.
## Pharmacometrics
[Wikipedia](https://en.wikipedia.org/wiki/Pharmacometrics) defines pharmacometrics (PMx) as a field of study of the methodology and application of mathematical models for disease and pharmacological measurement. It applies mathematical models of biology, pharmacology, disease, and physiology to describe and quantify interactions between xenobiotics (drugs) and patients (human and non-human), including both beneficial and adverse effects. It is normally applied to combine data from drugs, diseases and clinical trials to aid efficient drug development, regulatory decisions and rational drug treatment in patients.
Pharmacometrics rolls up modeling and simulation for pharmacokinetics, pharmacodynamics, and disease progression, with a focus on populations and variability. A major focus is to understand variability in drug response, which can be predictable (e.g. due to differences in body weight or kidney function) or unpredictable (differences between subjects seem random, but likely reflect a lack of knowledge or data).
Quantitative systems pharmacology (QSP) is also considered to be a part of the PMx ecosystem, but applies a more theoretical and less data-driven approach to building models. QSP models are often much more complex than PK/PD models, with less of a populations focus.
What this boils down to is using mathematical/statistical models to help explain and predict PK and PD - these are often combined to produce PKPD or exposure-response (ER) models. We build these using data collected from clinical trials (e.g. blood samples, clinical observations, scores, X-rays and suchlike - multiple samples, over time, from many subjects), which we use to build compartmental models which approximate what is happening over time using ordinary differential equations (ODEs).
This sounds complicated - and it can be - but it's based on the well-stirred compartmental model for PK, a well-established set of principles for how systems like these can be approximated.
Alcohol, interestingly, is a pretty good example. PK describes what happens to the alcohol (ethanol) you consume between the glass and the bathroom, and PD describes what it does while it's circulating in your blood (quite a few things, including making you tipsy). It is eye-wateringly complex. The "DrinkMe" simulation on Nick Holford's website is a fun interactive example of how it fits together! You can find it at <http://holford.fmhs.auckland.ac.nz/research/ethanol>.
So pharmacometrics can help us understand how drugs behave in different people. The "DrinkMe" model includes body weight - the bigger you are, the bigger your organs are (usually) and the more machinery you have for metabolizing substances like ethanol, so the slower you get drunk, and if you've eaten something, the alcohol will take longer to get into your system (although these are just two aspects of a very complex system).
These principles apply to every drug we take, from aspirin to metformin (which is commonly used for treating diabetes). We use these models to figure out what an appropriate dose is, and what might affect it.
We can use pharmacometric models like these to simulate clinical trials, dose regimens and so on, *in silico*, so that we can predict what will happen when we actually give a drug to a human, and whether the design we have proposed for our clinical trial will actually work when we run it.
Later on in drug development, as we get close to registration, we can use these models to identify covariates whcih might inform differences in exposure and effect between patients (like age, weight, and sex), and to quantify the relationships between dose, exposure, and response for efficacy (e.g. how well the drug does at reducing or eliminating a tumour) and safety (e.g. how many unwanted side effects the drug generates at a useful dose).
It's not just about the drugs themselves. Drug-disease and disease progression models are also an area in which pharmacometrics continues to have an impact - FDA maintains a list the ones they've developed internally (<https://www.fda.gov/about-fda/center-drug-evaluation-and-research-cder/division-pharmacometrics>), including examples for Alzheimer's disease and diabetes, although there are many, many more.
So far we've mostly talked about empirical, data-driven models, but pharmacometrics goes further, especially now that the computers are getting so fast (models take time to fit to data, and the more complex they are, and the more patients you have, the longer they take).
Physiologically-based PK (PBPK) models, for example, find the middle ground between PK and QSP, having a more mechanistic bent by taking into account anatomical, physiological, physical, and chemical descriptions of the phenomena involved in complex absorption, distribution, metabolic and elimination (ADME) processes, while remaining fundamentally driven by observed data.
## `nlmixr2`
`nlmixr2` is a set of packages - let's call it the "mixrverse" - for R that provides an open source alternative for nonlinear mixed-effects (NLME) model development, which are the core of most pharmacometrics workflows (amongst others).
Modeling tools in our area are largely closed-source and massively expensive, and are a gigantic entry barrier for new people, especially in low and middle-income countries (and borderline unaffordable even for CROs like mine). `nlmixr2` is intended to be a solution to this problem.
## What you will learn
This book is intended to be a guide to using `nlmixr2` and its constellation of supporting and allied packages in R to develop and use nonlinear mixed-effect pharmacometric models. While it touches lightly on the core concepts of pharmacology and pharmacometrics, it does not delve deeply. You can learn about these elsewhere.
You will, however, learn to construct datasets for analysis, to write models in `rxode2` and `nlmixr2`, to simulate from them using `roxode2`, to fit them using `nlmixr2`, to use `shinyMixR` for tracking model development steps, to use `xpose.nlmixr2` and `ggPMX` for model evaluation, to use `babelmixr2` to cross-convert models from different tools, and to use `PKNCA` for figuring out initial estimates. You'll also learn how the `nlmixr2` ecosystem has been constructed and how to work with it efficiently.
Throughout the book, we'll point you to resources where you can learn more.
## What you won't learn
There are some topics that this book doesn't cover, not because we are not all-knowing, but because there isn't space. We will not look at AI or machine learning in this edition, although we may revisit this if we do a second edition (assuming someone figures out how to do it properly with respect to pharmacometrics).
## How this book is organised
We start off with a summary of `nlmixr2` and all its dependencies, and how they're built and work together. This is essential for understanding why things have been set up in the way they have, and how to drill down into the source code to figure out what is actually happening under the hood. It is not, however, essential if you want to dive straight into modeling.
We then get into datasets - how they should be structured, how events like doses are handled, visualization, and what variables should be.
Next up, we look at a simple PK model, to illustrate how models can be written - both with closed-form solutions and ODEs - as well as how `rxode2`/`nlmixr2` objects are constructed, and how to extract information from them. We'll use this example to explore the various minimization algorithms that are available and how to tune them.
We'll then move on to a more complex PK example, to illustrate some of `nlmixr2`'s niftier features, like transit absorption models, and how to use the various diagnostics that are available, as well as `shinyMixR`. We'll then segue into more complex simulation (using `rxode2`) to see how pharmacometric models can be used to predict clinical trial outcomes, for example.
Finally, we'll wrap up with a demonstration of using `babelmixr` to import models from NONMEM, and `PKNCA` for providing credible initial estimates, and some guidelines on how you can contribute to the project if you so wish. `nlmixr2` is, after all, an open-source project and relies entirely on volunteers for its development and maintenance.
Within each chapter, we try and adhere to a similar pattern: start with some motivating examples so you can see the bigger picture, and then dive into the details. Each section of the book is paired with exercises to help you practice what you've learned.
Although it can be tempting to skip the exercises, there's no better way to learn than practicing on real problems.
### Pharmacology
We know we said we weren't going to teach you pharmacology, but we are going to offer a primer of sorts. You can't be an effective pharmacometrician unless you're up to speed with basic pharmacology. That being said, you can't pick it up in an afternoon. We'll be touching on pharmacology concepts throughout, but we're assuming you will already know the theory. There are quite a few good books that can serve as a more detailed and comprehensive introduction to the topic than the bare bones we provide here - we particularly like Rowland & Tozer [@derendorf_rowland_2019].
### Pharmacometrics
Although you'll be able to infer a lot of things as we go, it would help if you already know what compartmental nonlinear mixed-effects models are and how they can be used to model the behaviour of drugs. Again, we show some of the basics, but more is needed. Mould & Upton published a nice overview of the field a decade or so ago [@Mould2012; @Mould2013; @Upton2014], and there are good textbooks as well [@ette_pharmacometrics_2007; @gabrielsson_pharmacokinetic_2007].
### Big data
This book assumes you're working with relatively small in-memory datasets. The kinds of models we talk about here don't work well with bigger ones.
### Data science
We are dealing with specifically pharmacometric data analysis. If it's pure data science you're interested in, we heartily recommend [R for Data Science](https://github.com/hadley/r4ds/), which provides a comprehensive grounding.
### Python/Julia/Matlab/SAS/Ruby on Rails/etc
In this book, you won't learn anything about Python, Julia, JavaScript or any other language outside of R. This is because `nlmixr2` is written in R.
R is an environment designed from the ground up to support quantitative science, being not just a programming language, but also an interactive environment. It is - in our opinion - a much more flexible language than many of its peers.
## Acknowledgements
We have a lot of people to thank. `nlmixr2` is the product of countless hours of hard work by many, many contributors.
First and foremost, Wenping Wang is in many ways the father of `nlmixr`. It was his work that provided the foundation for this tool, and although he has since moved on from the core development team, everything we've built started with him.
Teun Post was there at the very beginning, and was responsible for a lot of the initial documentation for `nlmixr`. Although he too has moved on, his contribution was large and fundamental.
The `nlmixr` project has relied heavily on support from our day jobs. Matt Fidler, Mirjam Trame, Yuan Xiong, Huijuan Xu, Max Taubert and Wenping were given the time they needed to work on `nlmixr` and its successor `nlmixr2` at various times by Novartis, which remains an enthusiastic core sponsor of the team and the project. Kai Grosch, Lisa Hendricks, Mick Looby and Etienne Pigeolet are worthy of special mention here. Justin Wilkins and Rik Schoemaker have had their time sponsored by Occams, Richard Hooijmaaijers and Teun Post are and were supported by LAP&P (respectively), Bill Denney's time is underwritten by Human Predictions, and Johnson & Johnson, Seattle Genetics, GSK, Avrobio and Certara have all generously donated their associates' time to help us build this tool. We are grateful to all of them.
Without `RxODE`, there would be no `nlmixr`. We would be remiss in not mentioning the early contributions of Melissa Hallow, David James and Wenping in the development of this, the engine that drove `nlmixr` and now drives `nlmixr2` as `rxode2`.
We'd all like to thank our families and colleagues for putting up with the odd hours and late nights and copious amounts of swearing emanating from our offices, both at work, and more often, recently, at home.
Those we're most grateful to, though, are our users: the early adopters, the curious, and most importantly, the bug reporters who have put `nlmixr` through its paces over the years and helped it become what it is today. Thank you, and we hope you'll stay with us as we grow.
## Colophon
This book is powered by [Quarto](https://quarto.org) which makes it easy to write books that combine text and executable code.