Skip to content

kylebaron/vera

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vera

Travis build status

Overview

local sensitivity analysis in R with mrgsolve

Model

Load the vera package and a PBPK model from the mrgsolve package. We decrease the tolerance a bit as well as the maximum step size.

library(vera)

mod <- modlib(
  "pbpk", 
  end = 12,     delta = 0.1, 
  atol = 1E-20, rtol  = 1E-12, hmax = 0.5
) %>% obsonly

Scenario

Create a function that uses the model to simulate a certain scenario. For now, we just simulate a single dose.

fun <- function(p,dose) {
  mod %>% 
    param(p) %>% 
    ev(dose) %>% 
    mrgsim()
}

d <- ev(amt = 100)

fun(param(mod),d) %>% plot(Cp+Amu~time)

Sensitivity analysis

Use vera::lsa(). We pick the parameters that we want to fiddle with (par):

  • Kpli liver partition coefficient
  • Kpmu muscle partition coefficient
  • Kpad adipose tissue partition coefficient
  • BW body weight

Also specify the output that we want to look at (var):

  • Cp - venous concentration
  • Amu - amount in the muscle compartment

d gets passed through to the function as dose.

out <- lsa(mod, fun, par = "Kpli,Kpmu,Kpad,BW", var = "Cp,Amu", dose = d)

Ouput

The output is long and ready to send in to ggplot2.

head(out)
.   time var    value  par       sens
. 1  0.0  Cp 0.000000 Kpli  0.0000000
. 2  0.1  Cp 0.913300 Kpli -0.2344372
. 3  0.2  Cp 1.240780 Kpli -0.2207772
. 4  0.3  Cp 1.425315 Kpli -0.2315567
. 5  0.4  Cp 1.546065 Kpli -0.2460310
. 6  0.5  Cp 1.625033 Kpli -0.2619396

There is a default plotting method as well.

plot(out)

Plot with ggplot2

library(ggplot2)

filter(out, par=="Kpmu") %>% 
  ggplot(aes(time,sens,col=var)) + 
  geom_line(lwd=1) + theme_bw() + 
  scale_color_brewer(palette="Set2") + 
  theme(legend.position="top") + 
  facet_wrap(~par) + geom_hline(yintercept=0,lty=2)


More info

See inst/doc/about.md (on GitHub only) for more details.

About

Local sensitivity analysis with mrgsolve

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published