Skip to content

Repository files navigation

CGM Short Course

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").

Rendered tutorial

Don't want to run the code yourself? Read the rendered pages directly:

Contents

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:

  1. Prerequisites and data format
  2. CGM data visualization and data quality checks
  3. CGM metrics: consensus and beyond
  4. Advanced visualization of CGM data
  5. Functional data analysis
  6. Distributional analysis
  7. Conclusion

Before the course

  1. Install R >= 4.5 and RStudio
  2. Clone or download this repository (see below)
  3. Open CGM_short_course.Rproj in RStudio
  4. 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")
  1. 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.

Reproducing the Hall et al. (2018) data prep (optional)

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:

  1. 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.
    • S1 Data (raw CGM, all 57 subjects) → save as HallFullData/pbio.2005143.s010
    • S5 Data (clinical/glucotype variables) → save as HallFullData/pbio.2005143.s014.db
    • S6 Data (glucose response to standardized meals) → save as HallFullData/pbio.2005143.s015.tsv
  2. prepare_hall_data.qmd is set to eval: 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:
    quarto render prepare_hall_data.qmd -M eval:true
    This is the slow step - it's why the output is cached in hall_data.Rda.

Getting the materials

  • Browser: Code → Download ZIP (green button on the repo page)
  • Command line:
git clone https://github.com/IrinaStatsLab/CGM_short_course.git

Contact

Irina Gaynanova, PhD Department of Biostatistics, University of Michigan irinagn@umich.edu

About

Short tutorial on CGM

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages