Skip to content
/statistical-modeling/time-series-alignment

Time-Series Alignment

The process of putting measurements sampled on different clocks, at different rates, and with different physiological lags onto a common time axis so they can be compared or modeled jointly.

Time-series alignment is the work of mapping several measurement streams onto one shared clock, correcting for sampling rate, timestamp convention, and physiological delay, before any joint analysis is run. It is the step people skip, and it is the step that produces most spurious findings in personal molecular data.

How it works

Three distinct problems get bundled under one name.

Clock alignment. Two devices disagree about what time it is. CGM readers often store local wall-clock time with no offset field, so a flight or a DST boundary silently shifts your series by an hour or several. Lab systems store UTC. Phone-based food logs store whatever the OS reported at write time. You cannot resolve this by inspection after the fact, so capture the timezone at ingest.

Grid alignment. CGM is nominally 5-minute (Dexcom G6/G7) or 15-minute (Libre historical record), but the actual intervals drift: 300 s ± a few seconds, with gaps at sensor warmup, signal loss, and calibration. Blood biomarkers are one point per draw. Proteomics is one point per draw. You need an explicit resampling policy, not whatever your dataframe library does by default.

Physiological alignment. Interstitial glucose lags plasma glucose. The measured lag combines a true diffusion delay and a filter delay introduced by the sensor’s internal smoothing, and the estimate depends on which you are asking about and whether glucose is rising or falling; Kovatchev and colleagues laid out a graphical and numerical framework for separating these components rather than quoting one number.1 Practically, expect something on the order of 5 to 15 minutes, direction-dependent. If you are correlating CGM against a fingerstick or a venous glucose from the same draw as your proteomics, you are comparing two compartments, not two estimates of the same quantity.

In your own data

Files you will hold:

  • Dexcom Clarity export: CSV, columns Timestamp (YYYY-MM-DDThh:mm:ss), Glucose Value (mg/dL), plus Event Type rows for calibrations and notes. No timezone. High and low values are clamped as the strings High and Low (above 400, below 40), which will silently coerce to NaN.
  • Libre export: CSV with Device Timestamp in locale-dependent format (MM-DD-YYYY hh:mm AM/PM in US exports) and a Record Type column separating historic (type 0) from scan (type 1) readings. Mixing the two double-counts.
  • Lab panels: HL7 or a PDF you retyped. Keep the collection time, not the result time.

A resampling recipe we use:

cgm = (cgm.set_index("ts")
          .tz_localize("America/New_York", ambiguous="infer")
          .tz_convert("UTC"))
g = cgm["glucose"].resample("5min").mean()
g = g.interpolate(limit=3, limit_area="inside")   # bridge <=15 min only

The limit=3 matters. Unbounded interpolation across a 6-hour sensor dropout will invent a flat overnight trace and inflate time in range. Flag any run longer than three missing samples and exclude the surrounding window from summary statistics. Compute percent-time-active per day and drop days below about 70% coverage before you compare weeks.

For event-anchored analysis, do not merge on nearest timestamp. Build windows: t0 = meal start, extract t0−30 min to t0+180 min, and compute incremental AUC against the mean of the pre-meal 30 minutes. Then shift the CGM window back by your assumed interstitial lag, and re-run the analysis at 0, 5, 10, and 15 minutes to see whether your conclusion survives. If peak time moves your answer, report the sensitivity.

Population reference helps you judge whether a peak is unusual. CGMap characterized CGM distributions across thousands of non-diabetic individuals, which gives you percentile context for metrics like time above 140 mg/dL rather than a single threshold.2 Consensus targets for CGM metrics and reporting come from professional bodies and are worth reading before you invent your own summary set.3

One more failure mode: acetaminophen interferes with the older glucose-oxidase electrode chemistry used in Dexcom G5 and earlier by oxidizing at the working electrode and producing a falsely high reading. G6 and G7 added a membrane that largely blocks this at standard doses. If you take anything during a monitored window, log the time, because the artifact is a clean step you will otherwise model as a physiological event.

Limitations

Alignment does not create causality. A well-aligned meal and glucose excursion still confounds meal composition with time of day, sleep, and prior activity. Glucose prediction models trained on aligned CGM histories reach useful short-horizon accuracy but degrade sharply beyond 30 to 60 minutes and transfer poorly across subjects without adaptation.45 Single-timepoint omics cannot be aligned to a dense stream in any meaningful sense; one proteomics draw gives you a state variable, not a trajectory. And any glucose pattern that concerns you, including recurring nocturnal lows, is a clinical question. Bring the aligned series to a physician rather than acting on it yourself.

Woolf Software builds longitudinal molecular profiles of individuals: whole-genome sequencing, RNA sequencing, proteomics, blood biomarkers, and continuous glucose data, integrated into one model of you. Build your profile.

Computational Angle

Your CGM writes every 5 minutes in device-local time, your blood draws carry a lab accession timestamp, and your RNA-seq has one collection time; aligning them correctly is the difference between a real postprandial signal and an artifact of timezone handling.

References

  1. Boris P. Kovatchev, Devin Shields, Marc Breton. Graphical and Numerical Evaluation of Continuous Glucose Sensing Time Lag . Diabetes Technology &amp; Therapeutics, 2009. DOI
  2. Ayya Keshet, Smadar Shilo, Anastasia Godneva, et al.. CGMap: Characterizing continuous glucose monitor data in thousands of non-diabetic individuals . Cell Metabolism, 2023. DOI
  3. Timothy S. Bailey, George. Grunberger, Bruce W. Bode, et al.. American Association Of Clinical Endocrinologists And American College Of Endocrinology 2016 Outpatient Glucose Monitoring Consensus Statement . Endocrine Practice, 2016. DOI
  4. C. Pérez-Gandía, A. Facchinetti, G. Sparacino, et al.. Artificial Neural Network Algorithm for Online Glucose Prediction from Continuous Glucose Monitoring . Diabetes Technology &amp; Therapeutics, 2010. DOI
  5. Xia Yu, Tao Yang, Jingyi Lu, et al.. Deep transfer learning: a novel glucose prediction framework for new subjects with type 2 diabetes . Complex &amp; Intelligent Systems, 2021. DOI