Materials for the JSM 2026 Short Course Digital Health Technologies: Data, Methods and Applications with R, CGM module.
Continuous Glucose Monitoring (CGM) devices generate rich, high-frequency data on glucose dynamics. This module walks through a full R analysis pipeline: visualizing raw traces, checking data quality, computing consensus clinical metrics (TIR, CV, GMI, GRI, glycemic episodes), richer visualizations (AGP, lasagna plots), and newer functional/distributional approaches to CGM data ("CGM Data Analysis 2.0").
Don't want to run the code yourself? Read the rendered pages directly:
- CGM Tutorial
- Hall et al. (2018) Data Preparation (companion script, optional)
| File | Description |
|---|---|
cgm.qmd |
Main tutorial. Start here. |
prepare_hall_data.qmd |
Companion data-prep script for Tutorial Parts 5-6. Optional - see below. |
hall_data.Rda |
Pre-processed output of the script above, included so you don't have to re-run it. |
cgm.qmd covers:
- Prerequisites and data format
- CGM data visualization and data quality checks
- CGM metrics: consensus and beyond
- Advanced visualization of CGM data
- Functional data analysis
- Distributional analysis
- Conclusion
- Install R >= 4.5 and RStudio
- Clone or download this repository (see below)
- Open
CGM_short_course.Rprojin RStudio - Install packages:
renv::restore()or, without renv:
# iglu from GitHub, for the latest version (CRAN release can lag)
install.packages("pak")
pak::pak("irinagain/iglu", ask = FALSE)
install.packages(c("dplyr", "ggplot2", "quarto"))
# Needed only for Tutorial Parts 5-6; hall_data.Rda is already included,
# so you do NOT need these to follow along, only if you want to dig into
# the fitted models yourself
install.packages(c("refund", "tidyr", "stringr", "patchwork", "biosensors.usc"))
pak::pak("https://github.com/alexandercoulter/fastfrechet")
pak::pak("IrinaStatsLab/OptiThresholds/optithresholdr")- Render the tutorial:
quarto::quarto_render("cgm.qmd")This is now a Quarto website project (see _quarto.yml), so output goes to _site/cgm.html rather than next to the source file.
hall_data.Rda is already included in this repo, so this step is not required to follow the tutorial. If you'd like to rebuild it from the original source instead:
- Download the three files below into a local
HallFullData/folder (not tracked by git). Source: Hall et al. (2018), PLOS Biology, doi:10.1371/journal.pbio.2005143, CC BY 4.0 licensed. prepare_hall_data.qmdis set toeval: false(it's published as reference-only, since the raw files above aren't hosted in this repo). To actually run it: open it in RStudio and run the chunks interactively, or render with the eval option overridden:This is the slow step - it's why the output is cached inquarto render prepare_hall_data.qmd -M eval:true
hall_data.Rda.
- Browser: Code → Download ZIP (green button on the repo page)
- Command line:
git clone https://github.com/IrinaStatsLab/CGM_short_course.git
Irina Gaynanova, PhD Department of Biostatistics, University of Michigan irinagn@umich.edu