Spatial transcriptomics captures gene expression at fixed array spots on a tissue section, preserving each spot's (x, y) location. Each spot's raw counts are noisy estimates of true underlying transcript abundance, so clinical pipelines apply a QC detection threshold before assigning a spot to a cell-type/tissue-domain label by comparing marker-gene signal.
This sim generates a synthetic tumor section with three ground-truth domains — a tumor core (EPCAM), a surrounding stroma (PDGFRB), and scattered immune infiltrate (CD8) — then "scans" it spot by spot, adding Gaussian noise before re-classifying each spot from its noisy signal.
measured_g = truth_g + N(0, sigma) for g in {EPCAM, CD8, PDGFRB}
detected = max_g(measured_g) >= QC_threshold
label = argmax_g(measured_g) if detected else "QC-fail"
accuracy = correct_calls / detected_spots
- Spot grid resolution — sets the array density (spots analyzed), like choosing a finer capture array.
- Measurement noise (σ) — Gaussian noise standard deviation added to each marker's true signal, mimicking assay/sequencing noise.
- QC threshold — minimum peak signal a spot needs to be called "detected"; too low admits noise, too high discards real signal.
- Scan speed — how fast the capture probe sweeps across the section.
- Rescan tissue — restarts the sweep and resets all QC statistics.
In clinical pathology, this exact tradeoff — QC threshold vs. noise vs. resolution — determines whether a pathologist can trust a spatial map of tumor, stromal, and immune compartments for diagnosis or biomarker scoring.