using PumasUtilities
using Random
using Pumas
using CairoMakie
using AlgebraOfGraphics
using DataFramesMeta
using CSV
using Dates
PK52 - Simulated impact of disease on r-hSOD kinetics
1 Background
- Structural model - IV infusion - Two compartment Model
- Route of administration - Rapid intravenous infusion of recombinant human superoxide dismutase (r-hSOD)
- Dosage Regimen - 20 mg/kg IV rapid infusion for 15 seconds in two categories of rats
- Number of Subjects - 1 normal rat, 1 clamped (nephrectomized) rat
In this model, a collection of plasma concentration data of parent drug and concentration of parent and metabolite in urine, will help derive the following parameters: Clearance, Volume of Distribution, Km, Vmax.
2 Learning Outcome
This exercise demonstrates
- The influence of the kidney’s removal on clearance and volume of the central compartment. The effective half life has been increased from 10 mins in normal rats to 90 mins in nephrectomized rats.
- The time to steady state might differ ninefold between the two groups.
- Importance of kidneys in the elimination of r-hSOD and the impact of kidney disease/nephrectomy on the overall kinetics of the drug.
3 Objectives
To build a simple two compartment model with 2 sets of parameters corresponding to normal and clamped rats, simulate the model for clamped versus normal subject and supsequently perform simulation for a population.
4 Libraries
Load the necessary libraries.
5 Model Definition
Note the expression of the model parameters with helpful comments. The model is expressed with differential equations. Residual variability is a proportional error model.
= @model begin
pk_52 @metadata begin
= "Two Compartment Model"
desc = u"minute"
timeu end
@param begin
"""
Clearance (mL/min/kg)
"""
∈ RealDomain(lower = 0)
tvcl """
Volume of Central Compartment (mL/min/kg)
"""
∈ RealDomain(lower = 0)
tvvc """
Volume of Peripheral Compartment (mL/min/kg)
"""
∈ RealDomain(lower = 0)
tvvp """
Intercompartmental Clearance (mL/min/kg)
"""
∈ RealDomain(lower = 0)
tvcld ∈ PDiagDomain(4)
Ω ∈ RealDomain(lower = 0)
σ²_prop end
@random begin
~ MvNormal(Ω)
η end
@pre begin
= tvcl * exp(η[1])
Cl = tvvc * exp(η[2])
Vc = tvvp * exp(η[3])
Vp = tvcld * exp(η[4])
Cld end
@dynamics begin
' = -(Cl / Vc) * Central - (Cld / Vc) * Central + (Cld / Vp) * Peripheral
Central' = (Cld / Vc) * Central - (Cld / Vp) * Peripheral
Peripheralend
@derived begin
= @. Central / Vc
cp """
Observed Concentration (μg/mL)
"""
~ @. Normal(cp, sqrt(cp^2 * σ²_prop))
dv end
end
PumasModel
Parameters: tvcl, tvvc, tvvp, tvcld, Ω, σ²_prop
Random effects: η
Covariates:
Dynamical system variables: Central, Peripheral
Dynamical system type: Matrix exponential
Derived: cp, dv
Observed: cp, dv
6 Initial Estimates of Model Parameters
The model parameters for simulation are the following. Note that tv
represents the typical value for parameters.
tvcl
- Clearance (mL/min/kg)tvvc
- Volume of Central Compartment (mL/min/kg)tvvp
- Volume of Peripheral CompartmentRenal (mL/min/kg)tq
- Intercompartmental Clearance (mL/min/kg)Ω
- Between Subject Variabilityσ
- Residual errors
= (;
param1 = 3.0,
tvcl = 31,
tvvc = 15,
tvvp = 0.12,
tvcld = Diagonal([0.01, 0.01, 0.01, 0.01]),
Ω = 0.04,
σ²_prop )
= (;
param2 = 0.22,
tvcl = 16,
tvvc = 13,
tvvp = 0.09,
tvcld = Diagonal([0.01, 0.01, 0.01, 0.01]),
Ω = 0.04,
σ²_prop )
= vcat(param1, param2) param
7 Dosage Regimen
A dose of 20 mg/kg to a single rat of 2 categories (normal and clamped)
= DosageRegimen(20000, cmt = 1) ev1
Row | time | cmt | amt | evid | ii | addl | rate | duration | ss | route |
---|---|---|---|---|---|---|---|---|---|---|
Float64 | Int64 | Float64 | Int8 | Float64 | Int64 | Float64 | Float64 | Int8 | NCA.Route | |
1 | 0.0 | 1 | 20000.0 | 1 | 0.0 | 0 | 0.0 | 0.0 | 0 | NullRoute |
8 Single-individual that receives the defined dose
= Subject(id = "Normal Rat", events = ev1, covariates = (Rat = "Normal_Rat",)) sub1
Subject
ID: Normal Rat
Events: 1
Covariates: Rat
= Subject(id = "Clamped Rat", events = ev1, covariates = (Rat = "Clamped_Rat",)) sub2
Subject
ID: Clamped Rat
Events: 1
Covariates: Rat
= [sub1, sub2] pop2_sub
Population
Subjects: 2
Covariates: Rat
Observations:
9 Single-Subject Simulation
Simulate the plasma concentration after the IV infusion
Initialize the random number generator with a seed for reproducibility of the simulation.
Random.seed!(123)
Define the timepoints at which concentration values will be simulated.
= map(
sim_pop2_sub -> simobs(pk_52, subject, param, obstimes = 0:0.1:500),
((subject, param),) zip(pop2_sub, param),
)
Simulated population (Vector{<:Subject})
Simulated subjects: 2
Simulated variables: cp, dv
10 Visualize Results
@chain DataFrame(sim_pop2_sub) begin
dropmissing(:cp)
data(_) *
mapping(:time => "Time (hours)", :cp => "Concentration (μg/L)", color = :id => "") *
visual(Lines; linewidth = 4)
draw(;
= (; fontsize = 22),
figure = (;
axis = log10,
yscale = i -> (@. string(round(i; digits = 1))),
ytickformat = 0:50:500,
xticks = "Simulated impact of disease on r-hSOD kinetics",
title
),= (; position = :bottom),
legend
)end
11 Population Simulation
We perform a population simulation with 16 participants.
This code demonstrates how to write the simulated concentrations to a comma separated file (.csv
).
= (;
par1 = 3.0,
tvcl = 31,
tvvc = 15,
tvvp = 0.12,
tvcld = Diagonal([0.012, 0.0231, 0.0432, 0.0311]),
Ω = 0.04,
σ²_prop
)
= (;
par2 = 0.22,
tvcl = 16,
tvvc = 13,
tvvp = 0.09,
tvcld = Diagonal([0.0231, 0.0432, 0.0121, 0.0331]),
Ω = 0.04,
σ²_prop
)
= vcat(par1, par2)
par
= DosageRegimen(20000, cmt = 1)
ev1 = map(i -> Subject(id = i, events = ev1, covariates = (Rat = "Normal_Rat",)), 1:8)
pop1 = map(i -> Subject(id = i, events = ev1, covariates = (Rat = "Clamped_Rat",)), 9:16)
pop2 = [pop1, pop2]
pop
Random.seed!(1234)
= reduce(
sim_pop
vcat,map(
-> simobs(
((subject, paramᵢ),)
pk_52,
subject,
paramᵢ,= [0.2, 2.1, 4.9, 9.5, 14.7, 29, 60, 119, 239, 480],
obstimes
),zip(pop, par),
),
)
= vcat(DataFrame.(sim_pop)...)
df_sim #CSV.write("pk_52_sim.csv", df_sim)
12 Conclusion
This tutorial showed how to build a simple two compartment model with 2 sets of parameters corresponding to normal and clamped rats and perform a single subject and a population simulation.