Pro-Drug Level

This tutorial describes how to process drug concentration data using Pro-Drug Level module in the system.

Michael L. Williams

Introduction

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.

# load EHR package
library(EHR)

Drug Level Data

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'))

Preparing the Drug Level Data

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.

td <- tempdir()
dir.create(file.path(td, 'data'))
dataDir <- file.path(td, 'data') # directory for processed data
saveRDS(conc.new, file=file.path(dataDir,"conc.rds"))

The next section demonstrates how to use the run_DrugLevel function to run the Pro-Drug Level module.

Running 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:

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.

Processed Data

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

References

  1. Choi L, Beck C, McNeer E, Weeks HL, Williams ML, James NT, Niu X, Abou-Khalil BW, Birdwell KA, Roden DM, Stein CM. Development of a System for Post-marketing Population Pharmacokinetic and Pharmacodynamic Studies using Real-World Data from Electronic Health Records. Clinical Pharmacology & Therapeutics. 2020 Apr;107(4):934-43. doi: 10.1002/cpt.1787.

Corrections

If you see mistakes or want to suggest changes, please create an issue on the source repository.