Code of the paper. About two million SNVs, sampled without regard to their associations, are described by their CADD v1.7 annotations and labeled for four traits (BMI, systolic blood pressure, Crohn's disease, coronary artery disease) from one GWAS per trait. A causal graph among the traits is estimated from the literature with a retrieval-augmented language model, and a Causal Concept Bottleneck Model (C²BM) built on that graph predicts the association of each variant with each trait. It is compared with black-box baselines, with and without the labels of the parent traits supplied at test time, and its edge-specific weights are read to tell edges whose child is mostly driven by the parent from edges that only shift it, against control edges toward prostate cancer.
| Folder | Content | Details |
|---|---|---|
data_prep/ |
Dataset construction: summary statistics, variant sampling, labels, CADD annotation, five- and four-trait files | data_prep/README.md |
graph/ |
Causal graph discovery (prompts, the model's answers, vote assembly), the graph G and the three control graphs, tables of Appendix B | graph/README.md |
main.py, conf/, src/ |
Models and training (PyTorch Lightning + Hydra): C²BM, Bayesian network, single-task, multi-task, Parents and All-traits MLPs | below |
experiments/ |
Cross-validation splits and the queue of every training run of the paper | below |
analysis/ |
Every table and figure of the paper from the training runs | below |
paths.py |
The directory layout shared by all scripts |
Data, splits and outputs are not in the repository. They live in one working directory, CBM_WORKDIR
(default ./workdir; see paths.py):
$CBM_WORKDIR/raw/ downloaded inputs (summary statistics, CADD annotation, 1000 Genomes EUR panel)
$CBM_WORKDIR/data/ datasets built by data_prep/
$CBM_WORKDIR/cache/ stored cross-validation splits
$CBM_WORKDIR/outputs/paper/ training runs, analysis reports, paper/tables and paper/images
conda env create -f environment.yaml
conda activate cbm_genomics
export CBM_WORKDIR=/path/to/workdir # optional, default ./workdirTraining uses one GPU (the queue runs several jobs side by side). The evidence table of
Appendix B (graph/evidence/supp_refs.py) also needs tectonic.
All commands run from the repository root.
1. Dataset (see data_prep/README.md; the CADD annotation of the sampled variants is an external step):
bash data_prep/0_download.sh
python data_prep/1_select_variants.py
# CADD v1.7 annotation of data/variants/sample_snp_list.tsv -> raw/annotation/
python data_prep/2_match_cd_study.py
python data_prep/3_make_labels.py
python data_prep/4_build_dataset.py
python data_prep/5_four_traits.py2. Causal graph. graph/G.csv and the control graphs are in the repository. To rebuild G from the saved answers
of the language model: python graph/discovery/assemble_dag.py (see graph/README.md).
3. Splits. Ten-fold cross-validation over genomic blocks of 5 Mb (and 1 Mb, 10 Mb for the ablation): the blocks are assigned to the folds once, and fold s (seed s) is the test set of run s, fold s+1 its validation set.
bash experiments/prepare_splits.sh4. Training. 25 jobs of ten folds each: the six models of the reference setting, the C²BM and Parents MLP of the three control edges, and the ablations.
python experiments/queue.py --list # jobs and progress
python experiments/queue.py # runs everything (resumable)A single job by hand, e.g. C²BM on fold 1:
python main.py hydra.sweep.dir=workdir/outputs/test data=four_traits cache=four_traits_5mb graph=G.csv \
hydra.sweeper.grid_params.model=c2bm hydra.sweeper.grid_params.seed=1 rand_int=1.05. Tables and figures into $CBM_WORKDIR/outputs/paper/paper/{tables,images}:
bash analysis/make_paper.sh| Paper | Script | Training runs |
|---|---|---|
| Fig. 2, label patterns | analysis/fig_label_patterns.py |
(labels only) |
| Table 2, AUROC and AUPR | analysis/table_performance.py |
main/* |
| Table 3, edges | analysis/annotation_scores.py, analysis/table_edges.py |
main/c2bm, main/blackbox, controls/* |
| Fig. 3, P1 against P0 | analysis/fig_edge_density.py |
main/c2bm, controls/*/c2bm |
| Table 4, loci | analysis/table_loci.py |
main/c2bm, controls/*/c2bm |
| Tables A1-A2, ablations | analysis/table_ablations.py |
ablations/* |
| Table A3, slopes by training regime | analysis/table_slopes_by_regime.py |
main/{c2bm,parents_mlp}, ablations/*, controls/* |
| Table A4, Mendelian randomization | analysis/mendelian_randomization.py |
(summary statistics only) |
| Sect. 3.2, proximity check | analysis/proximity_check.py |
(splits only) |
| Appendix B, prompt, votes and evidence | graph/evidence/evidence_table.py, graph/evidence/supp_refs.py |
(graph discovery) |
| Name in the paper | model= |
Uses the graph | Training of the reference setting |
|---|---|---|---|
| C²BM | c2bm |
yes | teacher forcing 1 (rand_int=1.0) |
| Bayesian network | standard_bn |
yes | teacher forcing 1 |
| Parents MLP | parents_mlp |
yes | teacher forcing 1 |
| All-traits MLP | masked_all |
levels only | every other label revealed (label_reveal_prob=1.0) |
| Multi-task MLP | multitask |
no | |
| Single-task MLPs | blackbox |
no |
Every network that reads the annotations has two hidden layers of 176 units; the loss uses inverse-frequency class
weights (conf/config.yaml). At test time the labels of the traits up to each topological level of G are supplied
(interventions), and each run writes, besides the metrics, per-variant exports used by the analysis: the edge
weights α, and P(child = 1 | do(parent = 0/1)) for every edge.
MIT (see LICENSE).