create_doses_from_file: Create a csv file of dosing rows for XML files using a study...

View source: R/create_doses_from_file.R

create_doses_from_fileR Documentation

Create a csv file of dosing rows for XML files using a study file to get subject information

Description

create_doses_from_file uses an Excel or csv file with subject information to generate a data.frame of dosing times and amounts – one for every subject – based on the dosing regimen specified. WARNING: This doesn't work when there are spaces in the column names in the study file! (I'm looking into whether there's a way around that. -LSh) This is meant for generating XML files for use in Phoenix WNL.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.) 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_from_file(
  study_file,
  dose_interval = 24,
  num_doses = NA,
  end_time = NA,
  custom_dosing_schedule = NA,
  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_column,
  subj_age_column,
  subj_weight_column,
  subj_height_column,
  subj_sex_column,
  save_output = NA
)

Arguments

study_file

optionally specify a file containing study information. This will be used for determining subject IDs, ages, weights, heights, and sexes for the subjects who will be dosed.

dose_interval

the dosing interval in hours. Default is 24 for a QD dosing regimen.

num_doses

the number of doses to generate. If this is left as NA, then the value for end_time will be used to determine the number of doses administered.

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.

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_column

the name of the column in study_file that contains subject IDs, unquoted

subj_age_column

the name of the column in study_file that contains the subject age (years), unquoted (optional)

subj_weight_column

the name of the column in study_file that contains the subject weight (kg), unquoted (optional)

subj_height_column

the name of the column in study_file that contains the subject height (cm), unquoted (optional)

subj_sex_column

the name of the column in study_file that contains the subject sex, unquoted; 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_dose_rows_from_file(study_file = "My dose info.csv",
                           dose_interval = 24, num_doses = 4,
                           subj_ID_column = Subject)


# 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 \code{create_doses_from_file} 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 \emph{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(study_file = "Subject metadata.csv",
                          subj_ID_column = SubjectID,
                          subj_age_column = Age,
                          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(study_file = "Subject metadata.csv",
                            subj_ID_column = SubjectID,
                            subj_age_column = Age,
                            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)

# Please see more examples with the function "create_doses".

                  

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