ContextTAD is a deep-learning TAD caller that learns boundary evidence from broader local Hi-C windows that capture TAD-scale structural context. Instead of treating boundary prediction as an isolated per-bin classification problem, ContextTAD uses a context-aware representation to produce left- and right-boundary tracks that are explicitly optimized for downstream TAD assembly.
Additional external tools required by some evaluation/plotting scripts:
Rscript (for structural protein enrichment)
coolpup.py (for coolpup pileups)
pyGenomeTracks (for genome track visualizations)
Data preparation
The full processed dataset is too large to keep in the Git repository. The expected layout, array format, and preprocessing inputs are documented in 0-data/README.md.
Note: Most processed resources are available from Zenodo. Raw .mcool files should be downloaded from the 4DN Data Portal.
The data sourcing follows the resources described by RefHiC.
How to run (step by step)
The workflow is deliberately separated into data preparation, training,
inference/TAD construction, and evaluation. Run commands from the repository
root unless stated otherwise.
Step 1: prepare training and inference arrays
Build the GM12878 windows after configuring the raw Hi-C and genomic-track
paths required by the preprocessing scripts:
The command will create the seven coverage directories, shared DP-refined labels,
and window_list.json under TAD_DATA_DIR. To process only a subset of the
coverage levels, use one of the following mutually exclusive options:
bash
1# Build only the 4000M arrays.2python 1-prepare_data/step2_prepare_labels/scripts/prepare_data.py --only-4000M
34# Build all downsampled arrays while reusing an existing 4000M directory.5python 1-prepare_data/step2_prepare_labels/scripts/prepare_data.py --skip-4000M
Build K562 or IMR90 arrays for cross-cell inference with:
Here, --mcool selects the 5-kb matrix, --out_data_dir is the destination
for the processed windows, and --coverage_tag is the identifier written into
the generated metadata. Replace K562 with IMR90 for the second cell line.
Step 2: train the base model
The base experiment uses O/E inputs, a diagonal radius of 50 bins, and random
coverage sampling for both training and validation.
--checkpoint accepts a checkpoint produced in Step 2 or downloaded from
Hugging Face. --gpu-id selects the inference device, and --run-id names the
output directory.
This stage writes chromosome-level boundary tracks, FDR-selected pair
candidates, postprocessing statistics, and final BED files under
2-training/step2_infer_decode/outputs/<run_id>/.
Step 4: infer K562 and IMR90 TADs (optional)
Cross-cell inference uses the same checkpoint and decoder:
--data-root must contain the processed K562/ and IMR90/ array
directories. If omitted, the script uses the default location documented in
0-data/README.md.
Step 5: evaluate the predictions
Evaluate the main GM12878 and cross-cell results against the reference callers:
--gm12878-beds refers to the seven-coverage output from Step 3, while
--othercell-beds refers to the K562/IMR90 output from Step 4.
--run-histone enables the histone permutation test, and
--run-coolpup enables aggregate pileup analysis. Omit either flag to skip that
optional experiment. TAD-size statistics are always computed because they only
require the 250M BED files.
Evaluate one ContextTAD variant on the core GM12878 experiments with:
This lightweight route runs exp1, exp3, exp4, and exp6 without requiring
other-cell data, histone tracks, or .mcool files.
Evaluation experiment catalog
Experiment
Analysis
Main manuscript use
exp1_tadnum_ctcf_chiapet
250M CTCF ChIA-PET-supported L0/L1+ TAD counts
Figure 2b
exp2_struct_protein
CTCF, RAD21, and SMC3 boundary enrichment
Figure 2c
exp3_tadb_left_ctcf_chipseq
Left-boundary CTCF ChIP-seq support
Figure 2d
exp4_tadb_right_ctcf_chipseq
Right-boundary CTCF ChIP-seq support
Figure 2e
exp5_coolpup
Aggregate TAD pileups
Figure 5
exp6_tadnum_ctcf_chiapet_downsample
Seven-coverage TAD counts and CTCF support
Figure 3
exp7_othercell_tadnum_ctcf_chiapet
K562/IMR90 CTCF ChIA-PET support
Figure 4
exp8_othercell_both_ctcf_chipseq
K562/IMR90 directional boundary support
Figure 4
exp9_tad_size
250M TAD-size distribution and median ranking
Figure 2a
exp10_histone_modification
H3K27me3/H3K36me3 contrast permutation test
Figure 2f
exp11_pairscore_structure
Pair-score quartile pileups, boundary insulation, and representative regions
Figure 6
Each directory under 3-evaluation/common/ contains its executable entry point
and a DATA_REQUIREMENTS.md file describing the required inputs and metric.
Run the two additional Figure 2 analyses independently with:
EVAL_DATA_ROOT supplies the reference callers and benchmark tracks.
RSCRIPT_BIN and BEDTOOLS_BIN may be omitted when both commands are already
available on PATH.
Run the Figure 6 structural characterization independently because it requires
both final calls and the scored raw candidates from the same 4000M inference
run:
This produces the pair-score quartile pileups, left/right insulation profiles,
three representative genomic regions, and fig6_final.{png,pdf}. See
exp11_pairscore_structure/DATA_REQUIREMENTS.md
for exact formats.
Step 6: run the complete pipeline with one command
The shortest command trains on GPU 0, infers on GPU 0, and runs the core
GM12878 evaluation suite:
--train-gpus accepts one or more comma-separated devices, whereas
--infer-gpu selects one inference device. --all-exps enables other-cell
inference and the ten standard benchmark workflows. Figure 6 remains a
standalone analysis because it additionally consumes scored raw candidates and
genome-track files. The full-pipeline output contains symlinks to stage-specific
products; model weights remain only under 2-training/step1_train/outputs/.
Step 7: run ablation experiments
All ablations retain the base architecture and optimization settings unless
explicitly changed. Each wrapper accepts the same arguments as
run_train_base.sh: