PHARMACOKINETIC MODELING and VISUALIZATION TOOL
BACKGROUND
Pharmacokinetics is the study of drug absorption, distribution, metabolism, and excretion over time. We often want to apply pharmacokinetic principles to the safe and effective therapeutic management of drugs in patients, but it may be difficult to measure drug concentrations in specific tissues. While we can easily measure drug concentrations in places like blood, urine, saliva, it can be much harder or impossible to measure drug concentrations in other tissues like in the subcutaneous space. However, easily obtained measurements can be leveraged to develop pharmacokinetic models to predict drug concentrations in other tissues where we cannot feasibly collect data from. Compartment models can be generated by dividing the body into compartments that describe the absorption, distribution and elimination. Pharmacokinetic models can be extremely valuable to drug research and development, shedding light to how a drug candidate interacts with the target organism.
This application is designed to aid researchers who are currently developing and researching drugs for deployment in animal models or other subjects. This tool consists of two parts that operate entirely independently, although both can be used at the same time.
For the full documentation, please visit the Github repository where a README has been uploaded to go into more detail HERE.
It should also be noted that supporting files for this application including a commented version of the Python code in this web application and a sample Jupyter Notebook for download that mimics the functionality of this application (allowing for greater end-user customizability) is available HERE.
Note: you will notice some stutters as packages load in as soon as you press the “Load-in Packages” button. This is completely normal. Additionally, the “Calculate k-values” button in part 2 is grayed out until said packages load - this can take up to 30 seconds. This application runs best in Chrome and Firefox. Safari is only compatible with the first part of the calculator. Also note that disabled buttons on SquareSpace appear with a gray surround while activated buttons appear with a black surround.
OVERVIEW
- Part 1 is the Pharmacokinetic Data Modeling Calculator and Visualizer
- The user inputs rate constants (k values) and initial values for each compartment and the application solves the system of differential equations and displays mass vs. time or concentration vs. time curves for each compartment.
-
Part 2 is the Rate Constant Calculator
- The user uploads mass vs. time or concentration vs. time data in a CSV file and the application solves for best fit rate constants (k-values) for the system of differential equations for the data.
COMPARTMENT MODEL AND DIFFERENTIAL EQUATIONS
This example system illustrates the model set-up for both parts of the application. In both parts, the user will be able to define the number of compartments in their model system. Each compartment starts with an initial mass and the application uses first-order kinetics to model flow in and out of each compartment. We have chosen to use a 3 compartment model as an example for the inputs and corresponding system of differential equations. The flow is dictated by the rate constants labeled as k1, k2, and k3 in our example picture. Initial mass in each compartment is given by X1,0, X2,0, X3,0. X1, X2, and X3 correspond to the mass in compartments 1, 2, and 3 at a given time t.
The differential equations used in the calculator, resemble the following, where each compartment's derivative is modified by the incoming mass and outgoing mass, where X represents the mass of a compartment.
INSTRUCTIONS
Part 1: Pharmacokinetic Data Modeling Calculator and Visualizer
Inputs
-
Number of Compartments:
- The number of compartments that you have in your model.
-
Compartment Info:
- Name (optional): for use in downloadable CSV file of generated data.
- Initial values: Mass at t = 0 in each compartment.
- k-value: rate constant for each compartment. The k-value input field in row 1 represents the k-value from Compartment 1 to 2 (k1 in the compartment model example) and so on. k-values should have consistent units of time with time range specified (below). k-values should have units of 1/t.
-
Time range and units:
- Specify the time range (0 to t) for the generated data and the associated units. Default is 250 minutes.
-
Number of steps:
- Specify the number of steps that you would like the integrator to take. Default is 100,000. Warning: too many steps will result in a lot of RAM usage and may take a long time.
-
Mass or concentration:
-
Specify whether you want the y-values generated to be in mass or concentration.
The default output is mass (of the same units as initial values). If you would like
to have outputs given as concentrations, another row will appear called the "Animal Model Constant"
prompting you to fill out a constant and select which compartments you want it to affect.
Animal Model Constant:
While modeling mass transfer between systems is typically easiest,
often to compare the amount of drug in the body to the efficacious therapeutic dose (or cytotoxic dose)
a concentration is required. The Animal Model Constant is a conversion factor that allows you to convert
mass to concentration (typically (blood volume)-1 or (distribution volume)-1. This will vary between
animal models and so users will have to determine the conversion appropriate for their system.
At present this application only supports one conversion factor and so for systems where one would need
to use a different conversion factor for each compartment we recommend only converting to concentration
for the compartment of interest or keeping all compartments in terms of mass. You are allowed to put in
mathematical expressions or numbers here.
After inputting the parameters for your system, you can press the “Calculate & Graph” button which will solve the system of ODEs using a 4th order Runge-Kutta ODE solver and generate mass vs. time or concentration vs. time curves for each compartment. The results will be graphed and can also be downloaded as a CSV to be plotted by the user.
Part 2: Rate Constant Calculator
Inputs:
- Press the "Load-in packages" button!
-
Choose CSV file to upload:
- Clicking this field will bring up an input dialog for you to upload a CSV. Please follow the format of the CSV here. Essentially, you will want the first row to be headers, your first column to be time, and your second column to be the dependent variable. Any additional columns are not supported currently and will produce errors. Please ensure that you delete any data that you do not want to consider any entry (time, value) that is missing either value will just result in the entire row being ignored. Please note that your data also must be normalized.
-
Number of Compartments, Mass or Concentration, Animal Model Constant:
- Same as part 1.
-
CSV data represents:
- Please input what compartment your CSV data represents. In the example case, our data represented Compartment 3.
-
Compartment Info:
- Please indicate the bounds for k-values that you are unsure of and the initial value that the compartment starts off at. If you do know the value, please tick the "Constrain" box and fill in what the k-value is for that compartment.
Finally, you can press the "Calculate k-values" button which will parse your inputs and return final k-value results for each compartment. For specifics as to how this is done check-out the Python files which the code from this app is based on and the methodologies section in the full DOCUMENTATION for this web application. There is also an example Jupyter Notebook that can be customized to your specific situation. The link to that repository is HERE. Enjoy and best of luck with your research!
If for whatever reason you cannot utilize or run this application or it is displaying weirdly, you can visit THIS page which hosts an identical version of this app.
Pharmacokinetic Data Modeling Calculator and Visualizer
Rate Constant Calculator
TROUBLESHOOTING?
Visit the full DOCUMENTATION page for tips on troubleshooting. Additionally, check out the original Github page where a more up to date version of this application may be hosted HERE.
This tool was built by Peyton Chen (peytonc@stanford.edu). The project source code files and other miscellaneous supporting files are available here on Github. (2021)