Skip to content

This Python library models the diffusion of a drug through the body, using simple 2- and 3-compartment pharmacokinetic models. This project does not feature interactions with pharmacodynamic models.

License

Notifications You must be signed in to change notification settings

ian-mcfarlane/pk-modelling

Repository files navigation

Run unit tests OS Tests codecov BCH compliance

Pharmacokinetic Model for Intravenous and Subcutaneous Dosing

To install this package using pip use the command:

pip3 install -i https://test.pypi.org/simple/ pkmodel-sabs-group4

This Python library models the diffusion of a drug through the body, using simple 2- and 3-compartment pharmacokinetic models. This project does not feature interactions with pharmacodynamic models.

These models can be used to ensure there are sufficient concentrations of the drug administered according to its toxic threshold and the desired efficacy of the drug regimen.

2-Compartment Model (Intravenous Dosing)

The 2-compartment model describes intravenous bolus dosing into a body with one "central" compartment and one "peripheral" compartment.

The central compartment is where the drug is directly administered according to the Dose function, and excreted according to rate CL.

The drug diffuses between the central and peripheral compartments according to the rate Qp1 and their relative volumes and drug concentrations.

The corresponding system of ordinary differential equations for this model is:

equation

equation

Where:

  • qc is the quantity of the drug in the central compartment
  • qp1 is the quantity of the drug in the peripheral compartment
  • Dose(t) is the dose function
  • Vc is the volume of the central compartment
  • Vp1 is the volume of the peripheral compartment
  • CL is the clearance rate from the central compartment
  • Qp1 is the transition rate between central compartment and the peripheral compartment.

3-Compartment Model (Subcutaneous Dosing)

The 3-compartment model describes subcutaneous dosing into a body with one "central" compartment and one "peripheral" compartment. The subcutaneous dosing is represented by a third compartment into which the dose is administered, from which the drug diffuses into the central compartment according to rate q0

The drug diffuses between central and peripheral compartments as in the 2-compartment model.

The corresponding system of ordinary differential equations for this model is:

equation

equation

equation

Where:

  • q0 is the concentration of drug in the initial dosing subcutaneous compartment
  • ka is the rate of diffusion from the subcutaneous compartment to the central compartment
  • All other parameters as in the 2-compartment model.

Inputs

All parameters above are to be specified by the user in a .csv file to be read by the model. This file takes the format:

label,comps,Q_p1,V_c,V_p1,CL,X,dose_on,dose_off,k_a,graph_preview.

Each new line of the input .csv file represents a new set of parameters to be run through the model and will each produce a solution.

Each parameter is explained below:

  • label = a string labelling the set of parameters to distinguish from all other sets being run
  • comps = the number of compartments in the model, with 2 representing intravenous dosing and 3 representing subcutaneous dosing
  • Q_p1 = the diffusion rate (mL/h) between the central and peripheral compartment
  • V_c = the volume (mL) of the central compartment
  • V_p1 = the volume (mL) of the peripheral compartment
  • CL = the clearance rate (mL/h) from the central compartment
  • X = the amount (ng) of drug to be administered at all relevant time points (see section Dosing Functions for guidance on designing a dosing function)
  • dose_on = the number of time periods (1000ths of 1 hour) for which the dose is to be administered at a time (see section Dosing Functions for guidance on designing a dosing function)
  • dose_off (optional) = the number of time periods (1000ths of 1 hour) for which the dose is not to be administered at a time
  • k_a (optional) = the diffusion rate from the subcutaneous dosing compartment to the central compartment in the 3-compartment model
  • graph_preview (optional) = True or False, indicating whether to show a preview of the dosing graph when creating parameter sets.

Outputs

The model outputs a graph representing the change in drug quantity for each compartment for each set of parameters input.

Appendix 1: Dosing functions

The dosing regimen is specified by three parameters in the model inputs:

  • X - the amount of drug in ng administered
  • dose_on - the length of time period for which doses are administered
  • dose_off - the length of time between each dosing period

Example 1

If dose_on = 0 then the dose function represents an instantaneous dose at time 0 and no more of the drug will be administered. In this case dose_off does not need to be specified, and its value will not affect the dose function.

For example, if:

  • X = 1, and
  • dose_on = 0

the dose function is as below:

dose_func_ex_1

Example 2

If dose_on > 0 and dose_off = 0 then the dose function represents the drug administered continuously for the whole time period.

For example, if:

  • X = 1,
  • dose_on = 1, and
  • dose_off = 0,

the dose function is as below:

dose_func_ex_2

Example 3

If dose_on > 0 and dose_off > 0 then the dose function switches between the drug being administered continuously (for as many time periods as dose_on specifies) and the drug not being administered (for as many time periods as dose_off specifies).

For example, if:

  • X = 1,
  • dose_on = 20, and
  • dose_off = 30,

the dose function is as below:

dose_func_ex_3

Appendix 2: Full Example

If the .csv file used to import parameters is as below:

"Ex. 1", 2,1,1,0.5,1,1,15,20

"Ex. 2", 3,1,1,0.5,1,1,15,20,1

which is interpreted by the model as:

label comps Q_p1 V_c V_p1 CL X dose_on dose_off k_a graph_preview
Ex. 1 2 1 1 0.5 1 1 15 20 (0) (False)
Ex. 2 3 1 1 0.5 1 1 15 20 1 (False)

Running these together through the model, we can compare the intravenous (Ex. 1) with subcutaneous (Ex. 2) dosing and the model saves the below graph:

example_output

About

This Python library models the diffusion of a drug through the body, using simple 2- and 3-compartment pharmacokinetic models. This project does not feature interactions with pharmacodynamic models.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages