if (campsis::on_cran()) { cat( "This vignette was not built on CRAN. Please check out the online version [here](https://calvagone.github.io/campsis.doc/articles/v04_bioavailability.html)." ) knitr::knit_exit() }
library(campsis)
There are 2 ways to implement bioavailability in Campsis:
In the first case, the simulation engine will take care of the bioavailability. In the second case, Campsis will adapt automatically the amount injected through the dataset (AMT column).
Let's use a 2-compartment model with absorption compartment to illustrate how this can be achieved.
model <- model_suite$nonmem$advan4_trans4
For this example, we're going to define a bioavailability F1 for this absorption compartment.
First let's create a new parameter F1, log-normally distributed with a median of 0.75 and 10% CV.
model <- model %>% add(Theta(name = "F1", value = 0.75)) %>% add(Omega(name = "F1", value = 10, type = "cv%"))
Now, let's add an equation to the drug model to define F1.
model <- model %>% add(Equation("F1", "THETA_F1*exp(ETA_F1)"))
Finally, we need to tell Campsis that F1 corresponds to a bioavailability.
model <- model %>% add(Bioavailability(compartment = 1, rhs = "F1"))
Our persisted drug model would look like this:
model
Now, let's now give a simple bolus and simulate with and without F1.
ds1 <- Dataset(50) %>% add(Bolus(time = 0, amount = 1000)) %>% add(Observations(times = seq(0, 24, by = 0.5)))
results_f1 <- simulate(model = model, dataset = ds1, seed = 1) results_no_f1 <- simulate( model = model_suite$nonmem$advan4_trans4, dataset = ds1, seed = 1 ) gridExtra::grid.arrange( shaded_plot(results_f1, "CONC"), shaded_plot(results_no_f1, "CONC"), nrow = 1 )
The same simulation can be performed by adapting the column AMT in the dataset.
First, we need to sample F1 values. This can be done as follows:
set.seed(1)
distribution <- ParameterDistribution( model = model, theta = "F1", omega = "F1" ) %>% sample(50L)
We can then pass the pre-sampled distribution.
ds2 <- Dataset(50) %>% add(Bolus(time = 0, amount = 1000, f = distribution)) %>% add(Observations(times = seq(0, 24, by = 0.5)))
Let's have a look at the dataset, in its table form, and if we look at the doses only:
ds2 %>% export(dest = "rxode2") %>% dosing_only() %>% head()
Finally, we can simulate the original model using this new dataset.
results_f1 <- simulate( model = model_suite$nonmem$advan4_trans4, dataset = ds2, seed = 1 ) shaded_plot(results_f1, "CONC")
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.