using Random
using Pumas
using PumasUtilities
using CairoMakie
using AlgebraOfGraphics
using CSV
using DataFramesMeta
PK33 - Transdermal input and kinetics
1 Learning Outcome
To understand the kinetics of a given drug using transdermal input following 2 different input rates
2 Objectives
To build a one compartment model with zero-order input and to understand its function using a transdermal delivery system
3 Background
Before constructing a model, it is important to establish the process the model will follow and a scenario for the simulation.
Below is the scenario for this tutorial:
- Structural model - One compartment linear elimination with zero-order input
- Route of administration - Transdermal
- Dosage Regimen - 15,890 μg per patch. The patch was applied for 16 hours over 5 consecutive days
- Number of Subjects - 1
This diagram describes how such an administered dose will be handled, which facilitates building the model.
4 Libraries
Call the required libraries to get started.
5 Model
This is a one compartment model with zero-order input following transdermal drug administration.
= @model begin
pk_33 @metadata begin
= "One Compartment Model"
desc = u"hr"
timeu end
@param begin
"""
Clearance (L/hr)
"""
∈ RealDomain(lower = 0)
tvcl """
Volume of Central Compartment (L)
"""
∈ RealDomain(lower = 0)
tvvc """
Dose of slow infusion (μg)
"""
∈ RealDomain(lower = 0)
tvdslow """
Duration of fast release (hr)
"""
∈ RealDomain(lower = 0)
tvtfast """
Duration of slow release (hr)
"""
∈ RealDomain(lower = 0)
tvtslow ∈ PDiagDomain(5)
Ω """
Proportional RUV
"""
∈ RealDomain(lower = 0)
σ²_prop """
Additional RUV
"""
∈ RealDomain(lower = 0)
σ_add end
@random begin
~ MvNormal(Ω)
η end
@pre begin
= tvcl * exp(η[1])
Cl = tvvc * exp(η[2])
Vc = tvdslow * exp(η[3])
Dose_slow = tvtfast * exp(η[4])
Tfast = tvtslow * exp(η[5])
Tslow = (t <= Tfast) * (15890 - Dose_slow) / Tfast
Ffast = (t <= Tslow) * Dose_slow / Tslow
Fslow end
@init begin
= 2 * Vc
Central end
@dynamics begin
' = Ffast + Fslow - (Cl / Vc) * Central
Centralend
@derived begin
= @. Central / Vc
cp """
Observed Concentration (μg/L)
"""
~ @. Normal(cp, sqrt((cp^2 * σ²_prop) + σ_add^2))
dv end
end
PumasModel
Parameters: tvcl, tvvc, tvdslow, tvtfast, tvtslow, Ω, σ²_prop, σ_add
Random effects: η
Covariates:
Dynamical system variables: Central
Dynamical system type: Nonlinear ODE
Derived: cp, dv
Observed: cp, dv
6 Parameters
These are the initial estimates we will be using in this model exercise. Note that tv
represents the typical value for parameters.
CL
- Clearance (L/hr),Vc
- Volume of Central Compartment (L)Dslow
- Dose of slow infusion (μg)Tfast
- Duration of fast release (hr)Tslow
- Duration of slow release (hr)Ω
- Between Subject Variabilityσ
- Residual error
= (;
param = 79.8725,
tvcl = 239.94,
tvvc = 11184.3,
tvdslow = 7.54449,
tvtfast = 19.3211,
tvtslow = Diagonal([0.01, 0.01, 0.01, 0.01, 0.01]),
Ω = 0.005,
σ²_prop = 0.01,
σ_add )
7 Dosage Regimen
- 15,890 μg per patch.
- The patch is applied for 16 hours, for 5 consecutive days
- The patch releases the drug at two different rate processes, fast and slow, simultaneously over a period of 6 and 18 hours respectively.
= Subject(; id = 1, observations = (cp = nothing,)) sub1
Subject
ID: 1
Observations: cp: (n=0)
8 Simulation
Since the model is created and the initial parameters are specified, one should evaluate the model. Simulating with a single subject is one way to address this.
The Random.seed!
function is included here for purposes of reproducibility of the simulation in this tutorial. Specification of a seed value would not be required in a Pumas workflow that is estimating model parameters.
Random.seed!(123)
= simobs(pk_33, sub1, param, obstimes = 0:0.1:24) sim_sub1
SimulatedObservations
Simulated variables: cp, dv
Time: 0.0:0.1:24.0
9 Visualization
@chain DataFrame(sim_sub1) begin
dropmissing(:cp)
data(_) *
mapping(:time => "Time (hours)", :cp => "Concentration (μg/L)") *
visual(Lines; linewidth = 4)
draw(; figure = (; fontsize = 22), axis = (; xticks = 0:5:25))
end
10 Population Simulation
This block updates the parameters of the model to increase intersubject variability in parameters and defines timepoints for the prediction of concentrations. The results are written to a CSV file.
= (
par = 79.8725,
tvcl = 239.94,
tvvc = 11184.3,
tvdslow = 7.54449,
tvtfast = 19.3211,
tvtslow = Diagonal([0.012, 0.024, 0.012, 0.01, 0.012]),
Ω = 0.008,
σ²_prop = 0.01,
σ_add
)
= DosageRegimen(15890; time = 0, cmt = 1)
ev1 = map(i -> Subject(id = i, events = ev1), 1:24)
pop
Random.seed!(1234)
= simobs(
sim_pop
pk_33,
pop,
par,= [0, 0.5, 1, 2, 3, 4, 6, 8, 10, 12, 14, 16, 17, 18, 21, 23.37],
obstimes
)= DataFrame(sim_pop)
df_sim
#CSV.write("pk_33.csv", df_sim)
With the CSV.write
function, you can input the name of the DataFrame
(df_sim
) and the file name of your choice (pk_33.csv
) to save the file to your local directory or repository.
11 Conclusion
Constructing a transdermal one-compartment model with zero-order input involves:
- understanding the process of how the drug is passed through the system,
- translating processes into ODEs using Pumas,
- preparing the data using Pumas data wrangling functionality, and
- simulating the model in a single patient for evaluation.