Stable Isotope Batch QC Dashboard
What you'll learn
~25 min- Build a single-file isotope batch QC dashboard with one AI prompt
- Detect instrument drift by plotting reference standard values over sequence position
- Apply two-point normalization to correct raw isotope measurements against V-PDB
- Flag outlier values exceeding 2-sigma control limits with visual indicators
What you’re building
Every stable isotope run on an IRMS generates 30-60 rows of raw data: reference standards interspersed with unknown samples. Before anyone can trust the results, someone has to plot the standards, check for instrument drift, apply normalization corrections, and flag anything outside control limits. Right now that means opening Excel, building pivot charts by hand, and hoping nobody misses a drifting standard.
You are going to replace that with a browser-based QC dashboard. Upload a batch CSV, and it instantly shows drift plots, flags outliers in red, applies two-point normalization against V-PDB, and prints a pass/fail summary for the entire run. One HTML file, no installation, no server.
If you work in or support an IRMS lab, this is the artifact that proves you can automate tedious QC workflows. Show it to your lab director. Share it with the facility staff who spend 30 minutes per batch in Excel. It works on any computer with a browser.
Upload → classify rows → plot control values → flag outliers → apply corrections → export summary. This pattern works for any instrument that uses bracketing standards: LC-MS, ICP-MS, spectrophotometers. The isotope-specific math is in the prompt; the structure transfers everywhere.
🔍Domain Primer: Stable isotope terminology
New to stable isotopes? Here are the key terms you will encounter:
- Delta notation (δ) — Isotope ratios are reported as delta values, which express how much a sample differs from a standard. A δ¹³C of -25.0‰ means the sample has 25 parts per thousand less ¹³C than the reference standard.
- Isotope ratio (¹³C/¹²C) — The relative abundance of a heavy isotope to its light counterpart. IRMS instruments measure this ratio directly.
- V-PDB (Vienna Pee Dee Belemnite) — The international reference scale for carbon isotope ratios. All δ¹³C values are reported relative to V-PDB.
- V-SMOW (Vienna Standard Mean Ocean Water) — The reference scale for oxygen and hydrogen isotopes (δ¹⁸O, δ²H).
- AIR standard — The reference scale for nitrogen isotopes (δ¹⁵N). Atmospheric N₂ is defined as 0‰.
- Per mil (‰) — Parts per thousand. The unit for delta values. A change of 0.1‰ is analytically significant.
- Drift correction — IRMS instruments can shift slightly during a run. Standards measured at the beginning and end of a batch let you detect and correct for this drift. The tool detects drift visually in the sequence plots and corrects using batch-mean two-point normalization. For position-dependent drift correction (interpolating between bracketing standards), see the customization section below.
- Two-point normalization — A correction method that uses two reference standards with known δ values to create a linear calibration. It averages all standard measurements across the run to define the calibration anchors, which smooths out drift rather than correcting it position-by-position. More accurate than single-point correction because it corrects both offset and scale compression.
- Control limits (2σ) — Statistical boundaries set at two standard deviations from the expected value. A standard falling outside 2σ suggests the instrument may be out of spec.
- IRMS (Isotope Ratio Mass Spectrometry) — The instrument that measures stable isotope ratios. Samples are combusted or pyrolyzed, and the resulting gases (CO₂, N₂, H₂, CO) are separated and measured.
You do not need to be an expert in mass spectrometry. The AI handles the math; you need to know what the numbers mean.
Who this is for
- IRMS facility staff who run QC on every batch and want to stop doing it in Excel.
- Graduate students submitting samples to a stable isotope facility who want to verify their own results.
- PIs who need a quick pass/fail check before publishing isotope data.
IRMS facilities process hundreds of samples per week across carbon, nitrogen, oxygen, and hydrogen isotopes. Every analytical batch includes reference standards (like USGS-40 and USGS-41a) that must be checked before results are released. A QC dashboard that flags problems immediately saves the facility from releasing bad data and re-running samples.
The prompt
Open your terminal Terminal The app where you type commands. Mac: Cmd+Space, type "Terminal". Windows: open WSL (Ubuntu) from the Start menu.
Full lesson →
, navigate to a project folder project folder A directory on your computer where the tool lives. Create one with "mkdir my-project && cd my-project".
Full lesson →
, start your AI CLI tool AI CLI tool Claude Code, Gemini CLI, or Codex CLI — a command-line AI that reads files, writes code, and runs commands.
Full lesson →
(e.g., by typing claude), and paste this prompt:
Build a single self-contained HTML file called isotope-batch-qc.html that serves as astable isotope batch QC dashboard. Requirements:
1. DATA INPUT - A file upload button that accepts .csv files - Also accept paste into a textarea (CSV format) - Expected columns: Sequence_Position, Sample_ID, Type, Raw_d13C, Raw_d15N, Weight_mg, Peak_Area_mVs - Type column values: "standard" or "unknown" - Auto-detect which rows are reference standards by Type column - Include a "Load Example" button with this embedded sample data:
Sequence_Position,Sample_ID,Type,Raw_d13C,Raw_d15N,Weight_mg,Peak_Area_mVs 1,USGS-40,standard,-26.25,-4.45,0.52,3200 2,USGS-40,standard,-26.28,-4.48,0.50,3150 3,UNK-001,unknown,-22.15,-1.20,0.55,2890 4,UNK-002,unknown,-18.73,4.55,0.48,2750 5,UNK-003,unknown,-27.89,-2.10,0.61,3340 6,USGS-41a,standard,36.55,47.52,0.53,3080 7,UNK-004,unknown,-14.22,8.30,0.50,2920 8,UNK-005,unknown,-25.67,-0.85,0.47,2680 9,UNK-006,unknown,-20.44,3.75,0.58,3190 10,USGS-40,standard,-26.18,-4.38,0.51,3210 11,USGS-41a,standard,36.62,47.60,0.49,3020 12,UNK-007,unknown,-31.05,-5.90,0.62,3450 13,UNK-008,unknown,-16.88,6.12,0.44,2560 14,UNK-009,unknown,-23.41,1.95,0.57,3100 15,UNK-010,unknown,-19.56,5.40,0.53,2870 16,USGS-40,standard,-26.12,-4.32,0.50,3180 17,USGS-41a,standard,36.68,47.68,0.52,3050 18,UNK-011,unknown,-28.33,-3.60,0.59,3280 19,UNK-012,unknown,-21.77,2.88,0.46,2710 20,UNK-013,unknown,-17.95,7.05,0.54,2940 21,USGS-40,standard,-26.05,-4.25,0.48,3120 22,USGS-41a,standard,36.75,47.78,0.51,2990 23,UNK-014,unknown,-24.60,0.45,0.56,3060 24,UNK-015,unknown,-15.30,9.15,0.50,2800 25,USGS-40,standard,-25.98,-4.20,0.52,3250 26,USGS-41a,standard,36.80,47.85,0.49,3000 27,USGS-40,standard,-25.40,-3.55,0.53,1850
Note: the data has intentional drift (USGS-40 d13C trending from -26.25 to -25.98 over the run, ~0.27 per mil) and one outlier (row 27, low peak area and off-value). Known accepted values: USGS-40 d13C = -26.39, d15N = -4.52; USGS-41a d13C = +36.55, d15N = +47.55.
2. DRIFT VISUALIZATION - Line chart (Chart.js) showing each reference standard's raw d13C value plotted against Sequence_Position - Separate series for each standard (USGS-40, USGS-41a) with different colors - Horizontal dashed lines showing the accepted/known value for each standard - Shade a band at +/- 2 sigma from the mean of each standard's measured values - Points outside the 2-sigma band should be colored red and slightly larger - Second chart: same layout but for d15N values
3. TWO-POINT NORMALIZATION - Calculate normalization using the mean measured values of USGS-40 and USGS-41a (excluding outliers outside 2-sigma) as anchors - Linear equation: d13C_corrected = m * d13C_raw + b, where m and b are derived from the two-point calibration against accepted V-PDB values - Apply correction to all unknown samples - Show the normalization equation and r-squared value prominently - Display a before/after comparison chart: grouped bar chart showing raw vs corrected d13C for each unknown sample
4. SUMMARY TABLE - For each reference standard, show: name, n measurements, mean raw d13C, SD, accepted value, offset from accepted, pass/fail (fail if |offset| > 0.3 per mil or SD > 0.15 per mil) - Overall batch status: large green PASS or red FAIL badge - Same table for d15N values
5. DESIGN - Dark theme: background #0f172a, cards #1e293b, text #e2e8f0, accent #10b981 - Clean sans-serif font (Inter from Google Fonts CDN) - Responsive single-column layout - "Load Example" and "Clear" buttons at the top - Section headers: "Drift Monitor", "Normalization", "Batch Summary"
6. TECHNICAL - Pure HTML/CSS/JS in one file, no build step - Chart.js loaded from CDN (https://cdn.jsdelivr.net/npm/chart.js) - All calculations in plain JavaScript (no external math libraries) - CSV parsing handles quoted fields and trailing newlinesThat entire block is the prompt. Paste it as-is. The embedded sample data has realistic drift and an outlier so you can immediately see the QC features working. The specificity about accepted values and control limits is critical — without it, the AI cannot build the normalization correctly.
What you get
After the LLM finishes (typically 60-90 seconds), you will have a single file: isotope-batch-qc.html. Open it in any browser.
Expected output structure
isotope-batch-qc.html (~700-900 lines)Click Load Example and you should see:
- Drift Monitor (δ¹³C) — A line chart with USGS-40 values trending upward from about -26.25 to -25.98 over the run. USGS-41a values trending slightly upward as well. The outlier in row 27 appears as a red dot outside the 2σ band. Accepted value lines are visible as dashed horizontals.
- Drift Monitor (δ¹⁵N) — Same layout for nitrogen. The drift should be less pronounced but the outlier should still flag.
- Normalization section — The two-point calibration equation displayed (something like
δ¹³C_corrected = 1.003 × δ¹³C_raw - 0.12). A grouped bar chart showing raw vs corrected values for all 15 unknowns. - Batch Summary — A table showing USGS-40 mean, SD, offset from accepted value (-26.39‰), and pass/fail. The outlier row should be excluded from the mean calculation. An overall batch status badge.
If something is off
| Problem | Follow-up prompt |
|---|---|
| 2σ band not visible | The 2-sigma control bands are not showing on the drift chart. Calculate the standard deviation of each reference standard's values and draw a filled rectangle from mean-2*SD to mean+2*SD behind the data points. |
| Normalization produces NaN | The two-point normalization is producing NaN. Check that the denominator (mean_USGS41a_raw - mean_USGS40_raw) is not zero. Print the intermediate values to the console for debugging. |
| Outlier not flagged red | Row 27 should be flagged as an outlier but it's the same color as other points. Check that the 2-sigma outlier detection is comparing each point to the mean and SD of its own standard group. |
How it works (the 2-minute explanation)
- CSV parsing splits the file into rows, identifies standards vs unknowns by the Type column, and groups standards by Sample_ID. This is the same pattern you would use for any instrument QC data.
- Drift detection plots each standard’s measured values in sequence order. A flat line means no drift. An upward or downward trend means the instrument is shifting. This is the single most important QC check for IRMS.
- Two-point normalization creates a linear calibration using two standards with known values. If USGS-40 (accepted: -26.39‰) measures -26.15‰ on average, and USGS-41a (accepted: +36.55‰) measures +36.70‰ on average, the calibration line corrects both the offset and any scale compression. This is more accurate than single-point correction, which only fixes the offset.
- Control limits (2σ) are calculated from the measured standard deviation. Any standard measurement falling outside mean ± 2σ is likely an analytical problem (contamination, poor combustion, low sample weight) rather than normal instrument variation.
Single-point normalization (subtracting the offset from one standard) assumes the instrument’s response is perfectly linear across the full δ range. In practice, IRMS instruments exhibit slight scale compression — the measured range between two standards is narrower than the true range. Two-point normalization corrects for this compression because it uses two anchors at different δ values to define both the slope and intercept of the correction line. IAEA guidelines recommend two-point normalization for all published stable isotope data.
When Things Go Wrong
Use the Symptom → Evidence → Request pattern: describe what you see, paste the error, then ask for a fix.
Customize it
Add δ¹⁸O and δ²H support
Extend the dashboard to handle oxygen and hydrogen isotopes. Add columns Raw_d18Oand Raw_d2H to the CSV parser. Create additional drift charts and normalizationsections for these isotopes. For water samples, use V-SMOW as the reference scalewith VSMOW2 and SLAP2 as normalization anchors. For carbonate samples, use V-PDBoxygen with NBS-18 and NBS-19 as anchors. Add a dropdown to select the samplematrix (water or carbonate) so the correct reference standards and scale are used.Let the user toggle which isotopes are displayed.Add position-dependent drift correction
Replace the batch-mean normalization with position-dependent drift correction.Instead of averaging all USGS-40 and USGS-41a measurements into single anchorvalues, interpolate between bracketing standard pairs. For each unknown sample,find the nearest standard measurements before and after it in sequence position,linearly interpolate the correction at that position, and apply it. This correctsfor within-run drift rather than averaging it out. Show the interpolated correctioncurve on the drift chart as a smooth line overlaying the data points.Add a printable QC report
Add an "Export QC Report" button that opens a new window with a print-friendlylayout on white background. Include: batch date (from a date picker input),analyst name, instrument ID, all drift charts rendered as static images(Chart.js toBase64Image), the normalization equation, and the pass/fail summarytable. Format for A4 paper with the facility logo placeholder at the top.Add historical batch tracking
Add a "Save Batch" button that stores the current batch summary (date, standardmeans, SDs, pass/fail status) in localStorage. Add a "History" tab that shows atable of all saved batches and a trend chart of USGS-40 mean d13C values acrossbatches over time. This lets staff track long-term instrument performance.Start with the working QC dashboard, then layer on features one prompt at a time. The printable report is often the first request from facility directors — they need paper records for accreditation audits. Historical tracking is the second — it turns a per-batch tool into a long-term instrument health monitor.
Try it yourself
- Open your CLI tool in an empty folder.
- Paste the main prompt from above.
- Open
isotope-batch-qc.htmlin your browser. - Click Load Example to see the QC dashboard with realistic drift and an outlier.
- If you have real IRMS data, export a batch from your instrument software as CSV and upload it. You may need to rename columns to match the expected format.
If this saves your facility even one batch of re-runs, it has already paid for itself.
Key takeaways
- Instrument QC is a pattern, not a one-off task — every batch needs the same drift check, normalization, and pass/fail assessment. Automating it eliminates human error and saves 20-30 minutes per batch.
- Two-point normalization is the gold standard for stable isotope corrections. It corrects both offset and scale compression, which single-point correction misses.
- Control limits (2σ) provide objective outlier detection — no more judgment calls about whether a standard “looks okay.” The dashboard flags it automatically.
- Single-file HTML tools work perfectly for instrument QC — the lab computer running the IRMS does not need Python, R, or any special software. Just a browser.
Reference standards are placed at regular intervals throughout an IRMS batch rather than only at the beginning. What is the primary reason?
Two-point normalization uses two reference standards with known δ values instead of one. What does the second standard correct for that single-point normalization cannot?
What’s next
In the next lesson, you will build an Energy Expenditure Study Summarizer that takes doubly labeled water isotope data and calculates total daily energy expenditure for each subject — automating the Speakman equations that DLW researchers currently compute by hand in spreadsheets.