# Paired Refinement Experiments This directory evaluates masked diffusion as an enhancer refiner rather than as a pure de novo generator. For each reference sequence `x`, the script creates edited variants `x'` under a mutation budget `rho`, scores both sequences with the trained DeepSTARR predictor, and reports: ```text delta = predictor(x') - predictor(x) ``` ## Experiments covered 1. Paired delta distribution over `rho = 0.01, 0.03, 0.05, 0.10, 0.20`. 2. Mask-selection strategy comparison: - `random`: randomly chosen editable positions. - `entropy`: positions where the diffusion model is most uncertain. - `logit_gap`: positions where the diffusion model most prefers a different base than the current base. 3. Best-of-N refinement: - sample multiple edits per sequence and keep the candidate with the largest predicted activity gain. ## Outputs The default output directory is: ```text ${RESULT_ROOT}/refinement/paired_refinement_test ``` It contains: ```text refinement_details.jsonl refinement_summary.json paired_delta_by_mask_ratio.png strategy_delta_violin.png best_of_n_refinement_curve.png ``` ## Recommended command on the GPU server Run from the repository root. Use explicit environment variables to avoid stale defaults from `env.sh`. ```bash cd /inspire/hdd/project/intelligentcreativedesign/dangshengqi-253114050252/z-anna/genrl-enhancer-diffusion PROJECT_ROOT=$(pwd) \ RUN_ROOT=$(pwd)/paper_runs \ DEEPSTARR_DIR=$(pwd)/datas/DeepSTARR-enhancer-activity \ GENERANNO_BASE_MODEL=$(pwd)/models/GENERanno-eukaryote-0.5b-base \ DIFFUSION_MODEL=$(pwd)/saved_model/deepstarr_discrete_diffusion \ PREDICTOR_MODEL=$(pwd)/paper_runs/results/deepstarr_regression/best_model \ REFINEMENT_SPLIT=test \ REFINEMENT_NUM_SEQUENCES=1024 \ REFINEMENT_NUM_SAMPLES=8 \ REFINEMENT_MASK_RATIOS="0.01 0.03 0.05 0.10 0.20" \ REFINEMENT_STRATEGIES="random entropy logit_gap" \ REFINEMENT_DIFFUSION_STEPS=32 \ REFINEMENT_BATCH_SIZE=16 \ PREDICTOR_SCORE_BATCH_SIZE=256 \ TRANSFORMERS_NO_TF=1 \ USE_TF=0 \ TOKENIZERS_PARALLELISM=false \ nohup bash scripts/11_refinement/run_paired_refinement.sh > paired_refinement.log 2>&1 & ``` For a fast smoke test: ```bash PROJECT_ROOT=$(pwd) \ RUN_ROOT=$(pwd)/paper_runs \ DEEPSTARR_DIR=$(pwd)/datas/DeepSTARR-enhancer-activity \ GENERANNO_BASE_MODEL=$(pwd)/models/GENERanno-eukaryote-0.5b-base \ DIFFUSION_MODEL=$(pwd)/saved_model/deepstarr_discrete_diffusion \ PREDICTOR_MODEL=$(pwd)/paper_runs/results/deepstarr_regression/best_model \ REFINEMENT_SPLIT=valid \ REFINEMENT_NUM_SEQUENCES=64 \ REFINEMENT_NUM_SAMPLES=2 \ REFINEMENT_MASK_RATIOS="0.03 0.10" \ REFINEMENT_STRATEGIES="random logit_gap" \ REFINEMENT_DIFFUSION_STEPS=16 \ REFINEMENT_BATCH_SIZE=16 \ PREDICTOR_SCORE_BATCH_SIZE=128 \ TRANSFORMERS_NO_TF=1 \ USE_TF=0 \ TOKENIZERS_PARALLELISM=false \ nohup bash scripts/11_refinement/run_paired_refinement.sh > paired_refinement_smoke.log 2>&1 & ```