ArgumentError invalid index

Hi there!

I am a newcomer in the field of pk/pd modelling but so far Pumas treated me very nicely. Thank you for that!
Currently i try to rebuild the model given in:
https://pubmed.ncbi.nlm.nih.gov/32748108/

For this i use JuliaPro Version 1.5.2-2 and Pumas Version 1.1.0.
My model then looks like this:

using Pumas
using Random
using Plots

pk_cmp = @model begin
  @param begin
    Ω ∈ PDiagDomain(4)
  end

  @random begin
    η ~ MvNormal(Ω)
  end

  @pre begin
    #transition parameters between compartments
    k_1     = 0.037
    k_2     = 0.06
    k_3     = 0.17
    k_d     = 0.0012
    R_max   = 5100.
    E_arac  = 304.8
    KC_arac = 2370.8
    Vc_arac = 118.
    Vp_arac = 98.2
    Cl_arac = 65.7
    Q_arac  = 229.1
    E_FLT3  = 8.
    KC_FLT3 = 1.2
    k_FLT3 = 3.2
    Vc_FLT3 = 252.2
    Cl_FLT3 = 3.5 
    k_des   = 1.4*10^-5
    k_med = 5
    G_init = 65.
    S_init = 26.
    M_init = 9.
    D_init = 0.
    I_max_init = 1.
  end

  @vars begin
    C_tot = G + S + M
    INH_FLT3 = (I_max * C_FLT3) / (KC_FLT3 + C_FLT3)
    STIM_FLT3 = (E_FLT3 * C_FLT3) / (KC_FLT3 + C_FLT3)
    STIM_arac = (E_arac * C_arac) / (KC_arac + C_arac)
  end

  @init begin
    G      = G_init
    S      = S_init
    M      = M_init
    D      = D_init
    I_max  = I_max_init
  end 
      
  @dynamics  begin
    D_FLT3' = - k_FLT3 * D_FLT3
    C_FLT3' = k_FLT3 * D_FLT3 - (Cl_FLT3 / Vc_FLT3) * Cl_FLT3 
 
    C_arac' = - ((Cl_arac + Q_arac) / Vc_arac) * C_arac + (Q_arac / Vp_arac) * P_arac 
    P_arac' = (Q_arac / Vc_arac) * C_arac - (Q_arac / Vp_arac) * P_arac
    
    G'      = 2 * M * k_3 * (1 - C_tot/R_max) - G * k_1 * (1 - C_tot/R_max) * (1 - INH_FLT3) - k_d * G * (1 + STIM_FLT3)
    S'      = k_1 * (1 - C_tot/R_max) * (1 - INH_FLT3) * G - k_2 * S - k_d * S * (1 + STIM_arac)
    M'      = k_2 * S - k_3 * (1 - C_tot/R_max) * M - k_d * M
    D'      = k_d * (G * (1 + STIM_FLT3) + S + M)   
    I_max'  = k_des * (1 - I_max * (1 + (sign(C_FLT3 - KC_FLT3)) * (C_FLT3/KC_FLT3)))        
  end

@derived begin
  C_FLT3_conc ~ @. C_FLT3
  C_arac_conc ~ @. C_arac 
end

@observed begin
  G_conc = @. G
  S_conc = @. S
  M_conc = @. M
  D_conc = @. D
  I_maxO = @. I_max
  C_sum  = @. G + S + M + D
end
end

When i started to simulate i encountered an error i am not able to fully fix the way i want it to.
Basically if i choose the dose to go on cmt=1 everything works as expected:

dose1 = DosageRegimen(50; time = 0.1 ,evid = 1, cmt =1)
regimen = DosageRegimen(dose1)
turnover_params = (init_param(pk_cmp))
sub = Subject(events = regimen)
sim = simobs(pk_cmp, sub, turnover_params, obstimes = 0:0.1:120)

Changing the cmt like:

dose1 = DosageRegimen(50; time = 0.1 ,evid = 1, cmt =:D_FLT3)

however returns the error:

ERROR: LoadError: ArgumentError: invalid index: :D_FLT3 of type Symbol
Stacktrace:
 [1] to_index(::Symbol) at ./indices.jl:297
 [2] to_index(::LabelledArrays.LArray{Float64,1,Array{Float64,1},(:D_FLT3, :C_FLT3, :C_arac, :P_arac, :G, :S, :M, :D, :I_max)}, ::Symbol) at ./indices.jl:274
 [3] to_indices at ./indices.jl:325 [inlined]
 [4] to_indices at ./indices.jl:322 [inlined]
 [5] view at ./subarray.jl:157 [inlined]
 [6] maybeview at ./views.jl:133 [inlined]
 [7] dose! at /Users/vagrant/.julia/packages/Pumas/iIBBr/src/simulate_methods/diffeqs.jl:412 [inlined]
 [8] (::Pumas.var"#affect!#865"{DataType,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Bool,Symbol,Float64,Float64,Int64,Array{Pumas.Event{Float64,Float64,Float64,Float64,Float64,Float64,Nothing,Symbol},1},Base.RefValue{Bool},Base.RefValue{Float64},Base.RefValue{Float64},Base.RefValue{Float64},LabelledArrays.LArray{Float64,1,Array{Float64,1},(:D_FLT3, :C_FLT3, :C_arac, :P_arac, :G, :S, :M, :D, :I_max)},Base.RefValue{Float64},Base.RefValue{Float64},Base.RefValue{Float64},Base.RefValue{Int64},Base.RefValue{Bool},Base.RefValue{Int64},Base.RefValue{Int64},Base.RefValue{Int64},Base.RefValue{Int64},Array{Float64,1},LabelledArrays.LArray{Float64,1,Array{Float64,1},(:D_FLT3, :C_FLT3, :C_arac, :P_arac, :G, :S, :M, :D, :I_max)},Base.RefValue{Float64},Base.RefValue{Bool}})

I am not sure if i miss something?
Thanks for the support and the opportunity the share my error.

Cheers,
Adrian

Hi Adrian,

Thanks for the nice words and thanks for the reproducer. It made it easy for me to reproduce. In Pumas 1.1, there was a bug related to referring to compartments with a Symbol. The issue has been fixed in the latest version of Pumas.

New versions of Pumas are offered only on juliahub.com but they are still free for academic use. If you are interested in trying it out, please contact sales@pumas.ai.

Best
Andreas Noack

Thank you very much for the fast reply! That helps a lot.

Best regards,
Adrian

Is the latest version of Pumas the long waited version 2.0?

Sorry for the delayed reply.
Yes the latest version is 2.0.1.