Task

Solution

Packages

library(httk)
library(tidyverse)
library(simuloR)

Simulation by R

parms <- parameterize_1comp(chem.name = "theophylline")
## Warning in available_rblood2plasma(chem.cas = chem.cas, chem.name =
## chem.name, : Human in vivo Rblood2plasma returned.
parms
## $Vdist
## [1] 0.7801997
## 
## $kelim
## [1] 0.2653932
## 
## $Clint
## [1] 0.7476636
## 
## $Clint.dist
## [1] NA
## 
## $Funbound.plasma
## [1] 0.8965508
## 
## $Funbound.plasma.dist
## [1] NA
## 
## $Funbound.plasma.adjustment
## [1] 0.9961675
## 
## $Fhep.assay.correction
## [1] 0.9564623
## 
## $Pow
## [1] 0.8078951
## 
## $pKa_Donor
## pKa_Donor 
##    "7.82" 
## 
## $pKa_Accept
## pKa_Accept 
##         NA 
## 
## $MA
## [1] NA
## 
## $kgutabs
## [1] 2.18
## 
## $Rblood2plasma
## [1] 1.33
## 
## $million.cells.per.gliver
## [1] 110
## 
## $liver.density
## [1] 1.05
## 
## $hematocrit
## [1] 0.44
## 
## $MW
## [1] 180.167
## 
## $Fgutabs
## [1] 0.98
## 
## $hepatic.bioavailability
## [1] 0.9328532
## 
## $BW
## [1] 70
ffpk <- function(IngDose, Fgutabs, kgutabs, kelim, Vdist, BW, t){
    A <- (IngDose * Fgutabs * kgutabs)/(Vdist * BW * (kgutabs - kelim))
    Conc <- A * exp(-kelim * t) - A * exp(-kgutabs * t)
    return(Conc)
}
Fgutabs <- parms$Fgutabs * parms$hepatic.bioavailability
kgutabs <- parms$kgutabs
kelim <- parms$kelim
Vdist <- parms$Vdist
S1 <- subset(Theoph, Subject == 1)
mean(S1$Dose)
## [1] 4.02
mean(S1$Wt)
## [1] 79.6
IngDose <- mean(S1$Dose)*mean(S1$Wt)
IngDose
## [1] 319.992
out1 <- ffpk(IngDose = IngDose, 
             Fgutabs = Fgutabs,
             kgutabs = kgutabs, kelim = kelim,
             Vdist = Vdist, 
             BW = 79.6,
             t = S1$Time)
out1
##  [1] 0.000000000 1.909156333 3.062364221 3.517523615 3.072105720
##  [6] 1.944726071 1.385452594 0.830168992 0.485673409 0.215030371
## [11] 0.008328742
conc1 <- subset(Theoph, Subject == 1) %>% select(conc)

plot(S1$Time, conc1$conc)
lines(S1$Time, out1)

Simulation by MCSim

Non-Compartment model

IngDose    = 319.992;     # ingested dose (mg)
BW         = 79.6;        # body weight (kg)
Fgutabs    = 0.9142;      # bioavailability (-) 
kgutabs    = 2.18;        # absortion rate (/h)
kelim      = 0.2654;      # elimination rate constant (/h)
Vdist      = 0.7802;      # volumes (L/kg BW)

Simulation {
  Print (Conc 0.00   0.25   0.57   1.12   2.02   3.82   5.10   7.03   9.05  12.12  24.37);
}
End.

Use linux command

  • Create exectuable program (makemcsim)
makemcsim models/ffpk.model mcsim.ffpk
  • Conduct simulation
models/mcsim.ffpk inputs/ffpk.in

Use simuloR function

  • Create exectuable program
ffpk.model <- "models/ffpk.model"
makemcsim(model = ffpk.model)
## * Creating executable program, pleas wait...
## * Created executable program 'models/mcsim.ffpk.model'.
  • Create exectuable program and conduct simulation
mcsim(model = "models/ffpk.model", input = "inputs/ffpk.in")
## * Creating executable program, pleas wait...
## * Created executable program 'models/mcsim.ffpk.model'.
## Executing...
##     Time       Conc
## 1   0.25 1.90916000
## 2   0.57 3.06237000
## 3   1.12 3.51752000
## 4   2.02 3.07209000
## 5   3.82 1.94469000
## 6   5.10 1.38541000
## 7   7.03 0.83013600
## 8   9.05 0.48564700
## 9  12.12 0.21501400
## 10 24.37 0.00832743
  • Load file
read.delim(file = "sim.out")
##       Results.of.Simulation.1
## Time                     Conc
## 0.25                  1.90916
## 0.57                  3.06237
## 1.12                  3.51752
## 2.02                  3.07209
## 3.82                  1.94469
## 5.1                   1.38541
## 7.03                 0.830136
## 9.05                 0.485647
## 12.12                0.215014
## 24.37              0.00832743
read.delim(file = "sim.out", skip = 1)
##     Time       Conc
## 1   0.25 1.90916000
## 2   0.57 3.06237000
## 3   1.12 3.51752000
## 4   2.02 3.07209000
## 5   3.82 1.94469000
## 6   5.10 1.38541000
## 7   7.03 0.83013600
## 8   9.05 0.48564700
## 9  12.12 0.21501400
## 10 24.37 0.00832743

Compartment model

IngDose    = 319.992;     # ingested dose (mg)
BW         = 79.6;        # body weight (kg)
Period     = 48;          # period of the exposure/no exposure cycle (h)
Fgutabs    = 0.9142;      # bioavailability (-) 
kgutabs    = 2.18;        # absortion rate (/h)
kelim      = 0.2654;      # elimination rate constant (/h)
Vdist      = 0.7802;      # volumes (L/kg BW)

Simulation {
  Print (Ccpt 0.00   0.25   0.57   1.12   2.02   3.82   5.10   7.03   9.05  12.12  24.37);
}
End.
out1 <- mcsim(model = "models/ffpk.model", input = "inputs/ffpk.in")
## * Creating executable program, pleas wait...
## * Created executable program 'models/mcsim.ffpk.model'.
## Executing...
out1
##     Time       Conc
## 1   0.25 1.90916000
## 2   0.57 3.06237000
## 3   1.12 3.51752000
## 4   2.02 3.07209000
## 5   3.82 1.94469000
## 6   5.10 1.38541000
## 7   7.03 0.83013600
## 8   9.05 0.48564700
## 9  12.12 0.21501400
## 10 24.37 0.00832743
plot(x = S1$Time, y = conc1$conc)
lines(x = out1$Time, y = out1$Conc)