Skip to content

Part 1 Enhancer Encoder

Jiecong Lin edited this page Jul 15, 2026 · 3 revisions

Part 1 — Enhancer-activity encoder

Do this first — Part 2 loads this encoder (frozen).

The encoder (enhancer_predictor_256bp in EPInformer/models.py) predicts 256 bp enhancer activity from sequence. Target = log2(0.1 + Activity) where Activity = sqrt(H3K27ac_RPM · DNase_RPM).

1a. Preprocessing — ENCODE → ABC → 256 bp activity CSV

# DNase/H3K27ac BAMs + Hi-C (K562/GM12878)
python scripts/download_encode_data.py --cell-types K562,GM12878 --output-dir data
for f in data/*/{DNase,H3K27ac}/ENCFF*.bam; do samtools index "$f"; done

# Pinned H3K27ac narrowPeaks = the encoder summit sources
# (the shared manifest downloads the configured cell lines)
python scripts/download_encode_data.py --from-manifest config/encoder_narrowpeaks.json
gunzip -f reference/K562_H3K27ac.ENCFF544LXB.narrowPeak.gz

# Preview, then submit CPU/memory-heavy ABC work through SLURM
python run_pipeline.py --config config/config.yaml --samples K562 --stages links --dry-run
SAMPLES=K562 STAGES=links sbatch slurm/run_pipeline_cpu.slurm
#   -> batch_output/{cell}/links/{cell}_peak_5bins_around_summit_activity_sequence.csv

The pipeline job requests 12 CPUs and 128 GB RAM. Do not run it directly in a login-node notebook.

1b. Train the encoder (12-fold leave-chromosome-out)

python train_seqEncoder.py --cell K562 \
    --data-csv batch_output/K562/links/K562_peak_5bins_around_summit_activity_sequence.csv \
    --loss l1kl --batch-size 256 --folds 1 \
    --output-dir results/seqencoder/K562_repro --epochs 50

# all 12 folds via SLURM
CELL=K562 OUTPUT_DIR=results/seqencoder/K562_repro \
  sbatch slurm/train_seqencoder_12fold.slurm

The direct command is a one-fold inspection run. Use the array for the pooled 12-fold metric.

Recipe: 5 bins at summit ±192·{−2..2} (256 bp windows), Activity = sqrt(H3K27ac_RPM · DNase_RPM), target log2(0.1 + Activity), L1KL loss, batch 256.

1c. Evaluate

# Default predictions: single reverse strand (~0.734 for pinned K562 narrowPeak)
python evaluate.py encoder --pred_dir results/seqencoder/K562_repro

# Headline protocol: forward + reverse-complement averaging (~0.740), in a fresh directory
CELL=K562 \
DATA_CSV=./batch_output/K562/links/K562_peak_5bins_around_summit_activity_sequence.csv \
CKPT_DIR=./results/seqencoder/K562_repro/checkpoints \
OUTPUT_DIR=./results/seqencoder/K562_repro_fwdRC \
  sbatch slurm/eval_seqencoder_fwdrc.slurm
python evaluate.py encoder --pred_dir results/seqencoder/K562_repro_fwdRC

Do not mix reverse-only and fwd+RC prediction files in one directory.

Report the pooled out-of-fold Pearson R (concatenate all 12 folds → one R). Targets:

H1 HepG2 K562 HUVEC NHEK GM12878
0.820 0.743 0.740 0.742 0.677 0.617

To skip training, download the pretrained encoders from JiecongLin/EPInformer-pipeline.

Clone this wiki locally