Cryopreservation & IVF Calculator
What you'll learn
~20 min- Build a standalone cryopreservation and IVF calculator with a single AI prompt
- Calculate freezing media dilutions, estimate post-thaw viability, and plan IVF recovery sessions
- Troubleshoot common issues with dilution math, Chart.js bar rendering, and viability thresholds
- Customize the calculator with strain-specific benchmarks, cost estimates, or batch comparison views
What you’re building
Cryopreservation is insurance for your mouse colony. Instead of keeping a rare or expensive line alive as a breeding colony indefinitely — burning through per diem costs and cage space — you freeze sperm and recover the line later by IVF when you need it. The GEAM facility does this as a service, archiving dozens of lines per year.
This tool focuses on sperm cryopreservation, which is the most common archival method for mouse lines. Embryo vitrification is a related but distinct process that uses different quality metrics (morphology score, re-expansion rate after warming) and different protocols. The same single-prompt approach works for building an embryo vitrification tracker — just swap the sample data and metrics.
The problem: every freeze session involves mental math. How much cryoprotectant do you dilute? What post-thaw motility should you expect for this strain? How many females do you superovulate to get enough oocytes for a recovery? Right now, the answers live in someone’s head, a dog-eared protocol binder, or scattered across old lab notebooks.
You are going to build a calculator that centralizes all of that in one browser tab.
A cryopreservation calculator is not glamorous, but it prevents expensive mistakes. One botched dilution wastes a freeze session. One underestimate on superovulated females delays a line recovery by weeks. This tool turns tribal knowledge into a shared, reusable resource that any trained tech can use. Show it to your facility director.
By the end of this lesson you will have a standalone cryopreservation and IVF calculator that runs entirely in the browser. It loads embedded historical freeze/thaw data, calculates media dilution volumes, estimates post-thaw viability based on past performance, and plans IVF recovery sessions. You will build it by giving a single prompt to an LLM CLI tool.
Input parameters → compute derived values → compare against historical data → recommend action. This pattern works for manufacturing quality control, clinical lab reference ranges, equipment calibration — any domain where you combine calculation with historical performance data.
🔍Domain Primer: Key cryopreservation and IVF terms you'll see in this lesson
New to mouse cryopreservation? Here are the key terms you will encounter:
- Cryopreservation — Freezing biological material at ultra-low temperatures (-196 C in liquid nitrogen) for long-term storage. For mouse colonies, this typically means sperm cryopreservation (the focus of this lesson) or embryo vitrification. The goal is to preserve viability so the material can be thawed and used months or years later.
- Cryoprotectant — A chemical added to the freezing media that prevents ice crystal formation inside cells. Common cryoprotectants include DMSO (dimethyl sulfoxide) and glycerol. Too much damages cells; too little allows ice crystals to form.
- Vitrification vs. slow-freeze — Two approaches to cryopreservation. Slow-freeze uses a controlled-rate freezer to cool gradually. Vitrification uses very high cryoprotectant concentrations and ultra-rapid cooling to form a glass-like solid without ice crystals. Vitrification generally gives better results for embryos; slow-freeze is standard for sperm.
- Post-thaw motility — The percentage of sperm that are still moving after being thawed from frozen storage. This is the primary quality metric for sperm cryopreservation. Above 50% motility is considered good; below 20% is poor and indicates the freezing protocol needs to be changed. You cannot re-freeze thawed sperm — instead, you go back to the live colony, collect fresh sperm, and freeze a new batch using a different cryoprotectant or cooling rate.
- Superovulation — Hormone injections (PMSG + hCG) given to female mice to stimulate them to release many more oocytes (eggs) than they would naturally. A superovulated female might produce 15-30 oocytes vs. 6-8 naturally.
- IVF (in vitro fertilization) — Combining sperm and oocytes in a dish to achieve fertilization outside the body. Used to recover mouse lines from frozen sperm.
- Oocyte — An egg cell. In mouse IVF, oocytes are collected from superovulated females, placed in fertilization media, and combined with thawed sperm.
- Straw / vial — The containers used to store frozen sperm. Straws are thin sealed tubes; vials (cryovials) are small screw-cap tubes. Each straw typically contains enough sperm for one IVF session.
- Embryo transfer — Surgical placement of 2-cell embryos into a pseudopregnant recipient female. Typically 12-15 embryos per recipient.
- Pseudopregnant recipient — A female mouse mated with a vasectomized male, creating the hormonal state needed to accept transferred embryos. Must be prepared on the same timeline as the IVF.
You do not need to perform these procedures — the tool is for the people who do. You just need to know what the numbers mean.
Who this is for
- GEAM cryopreservation technicians who perform freeze and thaw sessions weekly and need quick dilution calculations and viability benchmarks.
- Colony managers planning line archival or recovery who need to estimate how many females to superovulate and how many straws to thaw.
- PIs and lab managers who want historical viability data at a glance to decide whether to collect fresh sperm and try a different cryoprotectant protocol for lines with poor past performance.
The GEAM facility archives mouse lines as a service — PIs submit a request, the facility freezes sperm and stores it in liquid nitrogen tanks. When a PI needs the line back, the facility thaws sperm and performs IVF. Having historical viability data and automated dilution calculations standardizes the process across technicians and reduces errors, especially during high-volume weeks when the facility may process 5-10 strains.
The showcase
Here is what the finished calculator looks like once you open the HTML file in a browser:
- Historical viability dashboard showing a bar chart of post-thaw motility rates across all archived strains. Each bar is color-coded: green (>50% motility), amber (20-50%), red (<20%).
- Dilution calculator with input fields for stock cryoprotectant concentration, desired working concentration, and final volume. Outputs the exact volumes of stock solution and diluent needed.
- Post-thaw viability estimator where you select a strain and see its historical average motility with confidence range, plus a go/no-go recommendation.
- IVF planning section with inputs for number of straws to thaw, expected motility, number of females to superovulate, expected oocyte yield per female, and fertilization rate. Outputs the expected number of 2-cell embryos and a recommendation on whether to proceed.
- Summary card with a go/no-go recommendation based on all inputs, with clear reasoning.
Everything runs client-side. No data leaves the browser.
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 cryo-calculator.html that serves asa cryopreservation and IVF calculator for a mouse facility. Requirements:
1. EMBEDDED HISTORICAL DATA Preload the following freeze/thaw history as a JavaScript array: [ { strain: "B6-Cre", dateFrozen: "2025-06-15", strawsFrozen: 12, preMotility: 85, postMotility: 62, cryoprotectant: "DMSO", coolingRate: "slow-freeze" }, { strain: "B6-Cre", dateFrozen: "2025-09-20", strawsFrozen: 10, preMotility: 80, postMotility: 58, cryoprotectant: "DMSO", coolingRate: "slow-freeze" }, { strain: "129-KO", dateFrozen: "2025-07-10", strawsFrozen: 8, preMotility: 78, postMotility: 45, cryoprotectant: "DMSO", coolingRate: "slow-freeze" }, { strain: "129-KO", dateFrozen: "2025-11-05", strawsFrozen: 10, preMotility: 82, postMotility: 42, cryoprotectant: "glycerol", coolingRate: "slow-freeze" }, { strain: "BALB-Flox", dateFrozen: "2025-08-22", strawsFrozen: 15, preMotility: 90, postMotility: 71, cryoprotectant: "DMSO", coolingRate: "slow-freeze" }, { strain: "BALB-Flox", dateFrozen: "2026-01-10", strawsFrozen: 12, preMotility: 88, postMotility: 68, cryoprotectant: "DMSO", coolingRate: "slow-freeze" }, { strain: "NSG-tdTom", dateFrozen: "2025-10-01", strawsFrozen: 6, preMotility: 75, postMotility: 18, cryoprotectant: "glycerol", coolingRate: "slow-freeze" }, { strain: "NSG-tdTom", dateFrozen: "2026-02-14", strawsFrozen: 8, preMotility: 72, postMotility: 15, cryoprotectant: "glycerol", coolingRate: "slow-freeze" }, { strain: "FVB-GFP", dateFrozen: "2025-05-30", strawsFrozen: 10, preMotility: 88, postMotility: 55, cryoprotectant: "DMSO", coolingRate: "slow-freeze" }, { strain: "CD1-WT", dateFrozen: "2025-12-08", strawsFrozen: 20, preMotility: 92, postMotility: 74, cryoprotectant: "DMSO", coolingRate: "slow-freeze" }, { strain: "CD1-WT", dateFrozen: "2026-01-25", strawsFrozen: 18, preMotility: 90, postMotility: 70, cryoprotectant: "DMSO", coolingRate: "slow-freeze" }, { strain: "Swiss-KI", dateFrozen: "2025-09-12", strawsFrozen: 8, preMotility: 70, postMotility: 12, cryoprotectant: "glycerol", coolingRate: "slow-freeze" } ]
2. HISTORICAL VIABILITY DASHBOARD - Grouped bar chart (Chart.js) showing pre-freeze vs post-thaw motility for each freeze record, sorted by strain name - Color-code post-thaw bars: green if >50%, amber if 20-50%, red if <20% - Show strain average motility as a horizontal reference line per strain group - Display average post-thaw motility per strain in summary cards above the chart
3. DILUTION CALCULATOR - Input fields: stock concentration (%), desired working concentration (%), final volume needed (mL) - Calculate and display: volume of stock solution (mL), volume of diluent (mL) - Formula: V_stock = (C_working x V_final) / C_stock; V_diluent = V_final - V_stock - Common presets: "10% DMSO from 100% stock", "15% glycerol from 100% stock", "5% DMSO from 50% stock" — clicking a preset fills in the fields - Show a warning if calculated stock volume exceeds final volume (impossible dilution)
4. POST-THAW VIABILITY ESTIMATOR - Dropdown to select a strain from the historical data - Show that strain's historical average post-thaw motility with min/max range - Show number of previous freeze records for confidence context - Go/no-go recommendation: green "Good candidate" if avg >50%, amber "Proceed with caution" if 20-50%, red "Poor viability — collect fresh sperm and freeze with different protocol" if <20% - If strain has only 1 record, show a "Low confidence — only 1 data point" note
5. IVF PLANNING SECTION - Inputs: number of straws to thaw, expected post-thaw motility (auto-fill from strain selection), number of females to superovulate, expected oocytes per female (default 25), expected fertilization rate (default 60%) - Calculate: total expected motile sperm, total expected oocytes, expected 2-cell embryos (oocytes x fertilization rate), expected live pups (2-cell embryos x 30% implantation rate) - Summary card: "Thaw X straws → Y motile doses → Z oocytes from N females → W expected 2-cell embryos → V expected pups" - Go/no-go: green if expected pups >= 10, amber if 5-9, red if <5
6. DESIGN - Dark theme: background #0f172a, cards #1e293b, text #e2e8f0, accent #10b981 - Clean sans-serif font (Inter from Google Fonts CDN) - Responsive layout, calculator sections in a clear top-to-bottom flow - Go/no-go badges with distinct colors and icons - Input fields with clear labels and units
7. 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 real-time as inputs change (no submit button needed) - Input validation: no negative numbers, concentrations 0-100%, volumes > 0That entire block is the prompt. Paste it as-is. The embedded historical data includes both high-viability strains (B6-Cre, CD1-WT) and low-viability strains (NSG-tdTom, Swiss-KI), so the LLM correctly implements the go/no-go logic for all scenarios. The dilution presets prevent the most common follow-up question.
What you get
After the LLM finishes (typically 60-90 seconds), you will have a single file: cryo-calculator.html. Open it in any browser.
Expected output structure
cryo-calculator.html (~500-700 lines)You should see:
- Strain summary cards at the top showing average post-thaw motility for each strain. CD1-WT should show ~72%, B6-Cre ~60%, NSG-tdTom ~16.5%, Swiss-KI ~12%.
- A grouped bar chart with paired bars (pre-freeze in blue, post-thaw in colored by threshold) for all 12 freeze records. NSG-tdTom and Swiss-KI bars should be red. BALB-Flox and CD1-WT bars should be green.
- The dilution calculator with three input fields. Click the “10% DMSO from 100% stock” preset and it should show: stock volume = 1 mL, diluent = 9 mL (for a 10 mL final volume).
- The viability estimator — select “NSG-tdTom” from the dropdown and you should see an average of ~16.5% motility with a red “Poor viability” recommendation. Select “BALB-Flox” and you should see ~69.5% with a green “Good candidate” badge.
- The IVF planning section — with default values, it should calculate the full pipeline from straws to expected pups and show a go/no-go recommendation.
If something is off
| Problem | Follow-up prompt |
|---|---|
| Bar chart shows all bars the same color | The post-thaw motility bars should be color-coded: green if >50%, amber/yellow if 20-50%, red if <20%. Use conditional coloring in the Chart.js dataset backgroundColor array based on each data point's value. |
| Dilution calculator shows negative diluent volume | When the working concentration is higher than the stock concentration, the calculator shows a negative diluent volume. Add input validation: if working concentration >= stock concentration, show an error message "Working concentration must be less than stock concentration" and disable the result display. |
| IVF section not updating when strain is selected | When I select a strain in the viability estimator, the expected post-thaw motility in the IVF section should auto-fill with that strain's average. Add an event listener on the strain dropdown that updates the motility input in the IVF section. |
When Things Go Wrong
Use the Symptom → Evidence → Request pattern: describe what you see, paste the error, then ask for a fix.
How it works (the 2-minute explanation)
You do not need to understand every line of the generated code, but here is the mental model:
- The dilution formula is
C1 x V1 = C2 x V2, rearranged to find V1 (volume of stock to add). The diluent volume is simply the final volume minus the stock volume. This is the same formula from general chemistry. - Historical viability is just descriptive statistics: compute the mean, min, and max of post-thaw motility for each strain. The color thresholds (50%, 20%) turn these numbers into actionable recommendations.
- IVF planning chains a series of multiplications: straws x motile fraction = motile sperm doses, females x oocytes/female = total oocytes, oocytes x fertilization rate = 2-cell embryos, embryos x implantation rate = expected pups. Each step has uncertainty, but the chain gives a useful planning estimate.
- Chart.js conditional coloring assigns a different
backgroundColorto each bar based on its value, using a simplemap()over the data array with threshold checks.
Some mouse strains consistently freeze poorly. NSG mice are notorious for low post-thaw sperm motility. If your facility tracks viability data over time, you can identify which strains need protocol adjustments (switching from glycerol to DMSO, using vitrification instead of slow-freeze, or increasing sperm concentration). Without historical data, every freeze session is a gamble. This calculator turns anecdotal experience into data-driven decisions.
Customize it
The base calculator is useful as-is, but here are single-prompt extensions that make it more powerful:
Add strain-specific protocol recommendations
Add a "Protocol Advisor" section. Based on the historical data, recommend the bestcryoprotectant and cooling rate for each strain. Compare average post-thaw motilityacross protocols used for the same strain. If a strain has been frozen with bothDMSO and glycerol, show which performed better as a clear recommendation card withthe percent difference. If only one protocol has been tried, suggest trying thealternative and show what other similar strains achieved with it.Add cost estimator
Add a "Cost Estimator" panel to the IVF planning section. Include these costinputs with default values: superovulation hormones per female ($15), IVF mediaand supplies per session ($50), transfer surgery per recipient ($75), per diemcage cost per day ($1.50), expected days to genotype (21). Calculate the total costof a recovery attempt and compare it to the cost of maintaining a live breedingcolony for 6 months. Show a break-even analysis: "Recovery costs $X. Maintaininga live colony costs $Y per month. Cryopreservation pays for itself after Z months."Add batch comparison view
Add a "Batch Comparison" tab that lets me select two freeze sessions for the samestrain and compare them side by side. Show pre-freeze motility, post-thaw motility,cryoprotectant used, date frozen, and any differences highlighted. Include a smallline chart showing that strain's motility trend over time (X-axis: freeze dates,Y-axis: post-thaw motility) to spot whether the protocol is improving or degrading.Notice the pattern: you start with a working calculator, then add features one prompt at a time. The protocol advisor turns historical data into actionable guidance. The cost estimator justifies the facility’s cryopreservation service to PIs. Each extension is a single prompt away.
Try it yourself
- Open your CLI tool in an empty folder.
- Paste the main prompt from above.
- Open the generated
cryo-calculator.htmlin your browser. - Try the dilution calculator with different concentrations.
- Select “NSG-tdTom” in the viability estimator and note the red warning — then select “CD1-WT” and see the green recommendation.
- Pick one customization from the list above and add it.
If your facility freezes even a few mouse lines per year, this tool standardizes the decision-making process. Save it, share it with the cryo team.
Key takeaways
- One prompt, one tool: a detailed prompt with embedded historical data produces a working cryopreservation calculator in under 2 minutes.
- Single-file HTML tools run anywhere — on the facility office computer, on a laptop in the vivarium, on a PI’s desktop during a meeting. No installation, no dependencies.
- Historical viability data transforms anecdotal experience into evidence-based decisions — tracking post-thaw motility across strains and protocols reveals patterns that individual technicians might not notice.
- The dilution formula is universal — the same
C1V1 = C2V2pattern applies to buffer preparation, drug dosing, media formulation, and any concentration-based calculation. - Go/no-go recommendations reduce cognitive load — instead of interpreting numbers, the tool gives a clear green/amber/red signal. The user can still see the underlying data, but the recommendation surfaces the actionable conclusion immediately.
A strain's historical data shows post-thaw motility of 18%, 15%, and 12% across three freeze sessions, all using glycerol as the cryoprotectant. What does this data suggest?
You need to prepare 10 mL of 10% DMSO working solution from a 100% DMSO stock. How much stock solution do you need?
Your IVF calculator estimates 3 expected live pups from a recovery attempt. What should you do?
What’s next
In the next lesson, you will build a Stable Isotope Batch QC Dashboard — a tool that flags instrument drift, applies reference corrections to delta values, and visualizes measurement variance across analytical runs. Same pattern: one prompt, one HTML file, immediate utility for the stable isotope facility.