ronkeizer / PKPDsim

R library for simulation of PKPD models [DEPRECATED, see InsightRX/PKPDsim]
Other
21 stars 12 forks source link

Problems implementing F1 Bioavailability #33

Open Anathawa opened 7 years ago

Anathawa commented 7 years ago

Trying and failing miserably. :)

Using the premade model pk1_cmt_oral, I get this description: ODE definition:

dAdt[1] = -KA*A[1];;
dAdt[2] = KA*A[1] - (CL/V)*A[2];;

;

Required parameters: KA, CL, V Covariates: Variables: Number of compartments: 2 Observation compartment: 2 Observation scaling: V Lag time:

The model has two compartments, with the amount of the chemical, 1 being the gut, 2 the central compartment i.e plasma? And to get the concentration I need to decide on an observation compartment and scale it? "Obs" here is compartment 2 (in mg) divided by the selected scaling variable V (L) giving me the concentration in mg / L? (How does the model know scaling means division, not multiplication..?)

basemodel <- new_ode_model( code = " dAdt[1] = -KA A[1] dAdt[2] = +KA A[1] -(CL/V) * A[2] ",obs = list(cmt = 2, scale = "V"))

gives me the same results as pk1_cmt_oral, and adding F1 should be

Bioavailability <- new_ode_model( code = " dAdt[1] = -KA A[1] dAdt[2] = +KA A[1] -(CL/V) * A[2] ",obs = list(cmt = 2, scale = "V"), dose = list(cmt = 1, bioav = "F1")

but this code gives me an error ( error: 'F1' was not declared in this scope)

and declaring it like this: Bioavailability <- new_ode_model( code = " dAdt[1] = -KA A[1] dAdt[2] = +KA A[1] -(CL/V) * A[2] ",obs = list(cmt = 2, scale = "V"), dose = list(cmt = 1, bioav = "F1") declare_variables = c("F1") ) gives me zero in all compartments

Hardcoding an F1 value doesn't change my results from not using any bioavailability data.

Bioavailability <- new_ode_model( code = " dAdt[1] = -KA A[1] dAdt[2] = +KA A[1] -(CL/V) * A[2] ",obs = list(cmt = 2, scale = "V"), dose = list(cmt = 1, bioav = 0.000000001) ) has no effect?

Started looking for it in source code, but thought I'd better ask. :)

ronkeizer commented 7 years ago

How does the model know scaling means division, not multiplication..?

That is more or less by convention, this is how scaling is defined in NONMEM (and I suppose in Monolix too).

gives me zero in all compartments

I think the code is correct (the version where you declare F1 as variable too). Do you supply "F1" as a parameter (or as a covariate) when you run the simulation? (you should)

philipdelff commented 5 years ago

Hi,

I just spend a little time getting exactly this working (on InsightRX/PKPDsim though). F1 should not be a defined as a variable, only a parameter. I found out by using ronkeizer's example from https://github.com/ronkeizer/PKPDsim/issues/35

Here is a full working example:

library(remotes) install_github("InsightRX/PKPDsim") library(PKPDsim) library(ggplot2)

pk1 <- new_ode_model(code = " dAdt[1] = -KA A[1] dAdt[2] = +KA A[1] -CL/V2 A[2] + Q(1/V3A[3] - 1/V2A[2]) dAdt[3] = Q(1/V2A[2] - 1/V3*A[3])" ,dose = list(cmt = 1, bioav = "F1") ### param goes here ,obs = list(cmt = 2, scale = "V2") ,parameters = c("F1","V2","CL","KA","V3","Q") )

pars <- list( KA = 1 ,V2 = 1.5 ,V3 = 3 ,Q = .5 ,CL =1 ,F1 = .4 )

reg <- new_regimen( ,amt = 400 ,times = c(0) ,cmt = c(1) )

simres <- sim( ode = pk1, parameters = pars, regimen = reg2, t_obs = seq(0,24,by=.1) )

ggplot(simres,aes(t,y,colour=comp))+geom_line()