Title: | Analysis of Continuous Glucose Monitor Data |
---|---|
Description: | Reads in continuous glucose monitor data of many different formats, calculates a host of glycemic variability metrics, and plots glucose over time. |
Authors: | Evan Olawsky [aut, cre], Yuan Zhang [ctb], Lynn Eberly [ctb] |
Maintainer: | Evan Olawsky <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.5 |
Built: | 2024-12-20 10:59:01 UTC |
Source: | CRAN |
Calculate Average Daily Risk Range (ADRR)
adrr(x, times, unit = "mg", method = "manuscript")
adrr(x, times, unit = "mg", method = "manuscript")
x |
vector of glucose readings |
times |
vector of corresponding times, in minutes |
unit |
"mg" if the units are mg/dL or "mmol" if the units are mmol/L. Null value is "mg". |
method |
"manuscript", "corrected", or "easy". Null value is "manuscript". |
The numeric ADRR value for a given dataset of glucose measurements and times.
adrr(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60), unit="mg", method='manuscript')
adrr(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60), unit="mg", method='manuscript')
Calculate Low / High Blood Glucose Index (LBGI, HBGI)
bgi(x, unit = "mg", method = "manuscript")
bgi(x, unit = "mg", method = "manuscript")
x |
vector of glucose readings |
unit |
"mg" if the units are mg/dL or "mmol" if the units are mmol/L. Null value is "mg". |
method |
"manuscript", "corrected", or "easy". Null value is "manuscript". |
A list containing the LBGI and HBGI values for a given dataset of glucose measurements.
bgi(x=c(rep(100, 10), rep(120, 10), 105, 85), unit='mg', method='manuscript')
bgi(x=c(rep(100, 10), rep(120, 10), 105, 85), unit='mg', method='manuscript')
Calculate area under the curve (AUC)
cgm_auc(x, times, thresh = 100, above = TRUE)
cgm_auc(x, times, thresh = 100, above = TRUE)
x |
vector of glucose readings |
times |
vector of corresponding times, in minutes |
thresh |
threshold above (or below) which you wish to calculate the AUC. Default is 100. |
above |
logical indicating whether you wish to calculate area above the threshold value (TRUE) or below it (FALSE). Default is TRUE. |
The numeric area under the curve value for a given dataset of glucose measurements and times.
cgm_auc(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60), thresh=110, above=TRUE)
cgm_auc(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60), thresh=110, above=TRUE)
Plot glucose values over time
cgm_plot(x, times, unit = "mg")
cgm_plot(x, times, unit = "mg")
x |
vector of glucose readings |
times |
vector of corresponding times, in minutes |
unit |
"mg" if the units are mg/dL or "mmol" if the units are mmol/L. Null value is "mg". |
A plot of glucose values over time.
cgm_plot(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60), unit='mg')
cgm_plot(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60), unit='mg')
Calculate continuous overall net glycemic action (CONGA)
conga(x, times, n = 1, s = 1, method = "manuscript")
conga(x, times, n = 1, s = 1, method = "manuscript")
x |
vector of glucose readings |
times |
vector of corresponding times, in minutes |
n |
number of hours between "partner" observations. Null value is 1. |
s |
number of minutes of slack used when searching for partners. Null value is 1. |
method |
"manuscript" or "easy". Null value is "manuscript". |
The numeric CONGA value for a given dataset of glucose measurements and times.
conga(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60), n=1, s=1, method="manuscript")
conga(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60), n=1, s=1, method="manuscript")
Calculate coefficient of variation (CV)
cv(x, times, overall = TRUE, interval = 1)
cv(x, times, overall = TRUE, interval = 1)
x |
vector of glucose readings |
times |
vector of corresponding times, in minutes |
overall |
a logical, equal to TRUE you want the CV for the entire dataset, or equal to FALSE if you would prefer many CV values over a moving window |
interval |
size (in hours) of the moving window to be used if overall is false. Null value is 1. |
Either a numeric coefficient of variation over the entire dataset or a vector of CV values over windows of the data.
cv(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60), overall=TRUE)
cv(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60), overall=TRUE)
Plots glucose changes over time
diff_plot(x, times, n = 1, s = 1, unit = "mg")
diff_plot(x, times, n = 1, s = 1, unit = "mg")
x |
vector of glucose readings |
times |
vector of corresponding times, in minutes |
n |
number of hours between "partner" observations. Null value is 1. |
s |
number of minutes of slack used when searching for partners. Null value is 1. |
unit |
"mg" if the units are mg/dL or "mmol" if the units are mmol/L. Null value is "mg". |
A plot of n-hour glucose differences over time.
diff_plot(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60), n=1, s=1, unit='mg')
diff_plot(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60), n=1, s=1, unit='mg')
Calculate distance travelled
dist_travelled(x)
dist_travelled(x)
x |
vector of glucose readings |
The numeric distance travelled value for a given dataset of glucose measurements.
dist_travelled(x=c(rep(100, 10), rep(120, 10), 105, 85))
dist_travelled(x=c(rep(100, 10), rep(120, 10), 105, 85))
Calculate Glucose Management Indicator (GMI)
gmi(x, unit = "mg")
gmi(x, unit = "mg")
x |
vector of glucose readings |
unit |
"mg" if the units are mg/dL or "mmol" if the units are mmol/L. Null value is "mg". |
The numeric GMI value for a given dataset of glucose measurements.
gmi(x=c(rep(100, 10), rep(120, 10), 105, 85), unit='mg')
gmi(x=c(rep(100, 10), rep(120, 10), 105, 85), unit='mg')
Calculate Glycemic Risk Assessment Diabetes Equation (GRADE)
grade( x, unit = "mg", method = "manuscript", c1 = ifelse(unit == "mg", 70.2, 3.9), c2 = ifelse(unit == "mg", 140.4, 7.8) )
grade( x, unit = "mg", method = "manuscript", c1 = ifelse(unit == "mg", 70.2, 3.9), c2 = ifelse(unit == "mg", 140.4, 7.8) )
x |
vector of glucose readings |
unit |
"mg" if the units are mg/dL or "mmol" if the units are mmol/L. Null value is "mg". |
method |
"manuscript" or "easy". Null value is "manuscript". |
c1 |
glucose value below which readings are considered hypoglycemic. Default is 70.2 mg/dL. |
c2 |
glucose value above which readings are considered hyperglycemic. Default is 140.4 mg/dL. |
A list containing the GRADE value and the percentage of the GRADE value due to euglycemia, hypoglycemia, and hyperglycemia for a given dataset of glucose measurements
grade(x=c(rep(100, 10), rep(120, 10), 105, 85), unit='mg', method='manuscript', c1=70.2, c2=140.4)
grade(x=c(rep(100, 10), rep(120, 10), 105, 85), unit='mg', method='manuscript', c1=70.2, c2=140.4)
Calculate all glycemic variability metrics
GV( x, times, unit = "mg", m_index = 120, k = 60, s = 1, conga_n = 1, interval = 1, thresh = 100, event_thresh = 55 )
GV( x, times, unit = "mg", m_index = 120, k = 60, s = 1, conga_n = 1, interval = 1, thresh = 100, event_thresh = 55 )
x |
vector of glucose readings |
times |
vector of corresponding times, in minutes |
unit |
"mg" if the units are mg/dL or "mmol" if the units are mmol/L. Null value is "mg". |
m_index |
a value to be considered a 'standard' blood glucose value for calculation of M-value, in mg/dL. Null value is 120. |
k |
length of time (in minutes) used to find partners. Null value is 60. |
s |
number of minutes of slack used when searching for partners. Null value is 1. |
conga_n |
number of hours between "partner" observations. Null value is 1. |
interval |
size (in hours) of the moving window to be used if overall is false. Null value is 1. |
thresh |
threshold above (or below) which you wish to calculate the AUC. Default is 100. |
event_thresh |
glucoses below this threshold are considered as part of an episode. Default is 55 |
A data frame containing the entire suite of rGV metrics for the given dataset.
GV(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60), unit='mg', m_index=120, k=60, s=1, conga_n=1, interval=1, thresh=100, event_thresh=55)
GV(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60), unit='mg', m_index=120, k=60, s=1, conga_n=1, interval=1, thresh=100, event_thresh=55)
Calculate Glycemic Variability Percentage (GVP)
gvp(x, times)
gvp(x, times)
x |
vector of glucose readings |
times |
vector of corresponding times, in minutes |
The numeric GVP value for a given dataset of glucose measurements and times.
gvp(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60))
gvp(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60))
Calculate J-index
j_index(x, unit = "mg")
j_index(x, unit = "mg")
x |
vector of glucose readings |
unit |
"mg" if the units are mg/dL or "mmol" if the units are mmol/L. Null value is "mg". |
The numeric J-index value for a given dataset of glucose measurements.
j_index(x=c(rep(100, 10), rep(120, 10), 105, 85), unit='mg')
j_index(x=c(rep(100, 10), rep(120, 10), 105, 85), unit='mg')
Calculate the lability index (LI)
li(x, times, k = 60, s = 1)
li(x, times, k = 60, s = 1)
x |
vector of glucose readings |
times |
vector of corresponding times, in minutes |
k |
length of time (in minutes) used to find partners. Null value is 60. |
s |
number of minutes of slack used when searching for partners. Null value is 1. |
The numeric value of the lability index for a given dataset of glucose measurements and times.
li(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60), k=60, s=1)
li(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60), k=60, s=1)
Calculate M-value
m_value(x, unit = "mg", index = 120, method = "manuscript")
m_value(x, unit = "mg", index = 120, method = "manuscript")
x |
vector of glucose readings |
unit |
"mg" if the units are mg/dL or "mmol" if the units are mmol/L. Null value is "mg". |
index |
value to be considered a 'standard' blood glucose value, in mg/dL. Null value is 120. |
method |
"manuscript", "corrected", or "easy". Null value is "manuscript". |
The numeric M-value for a given dataset of glucose measurements.
m_value(x=c(rep(100, 10), rep(120, 10), 105, 85), unit='mg', index=120, method='manuscript')
m_value(x=c(rep(100, 10), rep(120, 10), 105, 85), unit='mg', index=120, method='manuscript')
Calculate Mean Absolute Glucose (MAG)
mag(x, times)
mag(x, times)
x |
vector of glucose readings |
times |
vector of corresponding times, in minutes |
The numeric MAG value for a given dataset of glucose measurements and times.
mag(x=c(rep(100, 10),rep(120, 10), 105, 85), times=seq(0, 1260, 60))
mag(x=c(rep(100, 10),rep(120, 10), 105, 85), times=seq(0, 1260, 60))
Calculate Mean Amplitude of Glycemic Excursions (MAGE)
mage(x, times)
mage(x, times)
x |
vector of glucose readings |
times |
vector of corresponding times, in minutes |
The numeric MAGE value for a given dataset of glucose measurements and times.
mage(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60))
mage(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60))
Calculate Mean of Daily Differences (MODD)
modd(x, times, s = 1, method = "manuscript")
modd(x, times, s = 1, method = "manuscript")
x |
vector of glucose readings |
times |
vector of corresponding times, in minutes |
s |
number of minutes of slack used when searching for partners. Null value is 1. |
method |
"manuscript" or "easy". Null value is "manuscript". |
The numeric MODD value for a given dataset of glucose measurements and times.
modd(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60), s=1, method='manuscript')
modd(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60), s=1, method='manuscript')
Find number of episodes below a given glucose value for a given amount of time
num_events(x, times, thresh = 55, len = 15, gap = 5)
num_events(x, times, thresh = 55, len = 15, gap = 5)
x |
vector of glucose readings |
times |
vector of corresponding times, in minutes |
thresh |
glucoses below this threshold are considered as part of an episode. Default is 55 |
len |
minimum length of an episode. Default is 15 |
gap |
typical gap between CGM measurements, in minutes. Default is 5 |
The integer number of events for a given dataset of glucose measurements and times.
num_events(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60), thresh=55, len=15, gap=5)
num_events(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60), thresh=55, len=15, gap=5)
Read in continuous glucose monitor data
read_cgm( file, timezero = "first", na.rm = TRUE, skip = 0, calib_col = NA, calib_tag, mult_sensors = FALSE, sensor_times = NA, sensor_gap = 120, time_col, gluc_col, time_sep = " ", time_format = c(dates = "m/d/y", times = "h:m:s"), high_ind = "High", high_value = 400, low_ind = "Low", low_value = 40 )
read_cgm( file, timezero = "first", na.rm = TRUE, skip = 0, calib_col = NA, calib_tag, mult_sensors = FALSE, sensor_times = NA, sensor_gap = 120, time_col, gluc_col, time_sep = " ", time_format = c(dates = "m/d/y", times = "h:m:s"), high_ind = "High", high_value = 400, low_ind = "Low", low_value = 40 )
file |
name of the CSV file to be read in |
timezero |
set to "first" if the first glucose reading should be considered time zero and set to "midnight" if midnight of the day of the first reading should be considered time zero. Default is "first". |
na.rm |
a logical that is TRUE if you wish to exclude all readings that are missing glucose values or time stamps and FALSE if not. Default is TRUE. |
skip |
the number of lines in the data file to skip before beginning to read in data |
calib_col |
the number or name of the column containing information regarding calibration status of each glucose entry |
calib_tag |
the character value used to denote calibration rows in calib_col |
mult_sensors |
a logical that is TRUE if you wish to split the data set into parts corresponding to different CGM sensors and FALSE if not. Default is FALSE. |
sensor_times |
a vector of times (in the same format as the time data) that correspond to the beginning of a new CGM sensor. These times are used to split the data between multiple sensors if mult_sensors is TRUE. If sensor_times is NA, the data is split automatically at every gap of sensor_gap or more minutes. |
sensor_gap |
a number specifying the minimum gap (in minutes) for which we should split the data into two pieces. Default is 120. |
time_col |
the number or name of the column containing time data |
gluc_col |
the number or name of the column containing glucose data |
time_sep |
character that separates date from time in your time data |
time_format |
specify date and time formats according to the specification used in the chron package. Default is c(dates = "m/d/y", times = "h:m:s"). |
high_ind |
character value that identifies high glucose values in the data. Default is "High". |
high_value |
numeric value by which to replace glucose values equal to "high_ind". Default is 400. |
low_ind |
character value that identifies low glucose values in the data. Default is "Low". |
low_value |
numeric value by which to replace glucose values equal to "low_ind". Default is 40. |
A data frame with two columns: glucose values and time. This data frame can then be used with other rGV functions to calculate CGM metrics.
Calculate standard deviation (SD)
st_dev(x, times, overall = TRUE, interval = 1)
st_dev(x, times, overall = TRUE, interval = 1)
x |
vector of glucose readings |
times |
vector of corresponding times, in minutes |
overall |
a logical, equal to TRUE you want the CV for the entire dataset, or equal to FALSE if you would prefer many CV values over a moving window |
interval |
size (in hours) of the moving window to be used if overall is false. Null value is 1. |
Either a numeric standard deviation over the entire dataset or a vector of SD values over windows of the data.
st_dev(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60), overall=TRUE)
st_dev(x=c(rep(100, 10), rep(120, 10), 105, 85), times=seq(0, 1260, 60), overall=TRUE)
Plot the symmetrized glucose values
symm_plot(x, times, unit = "mg")
symm_plot(x, times, unit = "mg")
x |
vector of glucose readings |
times |
vector of corresponding times, in minutes |
unit |
"mg" if the units are mg/dL or "mmol" if the units are mmol/L. Null value is "mg". |
A plot of symmetrized glucose values over time. These symmetrized values are used in the calculation of BGI and ADRR.
symm_plot(x=c(rep(100, 10),rep(120, 10), 105, 85), times=seq(0, 1260, 60), unit='mg')
symm_plot(x=c(rep(100, 10),rep(120, 10), 105, 85), times=seq(0, 1260, 60), unit='mg')
Calculate amount of time that the CGM was active
time_on(times, gap = 5)
time_on(times, gap = 5)
times |
vector of corresponding times, in minutes |
gap |
typical gap between CGM measurements, in minutes. Default is 5 |
The numeric amount of time that the CGM device was active in a given dataset.
time_on(times=seq(0, 1260, 60), gap=5)
time_on(times=seq(0, 1260, 60), gap=5)
Calculate time in range (TIR)
tir(x, low = 70, high = 180)
tir(x, low = 70, high = 180)
x |
vector of glucose readings |
low |
lower bound of the range. Default is 70 |
high |
upper bound of the range. Default is 180 |
The numeric time in range value for a given dataset of glucose measurements and times.
tir(x=c(rep(100, 10), rep(120, 10), 105, 85), low=70, high=80)
tir(x=c(rep(100, 10), rep(120, 10), 105, 85), low=70, high=80)