DosageRegimen varies during infusion time

Hi all,

I have a question related to creating DosageRegimen in which Dose varies during infusion time.

Let’s assume that due to some reason that the drug loses during infusing, and the concentration decreases with time. And I want to create the ‘dynamical dose’. Is any way for me to do this?

For instance, I have 1000 mg at the onset of therapy, after 30 min, the amt is 950 mg until fulfilling the infusion, assume 2h, the amt is 800 mg. If I traditionally create DosageRegimen, the dose (and actually the concentration) is seen to be incremental.

Thank you for your help,
Tien Nguyen.

You can create 3 different infusion doses with your specifications. For eg, first infusion is 50mg for 30min, followed by 150mg for 2h…etc. Can you try that?
J

Thank you for your response.

I tried this before asking my question, but it didn’t work. The amt is counter for new events, but in this example, it must still be in 1 events.

I also tried to modify in @model like that, Cp = @. (Central.X%)/Vc, where X% is array[100, 95, 90, 85, 80]. But it when I executed my simulation, I had an error DimensionMismatch("arrays could not be broadcast to a common size; got a dimension with lengths 129 and 7")

Thank you for your help,
Tien Nguyen.

Please elaborate. Why can’t it be three different back-to-back infusion doses?

Thank you for your response,

The problem is due to some reason (especially instability drug), the drug loses during infusing, and the concentration (and amt) decreases with time in the infusing solution.

So lets me assume that the drug is given in extended infusion (for example with 3h), then the amt naturally decreases in infusion solution bags. So basically, it is still in 1 events.

I don’t know whether what I explained above matching with your question.

Thank you for your help,
Tien Nguyen.

My question was mostly why it’s necessary to treat this as a single dose in the dataset/software. It’s not clear to me why it would matter. Splitting it into three doses in the dataset would just be a convenient way of handling the effect that you are describing. The number of events in the software seems like it could be considered an internal detail as long as the total dose matches what was administered.

An alternative solution that might be closer to the real world would be to model the infusion rate as a smoothly decaying function over time. That is possible but then you’d have to carry the dose information as a covariate instead of using the event system since the latter only handles the three standard administration types. That can be done in the pre block. See the Weibull example in Absorption models for how this can be done.

Dear Tien - Interesting discussion. You may want to consider the following if you want to treat the dose as one event:

  1. Setup a diff eq based model with a depot and central compartments. Use a first-order transfer from depot to central; you can fix the ka to a high number 5/hr for eg. This will not be your rate-limiting step.
  2. Add a zero-order kloss from the depot compartment. If you know the ‘degradation’ rate from stability experiments you can fix to that rate here.
  3. Perform a simple simulation to begin with, to make sure this is what you wanted to achieve.
  4. If happy so far, then you can add a step-wise change in the kloss based on your requirements.
    J

Thank you, Joga and Andreas Noack for your recommendation.

  1. First, I have the same idea as you, Joga. But the depot here corresponding to the infusion solution, so I think instead of using 1-order transfer from depot to central, we should use zero-order with rate = Depot/duration. And depot here has 2 zero-order rates.

  2. Why this zero-order model has an error when simulation, I just copy this in tutorial. I’m using Pumas 2.0.

pk_03        = @model begin
  @param begin
    tvcl     ∈ RealDomain(lower=0)
    tvvc     ∈ RealDomain(lower=0)
    tvTabs   ∈ RealDomain(lower=0)
    Ω        ∈ PDiagDomain(3)
    σ²_prop  ∈ RealDomain(lower=0)
  end

  @random begin
    η        ~ MvNormal(Ω)
  end

  @pre begin
    Cl       = tvcl * exp(η[1])
    Vc       = tvvc * exp(η[2])
    duration = (Central = tvTabs * exp(η[3]),)
  end

  @dynamics begin
    Central' =  - (Cl/Vc)*Central
  end

  @derived begin
    cp       = @. 1000*(Central/Vc)
    dv       ~ @. Normal(cp, sqrt(cp^2*σ²_prop))
  end
end

param = ( tvcl     = 45.12,
          tvvc     = 96,
          tvTabs   = 4.54,
          Ω        = Diagonal([0.0,0.0,0.0]),
          σ²_prop  = 0.015
)

ev1   = DosageRegimen(20,rate=-2)
sub1  = Subject(id=1,events=ev1)

Random.seed!(123)
sim_sub1 = simobs(pk_03, sub1, param, obstimes=0:0.1:10)


ERROR: ArgumentError: either rate or duration should be set in the @pre block when the Event rate is -2

Tien -

The tutorials in that page are being updated to the new syntax, but essentially what you are hitting is an error due to a syntax change in 2.0. All parameters that control the dose are now in a new block called the dosecontrol block. You can see the documentation here.

here is the complete code that will help you run the example in Pumas 2.0

using Random, Pumas, PumasUtilities
pk_03        = @model begin
  @param begin
    tvcl     ∈ RealDomain(lower=0)
    tvvc     ∈ RealDomain(lower=0)
    tvTabs   ∈ RealDomain(lower=0)
    Ω        ∈ PDiagDomain(3)
    σ²_prop  ∈ RealDomain(lower=0)
  end

  @random begin
    η        ~ MvNormal(Ω)
  end

  @pre begin
    Cl       = tvcl * exp(η[1])
    Vc       = tvvc * exp(η[2])
  end

  @dosecontrol begin
    duration = (Central = tvTabs * exp(η[3]),)
  end

  @dynamics begin
    Central' =  - (Cl/Vc)*Central
  end

  @derived begin
    cp       = @. 1000*(Central/Vc)
    dv       ~ @. Normal(cp, sqrt(cp^2*σ²_prop))
  end
end

param = ( tvcl     = 45.12,
          tvvc     = 96,
          tvTabs   = 4.54,
          Ω        = Diagonal([0.0,0.0,0.0]),
          σ²_prop  = 0.001
)

ev1   = DosageRegimen(20,rate=-2)
sub1  = Subject(id=1,events=ev1, observations = (cp = nothing, dv=nothing))

Random.seed!(123)
sim_sub1 = simobs(pk_03, sub1, param, obstimes=0.1:0.1:10)

sim_plot(pk_03, [sim_sub1])

Thank you Profesor for your answer.

Dear all, Can I use if - else control follow in @pre block? I tried to use it but had an error

Thank you for your help.

using Pumas, DataFrames, Plots, Pkg, CSV, Random, PumasUtilities

model = @model begin
    @param begin
        θCl ∈ RealDomain(lower = 0.0, init = 5.27)
        θVc ∈ RealDomain(lower = 0.0, init = 17.2)
        θQ  ∈ RealDomain(lower = 0.0, init = 9.92)
        θVp ∈ RealDomain(lower = 0.0, init = 10.6)
        θX ∈ RealDomain(lower = 0.0, init = 0.2)
        #θduration ∈ RealDomain(lower = 0.0, init = 3)
        Ω_IIV ∈ PDiagDomain(init = [log(0.265^2 + 1), log(0.307^2 + 1)]) # IIV for Cl and Vc
    end

    @random begin
        η_IIV ~ MvNormal(Ω_IIV)
    end

    @covariates begin
        Clcr
        Wt
    end

    @pre begin
        Cl = θCl*(1 + 0.014*(Clcr - 39.0)*(60/1000))*(1 + 0.007*(Wt - 75))*exp(η_IIV[1])
        Vc = θVc*(1 + 0.0225*(Wt - 75))*exp(η_IIV[2])
        Vp = θVp
        Q = θQ
        if t <= 3
            μ = (θX/100)*t
        else μ = 0
        end 
    end

    #=@dosecontrol begin
        duration = (Central = θduration, )
    end=#

    @dynamics begin
        Depot' = -Depot*μ
        Central' = Depot/3 -Central*(Cl/Vc + Q/Vc) + Peri*Q/Vp
        Peri' = Central*Q/Vc - Peri*Q/Vp
    end

    @derived begin
        #Cdepot = Depot/1
        Cp = @. Central/Vc
        # dv ~ @. Normal(Cp, sqrt(...))
    end
end
ERROR: Variable μ already defined

Yes that is allowed but you can only assign to a variable once, so you’d have to write it like

μ = if t <= 3
    (θX/100)*t
else
    zero((θX/100)*t)
end

Using zero instead of 0 isn’t strictly require but it ensures that both branches in the control flow statement produce floating point values. This will give better performance.

An alternative formulation without control flow is

μ = (t <= 3)*(θX/100)*t

It’s interesting! Thank you for your help.