Skip to contents

Converts a list of structured dosing scenarios into an event data frame that can be used as the events argument for running PBK model simulations using ode.

Usage

create_desolve_events(
  model,
  dosing_events,
  time_unit = "h",
  amount_unit = "ug"
)

Arguments

model

An object of class sbmlModel for which the dosing events should be created.

dosing_events

A list of dosing scenarios, where each element is a named list following a fixed structure. Each scenario is described by a scenario type describing the type of the dosing pattern (single vs. repeated and bolus vs. continuous) and a target. Furthermore, all scenarios must have a time and an amount, and may include the an interval, a duration, and an until specification, depending on the dosing type.

time_unit

An optional character string describing the time unit of the specified dosing_events. Event timings are aligned with the time unit of the model. Current options are "h" for hours (default), "d" for days, or "model" when assuming the timings of the specified events are already aligned with the time unit of the model.

amount_unit

An optional character string describing the amount unit of the specified dosing_events. Amounts of the dosing events are aligned with the amount unit of the model. Current options are "ng", "ug" (default), "mg", or "model" (assuming the timings of the specified events are already aligned with the time unit of the model).

Value

A data.frame formatted for use as the events argument in deSolve::ode(), with columns:

var

Name of the state variable to which the dose applies (e.g., "A_compartment").

time

Numeric time of the event (in hours).

value

Amount added to the state variable.

method

Typically "add" for bolus or "rate" for continuous infusion.

Details

This function interprets each dosing scenario (specified as a named list) based on its type (e.g., bolus vs. continuous, single vs. repeated) and generates corresponding time-stamped events for use in PBK or PK simulations.

Recognized type values:

  • "single_bolus" – single dose at time.

  • "repeated_bolus" – repeated bolus doses between time and until at interval interval.

  • "single_continuous" – continuous infusion from time to time + duration.

  • "repeated_continuous" – multiple infusions each lasting duration, repeating every interval until until.

The target compartment/state variable for each dose is assumed to be specified in a field like target or by default as "A_Gut" if unspecified.

See also

Examples

model_file <- system.file("extdata/", "simple_oral.sbml", package = "sbmlpbk")
model <- load_sbml(model_file)
dosing_events <- list(
  list(target = "AGut", dose_type = "single_bolus", amount = 100, time = 0),
  list(
    target = "AGut",
    dose_type = "repeated_bolus",
    amount = 50,
    time = 12,
    interval = 24,
    until = 96
  ),
  list(
    target = "AAir",
    dose_type = "single_continuous",
    amount = 20,
    time = 0,
    duration = 24
  ),
  list(
    target = "AAir",
    dose_type = "repeated_continuous",
    amount = 20,
    time = 56,
    duration = 12,
    interval = 24,
    until = 96
  )
)

events <- create_desolve_events(model, dosing_events)
head(events)
#>    var time value  method
#> 1 AGut    0   100     add
#> 2 AAir    0    20 replace
#> 3 AGut   12    50     add
#> 4 AAir   24     0 replace
#> 5 AGut   36    50     add
#> 6 AAir   56    20 replace