This repository contains reproducible simulation code for the paper:
Title: Borderline copy number variations in preimplantation genetic testing: when signal becomes noise Authors: Anere Cye Journal: Royal Society Open Science (2026) DOI: 10.5281/zenodo.19421746
- R/ - simulation functions
- scripts/ - run_all.R and scenario scripts
- results/ - generated automatically
Open R in the project root and run: source(scripts/run_all.R)
All simulations use set.seed(2025). 5000 replicates per condition.
The first-pass real-data workflow uses only one workbook and only two sheets:
data/wgspgt/Fig.1d_Fig.1e_Fig.1f_Fig.1g_Fig.2b_Fig5.xlsxFig1f_WGSfor chromosome-level inputFig1d_Fig1efor embryo-level metadata
The loader in R/load_wgspgt_data.R:
- treats
EmbryoNumberasembryo_id - reshapes the WGS sheet from wide chromosome columns to tidy rows
- joins
meanDepth,meanBreadth,EmbryoStatus, andMethod - skips all other sheets for now
Run the validation analysis from the project root with:
Rscript analysis_wgspgt_validation.R
This first pass does not require a diagnosis sheet yet. It saves a cleaned
dataset and descriptive threshold-based outputs to results/wgspgt_validation/:
wgspgt_cleaned.csvwgspgt_threshold_calls.csvwgspgt_chromosome_summary.csvwgspgt_embryo_summary.csvwgspgt_method_summary.csv
The original simulation code is preserved as the idealized model. A new parallel prototype framework models a more realistic aggregated-signal path:
- latent embryo state
- latent chromosome-level signal
- measurement / distortion / aggregation layer
- embryo-level decision rule
Core files:
MODEL_REDESIGN.mdR/simulate_latent_embryo_state.RR/simulate_latent_chromosome_signal.RR/simulate_measurement_layer.RR/classify_embryo_realistic.Ranalysis_realistic_simulation.R
Run the realistic prototype from the project root with:
Rscript analysis_realistic_simulation.R
Outputs are written to results/realistic_simulation/, including:
- chromosome-level observed signal tables
- embryo-level summaries
- calibration cutoffs for out-of-sample evaluation
- evaluation metrics for out-of-sample evaluation
- confusion matrices
- sensitivity / specificity / accuracy tables
- decision-rule comparison tables
- idealized vs realistic comparison tables
- signal distribution plots
False normal rate M=15%: 34.5% [33.2-35.9%] False positive rate diploid: 54.4% [53.0-55.8%]