This tutorial describes how to process demographic data using Pro-Demographic module in the system.
EHR
package.This tutorial describes how to use the Pro-Demographic module to process demographic data (see Choi et al.\(^{1}\) for details).
To begin we load the EHR
package and create some directories to work from.
# load EHR package
library(EHR)
td <- tempdir()
checkDir <- file.path(td, 'checks') # directory for interactive checking
dir.create(checkDir)
dataDir <- file.path(td, 'data') # directory for processed data
dir.create(dataDir)
rawDataDir <- system.file("examples", "str_ex2", package="EHR")
drugname <- 'fent'
LLOQ <- 0.05
We will use example demographic data to demonstrate the Pro-Demographic module. The raw data is shown below.
demo.in <- read.csv(system.file("examples", "str_ex2","Demographics_DATA.csv", package="EHR"))[,c(1,2,3,4,5)]
head(demo.in,10)
subject_id subject_uid gender weight height
1 1106.0 34364670 0 5.14 59.18
2 1444.0 36792472 1 5.67 62.90
3 1465.0 36292449 0 23.67 118.02
4 1520.0 34161967 0 14.07 97.04
5 1524.0 37857374 1 23.40 102.80
6 1550.0 37826262 1 6.21 62.03
7 1566.0 35885929 0 101.32 176.26
8 1596.0 38340814 1 6.79 62.99
9 1607.1 38551767 0 10.81 74.95
10 1607.0 38551767 0 2.76 45.94
Each row in the data represents an individual surgical date. In this case, each individual is assigned a unique ID and has a recorded gender, weight, and height for each surgery. The goal of Pro-Demographic is to make the demographic data suitable for merging with medication data for population pharmacokinetic analysis while apply exclusion criteria in a reproducible manner which preserves and organizes the original data.
run_Demo
run_Demo
will configure the demographic data, apply exclusion criteria and saving a record of exclusion rules/excluded individuals. The argument toexclude
takes an expression evaluating to TRUE
/FALSE
indicating which individuals will be excluded from the final dataset.
low_wgt <- function(x, val=1) { x < 6 }
demo.out <- run_Demo(demo.path = file.path(dataDir, "demo.rds"),
demo.columns = list(id = 'subject_id'),
toexclude = expression(low_wgt(weight)))
The number of subjects in the demographic data, who meet the exclusion criteria: 9
The demographic data is now ready for further processing.
head(demo.out)
$demo
subject_id subject_uid gender weight height
1 1106.0 34364670 0 5.14 59.18
2 1444.0 36792472 1 5.67 62.90
3 1465.0 36292449 0 23.67 118.02
4 1520.0 34161967 0 14.07 97.04
5 1524.0 37857374 1 23.40 102.80
6 1550.0 37826262 1 6.21 62.03
7 1566.0 35885929 0 101.32 176.26
8 1596.0 38340814 1 6.79 62.99
9 1607.1 38551767 0 10.81 74.95
10 1607.0 38551767 0 2.76 45.94
11 1724.0 39087607 0 5.21 58.16
12 1770.1 39418554 1 5.44 60.44
13 1770.0 39418554 1 5.38 60.39
14 2157.0 42023523 1 4.20 54.95
15 2162.0 42044808 0 5.00 55.68
16 2164.0 41221120 0 5.80 61.90
17 466.1 28579217 0 21.99 116.90
18 466.0 28579217 0 9.23 77.08
$exclude
[1] 1106.0 1444.0 1607.0 1724.0 1770.1 1770.0 2157.0 2162.0 2164.0
If you see mistakes or want to suggest changes, please create an issue on the source repository.