create_doses: Create a csv file of dosing rows for XML files

View source: R/create_doses.R

create_dosesR Documentation

Create a csv file of dosing rows for XML files

Description

create_doses generates a data.frame of dosing times and amounts – one for every subject if subject IDs are provided – based on the dosing regimen specified. This is meant for generating XML files for use as observed data overlays for the Simcyp Simulator. Special notes for when you have more than one value for some items: If you have multiple values for anything having to do with the compound – the compound ID, administration route, dose unit, or dose amount (all have the prefix "compound_") – then all the other arguments having to do with compounds must have that same number of values or must have only one value, which will be repeated as needed. Really, this function will just be easier to use if you run it once for each compound you want. (See the examples at the bottom of the help file.) Similarly, if you have multiple values for anything having to do with the subject – the subject ID, age, weight, height, or sex (all have the prefix "subj_") – then all the other arguments having to do with subjects must have that same number of values or must have only one value, which will be repeated as needed. Any time you need to specify multiple values, you can make use of the R function rep to repeat elements of a vector. (See the R coding tip for the argument compound_dose_amount for an example.)

Usage

create_doses(
  dose_interval = NA,
  num_doses = NA,
  end_time = NA,
  custom_dosing_schedule = NA,
  simulator_version = 22,
  compoundID = "Substrate",
  compound_dosing_start_time = 0,
  compound_dose_route = "Oral",
  compound_dose_unit = "mg",
  compound_dose_amount = 100,
  compound_inf_duration = NA,
  subj_ID = NA,
  subj_age = NA,
  subj_weight = NA,
  subj_height = NA,
  subj_sex = NA,
  save_output = NA
)

Arguments

dose_interval

the dosing interval in hours. Default is NA for a single dose. Set this to, e.g., 24 for a QD dosing regimen.

num_doses

the number of doses to generate. If this is left as NA and you have specified the dose interval, then the value for end_time will be used to determine the number of doses administered. If this is NA and so is dose_interval, we'll assume you want a single dose.

end_time

the end time of the dosing in hours. If num_doses is filled out, that value will be used preferentially.

custom_dosing_schedule

a custom dosing schedule to be used for each subject in hours, e.g., custom_dosing_schedule = c(0, 12, 24, 168, 180, 192); if this is filled out, values in dose_interval, num_doses, and end_time will all be ignored.

simulator_version

the version of the simulator that will be used. This affects what columns will be included in hte output.

compoundID

specify the compound that's being dosed. Options are "Substrate" (default), "Inhibitor 1", "Inhibitor 2", or "Inhibitor 3". Not case sensitive. If you list more than one compound, you must also list more than one compound_dose_route, compound_dose_unit, and compound_dose_amount or list just one of each with the understanding that they will all be the same.

compound_dosing_start_time

the start time of compound administration (h); default is 0.

compound_dose_route

the route of administration. Options are "Oral" (default), "Intravenous", "Dermal", "Inhaled", "SC-First Order", "SC-Mechanistic", or "Auto-detect". Not case sensitive.

compound_dose_unit

the unit of dosing. Options are "mg" (default), "mg/m2", or "mg/kg".

compound_dose_amount

the amount of the dose. If this amount varies, please include one dose amount for each time. For example: compound_dose_amount = c(100, 50, 50) will generate doses of 100 mg for the first dose and then 50 mg for the next two doses. An R coding tip: You don't have to list everything multiple times; you can use the function rep to repeat elements. For example, here's how you could specify that the 1st dose should be 100 mg but the next 10 doses should be 50: compound_dose_amount = c(100, rep(50, 10))

compound_inf_duration

the infusion duration (min) (optional)

subj_ID

optionally specify subject IDs as, e.g., subj_ID = c("101-001", "101-002", "101-003").

subj_age

age (years) (optional)

subj_weight

weight (kg) (optional)

subj_height

height (cm) (optional)

subj_sex

sex; options are "F" or "M" (optional)

save_output

the file name to use for saving the output as a csv; if left as NA, this will generate a data.frame in R but no output will be saved.

Value

a data.frame

Examples


# QD dosing regimen of 100 mg
create_doses(dose_interval = 24, num_doses = 4)

# QD dosing regimen of 100 mg for subjects A, B, and C
create_doses(dose_interval = 24, num_doses = 4,
                 subj_ID = c("A", "B", "C"))

# QD dosing regimen of 100 mg for subjects A, B, and C and save output
create_doses(dose_interval = 24, num_doses = 4,
             subj_ID = c("A", "B", "C"),
             save_output = "My doses.csv")

# Custom dosing regimen for subjects A, B, and C
create_doses(custom_dosing_schedule = c(0, 12, 24, 48, 92, 168),
             subj_ID = c("A", "B", "C"))


# If you have multiple compounds -- say you've got a DDI study with both a
# substrate and a perpetrator -- this will probably be easiest to manage if you
# run create_doses once for each compound. It just gets pretty
# complicated pretty quickly to have a substrate with one dosing interval,
# start time, and amount and then an inhibitor with a *different* dosing
# interval, start time, and amount. Here's an example of how you could do this
# but still get just one csv file at the end:

# Substrate is dosed one time at 10 mg starting at t = 168 h.
Doses_sub <- create_doses(num_doses = 1, compoundID = "Substrate",
                          compound_dosing_start_time = 168,
                          compound_dose_amount = 10)

# Inhibitor is dosed QD at 500 mg for 336 h starting at t = 0 h.
Doses_inhib <- create_doses(dose_interval = 24, end_time = 336,
                            compoundID = "Inhibitor 1",
                            compound_dosing_start_time = 0,
                            compound_dose_amount = 500)

MyDoses <- bind_rows(Doses_sub, Doses_inhib)
write.csv(MyDoses, file = "Dose rows for sub and inhib.csv",
          row.names = FALSE)

                  

shirewoman2/Consultancy documentation built on Feb. 18, 2025, 10 p.m.