This tutorial describes how to process drug concentration data using Pro-Drug Level module in the system.
EHR
package.This tutorial describes how to use the Pro-Drug Level module to process drug concentration data (see Choi et al.\(^{1}\) for details).
To begin we load the EHR
package.
Drug level data is an essential part of pharmacokinetic (pk) data. It comprises the dependent variable in the model, the response elicited by medication dosing. It is generally measured as drug concentration in the blood calculated in mass per volume.
We will use example drug level data from the EHR
package. The raw data is shown below.
# read Concentration_DATA_simple.csv
conc.in <- read.csv(system.file("examples", "str_ex1", "Concentration_DATA_simple.csv", package="EHR"),
stringsAsFactors = FALSE)
head(conc.in,10)
patient_id patient_visit_id event conc.level date.time
1 10 10.1 4 0.17 2019-02-02 05:30:00
2 10 10.1 2 4.05 2019-02-24 14:00:00
3 10 10.1 3 0.64 2019-02-25 03:30:00
4 10 10.1 5 0.33 2019-02-27 02:45:00
5 10 10.1 6 0.07 2019-02-28 03:30:00
6 10 10.1 7 0.05 2019-03-01 02:35:00
7 10 10.1 8 0.01 2019-03-02 05:06:00
8 1 1.2 1 0.02 2016-01-07 11:30:00
9 1 1.2 2 2.83 2016-01-08 13:45:00
10 1 1.2 3 0.41 2016-01-09 04:11:00
The goal of Pro-Drug Level is to make this information suitable for merging with medication dosing data for further processing into a complete popPK dataset.
The patient ID and patient visit ID may need to be renamed so that all input datasets have the same names for these variables. See “2. EHR Vignette for Structured Data” of the EHR
package for more information. We demonstrate how to rename these variables using the dataTransformation
function below.
conc.new <- dataTransformation(conc.in,
rename = c('patient_id' = 'mod_id',
'patient_visit_id' = 'mod_id_visit'))
The data must be saved as an RDS file. Below, we show how to save the data in a temporary directory; however, dataDir
can be a specific directory on your computer.
The next section demonstrates how to use the run_DrugLevel
function to run the Pro-Drug Level module.
run_Druglevel
run_Druglevel
will configure the drug level data into a form ready for further processing by modules within the EHR
package. The following arguments are used:
conc.path
: The file path where the drug level data exist. It can be a file (CSV, RData, RDS) or data.frame.conc.columns
: A list mapping columns of the raw concentration file to concentration data. ‘id’ and ‘conc’ are required.conc.select
: The list of variables in the drug level data to be retained.check.path
: Path to a local directory where inconsistencies or possible data errors are saved for expert review.drugname
: Drug of interest.LLOQ
: Lower limit of concentration values. Values below this are invalid.Below we show how we would run run_DrugLevel
using the example drug level data from above. We create a temporary directory for the check files, but checkDir
can be a specific directory on your computer.
dir.create(file.path(td, 'checks'))
checkDir <- file.path(td, 'checks') # directory for interactive checking
drugname <- 'fent'
LLOQ <- 0.05
conc.out <- run_DrugLevel(conc.path=file.path(dataDir,"conc.rds"),
conc.columns = list(id = 'mod_id', idvisit = 'mod_id_visit', conc = 'conc.level', datetime = 'date.time'),
conc.select=c('mod_id','mod_id_visit','event','conc.level','date.time'),
check.path=checkDir,
drugname=drugname,
LLOQ=LLOQ)
no failures, file /var/folders/06/0qv1dr5508j_tbzqdjfqjf680000gn/T//RtmpqLJ9qE/checks/failMissingConcDate-fent.csv not created
0 subjects have multiple sets of concentration data
10 total unique subjects ids (including multiple visits) currently in the concentration data
10 total unique subjects in the concentration data
10 total unique subjects ids (after excluding multiple visits) in the concentration data
10 total unique subjects in the concentration data
In the above code, our drug of interest is fentanyl, so we set drugname
to be fent
, and our lower limit of concentration value (LLOQ
) is 0.05. The message printed out by the function tells us that 0 subjects need to be reviewed.
The concentration data is now ready for expert review or further processing by modules in EHR
.
head(conc.out)
mod_id mod_id_visit event conc.level date.time eid
8 1 1.2 1 0.02 2016-01-07 11:30:00 1
9 1 1.2 2 2.83 2016-01-08 13:45:00 1
10 1 1.2 3 0.41 2016-01-09 04:11:00 1
11 1 1.2 4 0.04 2016-01-11 06:24:00 1
12 1 1.2 5 0.01 2016-01-12 06:45:00 1
13 2 2.1 1 0.78 2015-06-14 15:11:00 1
If you see mistakes or want to suggest changes, please create an issue on the source repository.