Title: | Creates Pharmacokinetic/Pharmacodynamic (PK/PD) Data |
---|---|
Description: | Prepare pharmacokinetic/pharmacodynamic (PK/PD) data for PK/PD analyses. This package provides functions to standardize infusion and bolus dose raw data obtained from electronic health record (EHR) databases while linking it to drug level or concentration data. |
Authors: | Cole Beck [aut, cre] |
Maintainer: | Cole Beck <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.1.2 |
Built: | 2025-03-04 03:00:57 UTC |
Source: | https://github.com/couthcommander/pkdata |
This package will prepare data sets for PK data analysis.
Cole Beck, Leena Choi
Maintainer: Cole Beck [email protected]
Modify dose data such that it conforms for future use.
conformDoses( doseData, idVar = "id", dateVar = "date.dose", infusionDoseTimeVar = NULL, infusionDoseVar = NULL, bolusDoseTimeVar = NULL, bolusDoseVar = NULL, otherDoseTimeVar = NULL, otherDoseVar = NULL, otherVars = NULL )
conformDoses( doseData, idVar = "id", dateVar = "date.dose", infusionDoseTimeVar = NULL, infusionDoseVar = NULL, bolusDoseTimeVar = NULL, bolusDoseVar = NULL, otherDoseTimeVar = NULL, otherDoseVar = NULL, otherVars = NULL )
doseData |
data.frame; data set with dose information |
idVar |
character string; name of ID variable, defaults to id |
dateVar |
character string; name of date variable, defaults to date.dose |
infusionDoseTimeVar |
character string; name of infusion dose time variable |
infusionDoseVar |
character string; name of infusion dose variable |
bolusDoseTimeVar |
character string; name of bolus dose time variable |
bolusDoseVar |
character string; name of bolus dose variable |
otherDoseTimeVar |
character string; name of additional dose time variable |
otherDoseVar |
character string; name of additional dose variable |
otherVars |
character string; name of other variables within data set |
Date-time variables are given a consistent format. Invalid records are removed. The data set is sorted by date.
data.frame, containing dose data
Cole Beck
Modify dose data to remove duplicate dose values.
fixDuplicates( data, idVar = "id", infusionDoseTimeVar = NULL, infusionDoseVar = NULL, moveBolus = FALSE, bolusDoseTimeVar = NULL, bolusDoseVar = NULL )
fixDuplicates( data, idVar = "id", infusionDoseTimeVar = NULL, infusionDoseVar = NULL, moveBolus = FALSE, bolusDoseTimeVar = NULL, bolusDoseVar = NULL )
data |
data.frame; data set with dose information |
idVar |
character string; name of ID variable, defaults to id |
infusionDoseTimeVar |
character string; name of infusion dose time variable |
infusionDoseVar |
character string; name of infusion dose variable |
moveBolus |
logical; allow duplicate infusion doses to be categorized as bolus |
bolusDoseTimeVar |
character string; name of bolus dose time variable |
bolusDoseVar |
character string; name of bolus dose variable |
Some duplicates can be adjusted by changing the date-time rounding. Others may be converted from one dose type to another, such as moving infusion to bolus.
data.frame, containing dose data
Cole Beck
Given a vector of dates or date-times, determine the format if one is used
consistently. If inconsistentencies are found, the function will fail.
See strptime
for examples of format specifications.
guessDateFormat(x)
guessDateFormat(x)
x |
character vector of dates or date-times |
guessDateFormat
is rigid when determining the date format. For
date-times it expects the date and time parts to be separated by a space. It
does not recognize all format specifications, such as the AM/PM indicator.
The time part should have at least one colon to separate hours from minutes.
The date part may have any separator as non-numerical values are removed
before parsing.
Returns a character string representing the format of the date-time variables.
Cole Beck
x <- c("2014-01-15", "20140202") guessDateFormat(x)
x <- c("2014-01-15", "20140202") guessDateFormat(x)
Use last-observation-carried-forward to impute missing dose values by hour.
imputeDoses( data, idVar = "id", dateVar = "date.dose", infusionDoseTimeVar = NULL, infusionDoseVar = NULL, maxskips = 3 )
imputeDoses( data, idVar = "id", dateVar = "date.dose", infusionDoseTimeVar = NULL, infusionDoseVar = NULL, maxskips = 3 )
data |
data.frame; data set with dose information |
idVar |
character string; name of ID variable, defaults to id |
dateVar |
character string; name of date variable, defaults to date.dose |
infusionDoseTimeVar |
character string; name of infusion dose time variable |
infusionDoseVar |
character string; name of infusion dose variable |
maxskips |
integer; maximum number of missed doses that may be imputed |
Creates skips column
data.frame, containing dose data
Cole Beck
Given a vector of dates or date-times, create Date or POSIXct variables.
parse_dates(x, tz = getOption("pkdata.tz", ""))
parse_dates(x, tz = getOption("pkdata.tz", ""))
x |
character vector of dates or date-times |
tz |
character string; specifies the time zone to be used for the conversion. Defaults to the current time zone. |
parse_dates
calls parse_date_time
from the
lubridate package. While parse_date_time
accepts
multiple date formats, parse_dates
requires a consistent format.
vector of Date or POSIXct objects
Cole Beck
x <- c("2014-01-15", "20140202") parse_dates(x) x <- c("2014-01-15 01:51", "20140202 04:35:18") parse_dates(x)
x <- c("2014-01-15", "20140202") parse_dates(x) x <- c("2014-01-15 01:51", "20140202 04:35:18") parse_dates(x)
Create a dose data set with conforming data, and remove invalid records.
prepareDoses( doseData, drugLevelData, drugLevelID = "id", drugLevelTimeVar = "date.time", drugLevelVar = "fent.level", idVar = "id", dateVar = "date.dose", infusionDoseTimeVar = NULL, infusionDoseVar = NULL, bolusDoseTimeVar = NULL, bolusDoseVar = NULL, otherDoseTimeVar = NULL, otherDoseVar = NULL, otherVars = NULL, lookForward = 7 )
prepareDoses( doseData, drugLevelData, drugLevelID = "id", drugLevelTimeVar = "date.time", drugLevelVar = "fent.level", idVar = "id", dateVar = "date.dose", infusionDoseTimeVar = NULL, infusionDoseVar = NULL, bolusDoseTimeVar = NULL, bolusDoseVar = NULL, otherDoseTimeVar = NULL, otherDoseVar = NULL, otherVars = NULL, lookForward = 7 )
doseData |
data.frame; data set with dose information |
drugLevelData |
data.frame; data set with drug level data |
drugLevelID |
character string; name of ID variable, defaults to id |
drugLevelTimeVar |
character string; name of date-time variable, defaults to date.time |
drugLevelVar |
character string; name of drug level variable, defaults to fent.level |
idVar |
character string; name of ID variable, defaults to id |
dateVar |
character string; name of date variable, defaults to date.dose |
infusionDoseTimeVar |
character string; name of infusion dose time variable |
infusionDoseVar |
character string; name of infusion dose variable |
bolusDoseTimeVar |
character string; name of bolus dose time variable |
bolusDoseVar |
character string; name of bolus dose variable |
otherDoseTimeVar |
character string; name of additional dose time variable |
otherDoseVar |
character string; name of additional dose variable |
otherVars |
character string; name of other variables within data set |
lookForward |
integer; initializes the time frame window with the number of days prior to the first drug level data; defaults to 7 |
Wrapper function for conformDoses
and trimDoses
.
data.frame, containing dose data
Cole Beck
options(pkdata.tz='America/Chicago') dose.file <- read.csv(system.file('extdata', 'dosage.csv', package = 'pkdata'), stringsAsFactors = FALSE) drug.level.file <- read.csv(system.file('extdata', 'druglevel.csv', package = 'pkdata'), stringsAsFactors = FALSE) prepped <- prepareDoses(dose.file, drug.level.file, infusionDoseTimeVar='inf.time', infusionDoseVar='inf.dose', bolusDoseTimeVar='bol.time', bolusDoseVar='bol.dose', otherDoseTimeVar='patch.time', otherDoseVar='patch.dose', otherVars=c('gender','weight'))
options(pkdata.tz='America/Chicago') dose.file <- read.csv(system.file('extdata', 'dosage.csv', package = 'pkdata'), stringsAsFactors = FALSE) drug.level.file <- read.csv(system.file('extdata', 'druglevel.csv', package = 'pkdata'), stringsAsFactors = FALSE) prepped <- prepareDoses(dose.file, drug.level.file, infusionDoseTimeVar='inf.time', infusionDoseVar='inf.dose', bolusDoseTimeVar='bol.time', bolusDoseVar='bol.dose', otherDoseTimeVar='patch.time', otherDoseVar='patch.dose', otherVars=c('gender','weight'))
Helper function to sort dose data set by ID and time variables.
sortDoses( data, idVar = "id", infusionDoseTimeVar = NULL, bolusDoseTimeVar = NULL, otherDoseTimeVar = NULL )
sortDoses( data, idVar = "id", infusionDoseTimeVar = NULL, bolusDoseTimeVar = NULL, otherDoseTimeVar = NULL )
data |
data.frame; data set with dose information |
idVar |
character string; name of ID variable, defaults to id |
infusionDoseTimeVar |
character string; name of infusion dose time variable |
bolusDoseTimeVar |
character string; name of bolus dose time variable |
otherDoseTimeVar |
character string; name of additional dose time variable |
Sort order will be the ID variable, then infusion time, bolus time, or other dose date-time variables.
data.frame, containing dose data
Cole Beck
Remove invalid doses by creating a time frame window constructed from drug level data.
trimDoses( doseData, drugLevelData, drugLevelID = "id", drugLevelTimeVar = "date.time", drugLevelVar = "fent.level", infusionDoseTimeVar = NULL, infusionDoseVar = NULL, bolusDoseTimeVar = NULL, bolusDoseVar = NULL, otherDoseTimeVar = NULL, otherDoseVar = NULL, lookForward = 7, last = NA )
trimDoses( doseData, drugLevelData, drugLevelID = "id", drugLevelTimeVar = "date.time", drugLevelVar = "fent.level", infusionDoseTimeVar = NULL, infusionDoseVar = NULL, bolusDoseTimeVar = NULL, bolusDoseVar = NULL, otherDoseTimeVar = NULL, otherDoseVar = NULL, lookForward = 7, last = NA )
doseData |
data.frame; data set with dose information |
drugLevelData |
data.frame; data set with drug level data |
drugLevelID |
character string; name of ID variable, defaults to id |
drugLevelTimeVar |
character string; name of date-time variable, defaults to date.time |
drugLevelVar |
character string; name of drug level variable, defaults to fent.level |
infusionDoseTimeVar |
character string; name of infusion dose time variable |
infusionDoseVar |
character string; name of infusion dose variable |
bolusDoseTimeVar |
character string; name of bolus dose time variable |
bolusDoseVar |
character string; name of bolus dose variable |
otherDoseTimeVar |
character string; name of additional dose time variable |
otherDoseVar |
character string; name of additional dose variable |
lookForward |
integer; initializes the time frame window with the number of days prior to the first drug level data; defaults to 7 |
last |
integer; sets the end of the time frame window to be "last" days after the first dose date, rather than the date of the last drug level data |
The time frame window is generally seven days before drug level data up through the last drug level data record. The window can be adjusted by setting the lookForward and last arguments.
data.frame, containing trimmed dose data
Cole Beck