Built with Claude — Life Sciences
Separating the hemagglutinin positions that causally drive antigenic escape from the linked positions that merely ride along with them — across three hemagglutination-inhibition datasets, with an interpretable B-spline Kolmogorov–Arnold Network for prediction.
This project was built as part of the Claude Science Hackathon.
A reproducible research notebook. Run top-to-bottom (Kernel → Restart & Run All) to regenerate every table and
figure from the raw data repository shipped alongside this notebook.
Identifying specific hemagglutinin (HA) mutations that causally alter antibody recognition remains a significant challenge because dense viral phylogenies tightly link functional escape drivers with passenger mutations. While sequence-based models predict antigenic distance with high accuracy, they often conflate the evolutionary dynamics of population-level sweeps with the mechanistic physics of antibody-binding disruption. To address this ambiguity, we define the target estimand as a provenance-independent, type-level interventional contrast at the antigen–antibody interface, characterizing linkage-driven resolution loss as an intrinsic structural feature of observational serology. We analyze two H3N2 hemagglutination-inhibition (HI) datasets by collapsing co-evolving positions and applying target-oriented causal discovery algorithms (PC, GES, FCI) prioritized by a 200-resample bootstrap stability framework. This is paired with an interpretable B-spline Kolmogorov–Arnold Network (KAN) to evaluate per-position response curves and capture second-order position-by-position epistasis. Under matched-fold cross-validation, the first-order KAN performs slightly below black-box gradient boosting (lower $R^2$ by $\approx 0.025\text{--}0.028$; Wilcoxon $p < 10^{-5}$); a second-order KAN mitigates most of this performance gap under a 5-fold validation protocol. Cross-method convergence evaluates agreement across causal and association-based frameworks, identifying candidate drivers that overlap classical antigenic sites A and B. In the VHID dataset, convergent signals localize to mature H3 positions 156 and 189, where position 156 exhibits characteristics consistent with a stable hitchhiker (high frequency, small non-robust effect) and position 289 emerges as a doubly-robust candidate. In the Bedford dataset, convergent positions include mature 133, 158, and 189, with 158 demonstrating sensitivity to feature encoding. Under cluster resampling, mature position 189 remains the most robust signal across both datasets. Backdoor-adjusted effect sizes systematically shrink relative to marginal associations, consistent with the mitigation of phylogenetic confounding, though a Shipley d-separation test rejects a simplified sink-star structure. Finally, rigorous grouped (leave-serum-out) cross-validation establishes a baseline generalization accuracy (median $R^2 \approx 0.615$ for VHID, $\approx 0.498$ for Bedford). This work establishes a stability-ranked, confounding-audited, and linkage-aware feature-selection framework that systematically isolates candidate biophysical drivers of antigenic drift from observational data.
Influenza viruses continuously evolve under selective pressure from population immunity, accumulating substitutions in surface glycoproteins that facilitate immune escape. This process of antigenic drift causes circulating strains to diverge from those recognized by prior immunity, reducing vaccine effectiveness when selected vaccine strains mismatch circulating variants. This divergence is quantified as antigenic distance, and measuring it accurately is essential for evaluating vaccine efficacy and optimizing antigen selection. Traditionally, antigenic distance is determined via the hemagglutination-inhibition (HI) assay, where lower cross-titers indicate greater immune escape. While frameworks like antigenic cartography have been foundational in mapping these titers, generating the required serum panels is logistically demanding, costly, and prone to inter-laboratory variation. This bottleneck has motivated sequence-based predictive models designed to forecast HI titers directly from hemagglutinin (HA) sequences.
However, while machine learning approaches achieve high predictive accuracy, they frequently operate as black boxes, identifying predictive correlates rather than isolating the underlying causal drivers of immune escape. Because influenza strains share a dense phylogenetic history, HA positions exhibit strong linkage disequilibrium. Consequently, passenger mutations riding along with functional escape drivers appear as predictive as the drivers themselves. To resolve this ambiguity, this study introduces a precise conceptual reframing. Disentangling the drivers of antigenic drift requires separating the evolutionary question (which substitutions were favored by natural selection and swept the population) from the mechanistic question (which substitutions physically disrupt antibody recognition when introduced into a given strain background). This study focuses explicitly on the second, mechanistic question. We define our target estimand not as a historical claim about viral evolution, but as a provenance-independent, type-level interventional contrast at the antigen-antibody interface. Ideally, this contrast reflects a controlled biophysical experiment: introducing a single residue change at position $p$ in reference virus B to match virus A, while holding the rest of the protein sequence fixed, and measuring the resulting change in HI titer. The magnitude of this effect depends strictly on the structural footprint and local chemistry, independent of whether the mutation arose via positive selection or neutral drift. While evolutionary provenance does not dictate the biophysical effect itself, it heavily constrains our capacity to identify it from observational data. The selective history of the virus introduces systematic phylogenetic confounding, clustering distinct mutations into tightly linked blocks. Acknowledging this architecture allows us to treat linkage-driven resolution loss as an inherent structural characteristic of observational HI data, which must be formally accommodated within the analytical pipeline.
Related works. Antigenic cartography revealed the punctuated cluster structure of H3N2 drift by embedding HI tables into low-dimensional maps, and subsequent models unified antigenic and genetic evolution within joint phylogenetic frameworks. Modern sequence-based predictors forecast cross-immunity between drifted strains from sequence data with high accuracy. While these approaches are primarily predictive or descriptive, they do not explicitly learn causal structure over individual HA positions with quantified stability. The antigenic sites encompassing these positions were originally defined structurally and serologically (sites A through E on the H3 head) and subsequently refined via substitution resolution and deep mutational scanning escape maps. Our approach evaluates the extent to which these positions can be recovered directly from HI titers without structural priors. This framework complements influenza fitness models by isolating per-position candidate drivers and builds on intelligible-model literature for pairwise interactions.
Our contributions. We combine several ingredients that are not usually applied together for HI data to build a conservative, interpretable, and self-audited feature-selection pipeline. First, we implement linkage collapse with target-oriented causal discovery: we merge near-deterministic co-evolving positions into representative loci, then learn the direct-cause neighborhood of the HI target using PC, GES, and FCI algorithms, ranking every candidate by 200-resample bootstrap stability. Second, we deploy a genuine B-spline Kolmogorov–Arnold Network (KAN), an interpretable non-linear predictor whose learned per-position response curves are directly inspectable, and extend it to second order to capture and visualize position-by-position epistasis. Third, we assess cross-method convergence, treating it honestly as agreement between one causal screen and three correlated association screens (the KAN, gradient boosting, and univariate association) rather than four independent lines of evidence; positions flagged across these screens form our strongest candidate-driver claims. We then subject those claims to a battery of audits: a permutation calibration showing that the Fisher-Z conditional-independence test holds near-nominal size on our binary, left-censored data; a cluster (by-virus and by-serum) bootstrap that separates a robust convergent core from an over-optimistic stability tier; a left-censoring sensitivity analysis of the adjusted effect sizes; and a token-level identifiability audit of the discovered structure. Throughout, we estimate backdoor-adjusted per-position effect sizes but report them as partial-regression coefficients, because the baseline adjustment assumptions are rejected in-sample.
The remainder of the notebook is organized as an executable paper. Section 2 (Methods) introduces the two H3N2 HI datasets and explains how their feature matrices are derived from the raw data. Section 3 (Results) then carries the analysis in full, each subsection stating how a step is performed, presenting its output, and interpreting it: the predictive benchmark and its leakage-free cross-validated comparison (§ 3.1–3.2); target-oriented causal discovery together with the pre-collapse linkage block sizes, a permutation calibration of the Fisher-Z independence test, and a cluster bootstrap of candidate stability (§ 3.3), followed by the discovered dependency structure (§ 3.4); the interpretable B-spline KAN and its second-order epistasis extension (§ 3.5–3.6); cross-method convergence (§ 3.7); backdoor-adjusted effect sizes and their sensitivity to titer left-censoring (§ 3.8); three DAG-validation tests (§ 3.9); and a continuous per-position encoding that re-examines the titer Markov blanket (§ 3.10). The narrative moves from how much of the HI signal is learnable and how non-linear it is, through the discovered candidate drivers and their audited dependency structure, to per-position effect sizes and the validation — and in-sample rejection — of the discovered graph. Section 4 (Conclusion) interprets the convergent positions biologically, states plainly where residue-level attribution is limited and what assumptions the causal framing rests on, and looks ahead. Section 5 lists references.
This section outlines the data structure and feature extraction protocols. Analytical procedures are described alongside their respective outputs in the Results section to maintain context. Configuration parameters (random seeds, linkage thresholds, bootstrap counts, and tier cutoffs) are centralized in src/analysis.py. Computationally intensive steps, such as the causal bootstrap and repeated $k$-fold cross-validation, are managed via environment flags and are defaulted to load precomputed results to ensure reproducibility.
The study evaluates two H3N2 virus $\times$ reference-strain HI panels. Each dataset is derived from previously published works: the VHID panel is derived from the DPCIPI dataset (Du et al., 2023), and the Bedford dataset is obtained from Bedford et al. (2014). While both panels represent H3N2 HI datasets, they differ in metadata completeness. The Bedford H3N2 panel is curated from Bedford et al. (2014), GenBank accessions, and isolate collection years, all of which are fully populated. We analyze the two panels as independent replications of the same underlying structure-learning task rather than assuming a calibrated joint assay protocol. The reported positions correspond to mature H3 residue numbers. Feature matrices are indexed by HA1 alignment columns, which map to mature numbers via fixed per-panel offsets. The VHID reference is gapless from mature Q1, yielding a 0-residue offset. In contrast, the Bedford H3N2 alignment contains a 9-residue signal-peptide prefix and an internal gap at column 17; thus, mature Q1 maps to column 10, and for all reported positions ($\ge \text{column 143}$), $\text{mature residue} = \text{column} - 10$. This mapping was verified against column-wise consensus references and gapless VHID references to ensure structural interpretability.
The sequence data is formatted as per-position HA1 feature matrices under two distinct encodings: Binary Mismatch Encoding: Sets a position to 1 when the virus and reference residues differ at that HA1 alignment position and 0 otherwise; this serves as the primary input for causal discovery. Grantham Encoding: Quantifies the physicochemical distance between residue pairs based on Grantham (1974) metrics (gap-aware); this is utilized for predictive modeling and KAN response curves.
The target variable is modeled as $\log_2(\text{HI_titer})$. To ensure complete pipeline traceability, feature matrices are regenerated from raw virus $\times$ reference pair tables using the repository's build scripts (scripts/build_vhid_matrices.py, scripts/build_bedford_matrices.py). Matrix identities were verified against shipped derivatives using SHA-256 checksums. Feature spaces are evaluated independently per panel to prevent artifacts from lineage-specific HA1 trimming.
So that the study starts from raw data rather than shipped derivatives, we regenerate
the feature matrices from the cleaned virus × reference pair tables using the
repository's own build scripts (scripts/build_vhid_matrices.py,
scripts/build_bedford_matrices.py), which depend only on numpy and pandas. Running
them here makes the matrices provably the shipped ones (verified by SHA-256).
| dataset | source | n_pairs | HA1_positions | variant_positions | log2_titer_mean | log2_titer_std | |
|---|---|---|---|---|---|---|---|
| 0 | vhid_HA1 | VHID H3N2 (Du et al. 2023) | 2751 | 329 | 102 | 7.256 | 2.861 |
| 1 | H3N2 | Bedford H3N2 (Bedford et al. 2014) | 7808 | 329 | 312 | 7.770 | 2.286 |
Each dataset is internally row-aligned across its binary matrix, Grantham matrix, and cleaned pair table. Feature spaces are comparable within a lineage but not across lineages (each lineage was HA1-trimmed against its own reference), so we analyze the two datasets independently and compare only which HA positions emerge.
Before any modeling we look at what is being predicted. The panel below shows the distribution of log2 HI titer in each dataset; its spread sets the scale against which every R² reported in the Results should be read.
After establishing baseline performance metrics in Section 3.1, we describe the generalization capacity and error bounds of our sequence-to-antigenic maps under strict grouped and temporal cross-validation protocols in Section 3.2. In Section 3.3, we outline the structural causal discovery pipeline, linkage-collapse dynamics, and test calibrations. In Section 3.4, we analyze the resulting parent dependency structures and check for intermediate mediation. We then present our interpretable modeling frameworks, detailing the 1-D response curves of the first-order B-spline KAN in Section 3.5 and the bivariate tensor-product surfaces for capturing epistasis in Section 3.6. In Section 3.7, we evaluate the cross-method convergence of our feature screens and verify non-linear omissions. Finally, we describe the estimation of backdoor-adjusted effect sizes and driver-hitchhiker differentiation in Section 3.8, the global d-separation validation tests in Section 3.9, and the continuous physicochemical encoding replication in Section 3.10.
To establish performance baselines and characterize the mathematical properties of the antigenic signal, we evaluated the held-out test $R^2$ (20% split) for the top-performing single-position (max univariate $R^2$), LASSO, Ridge, and XGBoost models. The predictive performance across both datasets consistently follows the ordering:
$$ \begin{aligned} &\text{XGBoost} \gtrsim \text{LASSO} \approx \text{Ridge} \\ &\qquad \gg \text{Best Single Position}. \end{aligned} $$
| dataset | n | n_features | univ_sig | univ_best_singleR2 | LASSO_testR2 | Ridge_testR2 | XGB_testR2 | |
|---|---|---|---|---|---|---|---|---|
| 0 | vhid_HA1 | 2751 | 102 | 78 | 0.443 | 0.751 | 0.754 | 0.862 |
| 1 | H3N2 | 7808 | 312 | 185 | 0.205 | 0.509 | 0.522 | 0.618 |
The substantial performance delta between the single-position baseline and multivariable models indicates that the antigenic signal is distributed across multiple positions. Furthermore, the performance margin achieved by XGBoost over linear models suggests the presence of underlying non-linear and interaction structures, motivating the deployment of the KAN framework detailed in Section 3.5.
To provide robust uncertainty estimates and ensure rigorous model comparison, all models were evaluated under an identical $5 \times 4$ repeated $k$-fold cross-validation protocol using matched folds. XGBoost parameters were optimized via early stopping, performed strictly on an inner validation split carved from the training fold, thereby protecting the test fold from data leakage. Models are compared using a matched-fold paired test (Wilcoxon signed-rank test on the 20 per-fold differences) rather than evaluating confidence-interval overlaps.
While a paired test on random splits effectively differentiates model architectures, random partitioning allows identical viruses and reference antisera to recur across training and testing folds. This pair-level recurrence can artificially inflate performance metrics because models can memorize strain-specific profiles rather than generalizing to unseen variants. We treat random-split metrics purely as a baseline and leverage leakage-free grouped cross-validation as our primary generalization metric.
Under the random-split baseline, XGBoost yields the highest cross-validated $R^2$ across both datasets (VHID: 0.845, Bedford: 0.613), followed closely by the KAN (VHID: 0.820, Bedford: 0.585). The matched-fold paired test confirms that the performance gap is statistically robust: the KAN trails XGBoost by 0.025 $R^2$ on VHID (Wilcoxon $p \approx 2 \times 10^{-6}$) and by 0.028 on Bedford ($p \approx 6 \times 10^{-6}$). The KAN's primary utility lies in its additive interpretability, recovering most of the tree-based model's performance while explicitly exposing per-position response curves.
To determine true generalization performance on unseen strains, we executed grouped cross-validation via leave-virus-out and leave-serum-out protocols.
| dataset | scheme | n_groups | method | folds | median_R2 | min_R2 | max_R2 | |
|---|---|---|---|---|---|---|---|---|
| 0 | vhid_HA1 | leave_virus_out | 246 | LASSO | 5 | 0.736 | 0.685 | 0.757 |
| 1 | vhid_HA1 | leave_virus_out | 246 | Ridge | 5 | 0.728 | 0.626 | 0.762 |
| 2 | vhid_HA1 | leave_virus_out | 246 | XGBoost | 5 | 0.821 | 0.795 | 0.862 |
| 3 | vhid_HA1 | leave_virus_out | 246 | KAN | 5 | 0.794 | 0.746 | 0.830 |
| 4 | vhid_HA1 | leave_serum_out | 45 | LASSO | 5 | 0.596 | 0.420 | 0.747 |
| 5 | vhid_HA1 | leave_serum_out | 45 | Ridge | 5 | 0.566 | 0.391 | 0.743 |
| 6 | vhid_HA1 | leave_serum_out | 45 | XGBoost | 5 | 0.615 | 0.435 | 0.790 |
| 7 | vhid_HA1 | leave_serum_out | 45 | KAN | 5 | 0.589 | 0.292 | 0.744 |
| 8 | H3N2 | leave_virus_out | 304 | LASSO | 5 | 0.451 | -0.123 | 0.511 |
| 9 | H3N2 | leave_virus_out | 304 | Ridge | 5 | 0.444 | -12.525 | 0.494 |
| 10 | H3N2 | leave_virus_out | 304 | XGBoost | 5 | 0.547 | 0.442 | 0.590 |
| 11 | H3N2 | leave_virus_out | 304 | KAN | 5 | 0.501 | 0.367 | 0.541 |
| 12 | H3N2 | leave_serum_out | 191 | LASSO | 5 | 0.429 | 0.299 | 0.531 |
| 13 | H3N2 | leave_serum_out | 191 | Ridge | 5 | 0.473 | 0.284 | 0.510 |
| 14 | H3N2 | leave_serum_out | 191 | XGBoost | 5 | 0.498 | 0.378 | 0.523 |
| 15 | H3N2 | leave_serum_out | 191 | KAN | 5 | 0.438 | 0.355 | 0.479 |
The performance metrics degrade under grouped cross-validation, confirming that random-split protocols are systematically influenced by strain/serum recurrence. Under the strict leave-serum-out protocol, XGBoost performance settles at a median $R^2$ of 0.615 on VHID and 0.498 on Bedford. These grouped cross-validation medians represent our honest predictive headlines for sequence-to-antigenic maps operating outside the training distribution.
Since the Bedford H3N2 dataset includes temporal metadata (1968–2010), we evaluated forward-in-time generalization using an expanding window strategy: training on all pairs up to year $t$ and testing on the subsequent 5-year block.
| train ≤ | test window | n_test | Ridge R² | XGBoost R² |
|---|---|---|---|---|
| 1990 | 1991–1995 | 927 | −4.70 | 0.43 |
| 1995 | 1996–2000 | 369 | 0.35 | 0.60 |
| 2000 | 2001–2005 | 3636 | −3.73 | −0.37 |
| 2005 | 2006–2010 | 1297 | −0.59 | 0.25 |
Forward-in-time generalization displays notable instability; in the 2001–2005 test window, XGBoost performance drops to $R^2 = -0.37$. This highlights a primary boundary of transportability: models trained exclusively on past seasons struggle to reliably predict titers for future antigenic clusters when drift crosses major structural boundaries that are absent from the training history.
We tested whether encoding substitutions by their physicochemical property shifts (a 12-property $L_2$ scalar) rather than by raw amino acid identity enhances temporal transportability. Mapping unseen substitutions to their local shifts in charge, volume, or hydrophobicity could enable the model to generalize based on biophysical similarity.
Our empirical results do not support this hypothesis. Across the unbiased XGBoost models, the mean future $R^2$ across all test windows was 0.19 for the binary encoding, 0.22 for the Grantham distance, and 0.18 for the 12-property $L_2$ vector. The single-scalar Grantham distance yielded the most stable performance across windows, undermining the assumption that higher-dimensional property vectors improve generalization to distribution shifts. All three encodings systematically fail during the 2001–2005 window, confirming that substitution-based representations do not fully capture major shifts in antigenic distribution.
Consequently, the utility of property encodings rests on their interpretability (Section 3.10) rather than cross-cluster predictive transport.
We model the HI titer as a downstream causal sink: HA sequence variations cause variations in titer, orienting all feature-to-target edges into the target variable. The direct-cause candidates are defined as the immediate parents of this target node.
The structural pipeline proceeds as follows
$$ \begin{aligned} \text{Power Filter} &\rightarrow \text{Linkage Collapse } (\vert{}\phi\vert{} \ge 0.8) \\ &\rightarrow \text{Constraint/Score Discovery } (\text{PC, GES, FCI}) \\ &\rightarrow \text{Bootstrap Stability Evaluation } (B=200). \end{aligned} $$
Linkage collapse is a critical prerequisite; near-deterministic co-evolution violates the faithfulness assumption and introduces structural singularities into constraint-based searches. Collapsing these blocks into single representative loci resolves these dependencies. Because causal claims apply to the entire co-evolving unit, we explicitly report block sizes throughout.
| dataset | variant_positions | loci_after_collapse | multi_position_blocks | residual_strong_pairs | |
|---|---|---|---|---|---|
| 0 | vhid_HA1 | 102 | 71 | 10 | 0 |
| 1 | H3N2 | 312 | 123 | 9 | 0 |
| position | bootstrap_freq | tier | PC | GES | FCI | block_size | |
|---|---|---|---|---|---|---|---|
| 0 | 156 | 1.000 | high | True | False | True | 1 |
| 1 | 189 | 1.000 | high | True | False | True | 1 |
| 2 | 289 | 0.955 | high | True | False | True | 1 |
| 3 | 158 | 0.950 | high | True | False | True | 1 |
| 4 | 144 | 0.505 | moderate | True | True | False | 1 |
| position | bootstrap_freq | tier | PC | GES | FCI | block_size | |
|---|---|---|---|---|---|---|---|
| 0 | 11 | 1.000 | high | True | False | n/a | 9 |
| 1 | 143 | 1.000 | high | True | True | n/a | 1 |
| 2 | 167 | 1.000 | high | True | True | n/a | 1 |
| 3 | 168 | 1.000 | high | True | True | n/a | 1 |
| 4 | 199 | 1.000 | high | True | False | n/a | 1 |
| 5 | 203 | 0.995 | high | True | False | n/a | 1 |
| 6 | 288 | 0.815 | moderate | True | False | n/a | 1 |
| 7 | 200 | 0.650 | moderate | True | False | n/a | 1 |
Following linkage collapse, residual strong locus pairs ($\vert{}\phi\vert{} \ge 0.9$) drop to zero in both datasets. PC and GES algorithms were executed on the collapsed feature space, with selection frequency across 200 bootstrap resamples used to categorize candidates into stability tiers: High Confidence ($\ge 0.9$) and Moderate Confidence ($0.5\text{--}0.9$). Under standard i.i.d. resampling, the High Confidence parent sets encompass:
Linkage collapse groups positions co-evolving at $\vert{}\phi\vert{} \ge 0.8$ into representative units. The distribution of these blocks is heavy-tailed: while the majority of positions remain singletons (61/71 in VHID; 114/123 in Bedford), a few large blocks absorb substantial portions of the feature space.
In the Bedford H3N2 dataset, the largest pre-collapse block spans 88 positions (representative alignment column 181), the second spans 55 positions (column 90), and the third spans 26 positions (column 50). These large, clade-linked units absorb numerous head positions, indicating that purely observational methods cannot structurally disentangle individual residue effects within these blocks. Conversely, the VHID dataset exhibits less linkage; its largest block encompasses only 14 positions (column 173), allowing its collapsed loci to map more directly to individual amino acid changes.
| dataset | n_blocks | positions | singletons | multi_position_blocks | largest_block | second_block | |
|---|---|---|---|---|---|---|---|
| 0 | VHID H3N2 (Du et al. 2023) | 71 | 102 | 61 | 10 | 14 | 4 |
| 1 | Bedford H3N2 (Bedford et al. 2014) | 123 | 312 | 114 | 9 | 88 | 55 |
| dataset | rank | rep_align_col | rep_mature_H3 | block_size | |
|---|---|---|---|---|---|
| 0 | VHID H3N2 (Du et al. 2023) | 1 | 173 | 173 | 14 |
| 1 | VHID H3N2 (Du et al. 2023) | 2 | 25 | 25 | 4 |
| 2 | VHID H3N2 (Du et al. 2023) | 3 | 80 | 80 | 4 |
| 3 | Bedford H3N2 (Bedford et al. 2014) | 1 | 181 | 171 | 88 |
| 4 | Bedford H3N2 (Bedford et al. 2014) | 2 | 90 | 80 | 55 |
| 5 | Bedford H3N2 (Bedford et al. 2014) | 3 | 50 | 40 | 26 |
Conditional independence decisions within the causal pipeline rely on the Pearson partial-correlation Fisher-Z test (fisherz). Because the data consists of binary mismatch features and left-censored titers, the multivariate normality assumption is violated, making the operating threshold ($\alpha = 0.01$) nominal.
To evaluate true type-I error rates, we constructed an empirical null distribution by permuting the $\log_2$ titer column, thereby disrupting feature-to-target relationships while preserving feature-to-feature correlation structures. We evaluated 10,000 independent tests across conditioning sizes ${0, 1, 2, 3}$ using three distinct encodings: VHID collapsed binary loci, VHID continuous $L_2$ physicochemical distances, and a top-40 screened subset of Bedford binary loci.
At the target operating point ($\alpha = 0.01$), the empirical false-positive rates align closely with nominal expectations, landing within their respective 95% Clopper–Pearson intervals:
At a looser threshold ($\alpha = 0.05$), marginal deviations occur (VHID binary: 0.054, Bedford binary: 0.045, continuous: 0.051). These results indicate that the Fisher-Z test maintains controlled size at the target operating threshold ($\alpha = 0.01$), preventing inflation of the false-positive edge rate on these data.
The 200× selection-stability bootstrap above resamples HI pairs independently. But VHID's 2751 pairs derive from only 246 viruses crossed with 45 reference sera, and the grouped cross-validation in §3.2 shows this clustering is decisive (held-out R² drops ~0.23 when folds respect virus grouping). Resampling pairs i.i.d. treats correlated pairs as independent draws and can therefore overstate how reproducibly a position is selected.
To test this directly we re-ran the identical collapse → PC parent-selection routine (src/causal_helpers.py), changing only the resampling unit: instead of drawing pairs, we draw whole viruses with replacement (leave-virus-out clusters), and separately whole reference sera. Everything else — linkage collapse, the screened 50-locus node set, α=0.01, terminal-target background knowledge — is held fixed, so the comparison isolates the effect of respecting clustering. All three schemes use B=200 on VHID.
Finding. The HIGH-stability set is not preserved under clustering. Under i.i.d. pairs it is {156, 158, 189, 289}; under virus clustering only {156, 189} remain HIGH (158 and 289 fall to moderate), and under serum clustering only {189, 289} remain HIGH (156 and 158 fall to moderate). Only mature 189 stays HIGH in all three schemes. Frequencies of the i.i.d.-HIGH parents move systematically downward toward the moderate range (mean change −0.04 under virus resampling, −0.12 under serum resampling; pos 158 falls from 0.95 to 0.69 under serum clustering) — i.e. the pipeline is less confident once pair correlation is accounted for, never more. The convergent-driver headline is unaffected in substance — 156 and 189 are the VHID convergent pair and both survive at least one clustering scheme, 189 survives both — but the four-position HIGH tier reported in §3.3 rests partly on i.i.d. resampling and should be read as an upper bound on selection confidence. The Bedford H3N2 cluster bootstrap is heavier (≈73 s per PC fit at 7808×50 vs ≈13 s for VHID, so a full 3×200 is ≈50 min CPU); it is left to the shipped i.i.d. run here and flagged as a recommended robustness check.
We map the learned relationships into the titer sink as a directed graph, where edge widths represent bootstrap stability. To evaluate whether the system operates as a strict star graph (parallel, mutually independent features directed into a common child) or exhibits intermediate dependencies, we performed a partial-correlation skeleton check across the parent nodes:
Our structural analysis shows that every parent node maintains a statistically significant direct association with the titer when conditioning on all other parents, indicating that the feature set contains no pure intermediates. However, the parent nodes are densely interconnected: we identify 5/10 significant parent-parent adjacencies in VHID and 21/28 in Bedford. The graph is therefore not a strict star. The observational data confirms strong structural dependencies among the causal parents. While the direction of these internal edges or the exact proportion of mediated vs. direct effects cannot be uniquely oriented without direct interventional data, this dense linear interdependence parallels the non-linear epistatic surfaces captured by our second-order networks.
To maintain predictive transparency without reverting to strict linear assumptions, we deployed a genuine B-spline Kolmogorov–Arnold Network (order-3 splines + SiLU residual), which optimizes learnable univariate functions along each network edge. This allows each first-layer connection to be characterized as an inspectable 1-D response curve: $f(\text{Grantham distance})$. Models were optimized using Adam, $L_1$ spline regularization, and early stopping on pinned random seeds to ensure numerical reproducibility. Feature importance is calculated as the standard deviation of each position's partial contribution evaluated strictly over the observed data distribution to avoid extrapolation artifacts.
The B-spline KAN implementation was validated on a synthetic additive function, recovering known functional forms and yielding an $R^2 \approx 0.99$. When applied to the empirical datasets, the KAN achieved predictive performance that tracked closely to gradient boosting, trailing by a small but stable margin under matched-fold cross-validation (Section 3.2). The learned per-position response curves across both datasets are predominantly monotone-decreasing with respect to Grantham distance, indicating that increasing physicochemical divergence maps directly to decreases in cross-titer (greater immune escape).
A comparison between depth-1 (additive) and depth-6 tree models indicates that a notable portion of the predictive signal depends on interaction effects, or epistasis. To capture these interactions within an interpretable framework, we extended the KAN to second order by incorporating bivariate tensor-product spline surfaces, $g(x_i, x_j)$, across an interaction pool composed of the causal parents and top predictive positions. Group-sparsity penalties were applied to prune inactive pairs systematically. Cross-validation was nested relative to pool selection, ensuring that interaction pools were selected strictly within training folds to prevent data leakage.
To verify whether pairwise terms sufficiently capture the non-linear signal, we computed an interaction-order ladder across tree models of increasing depth:
| dataset | KAN 1st-order | KAN 2nd-order | KAN 2nd (±SD) | 2nd folds | XGBoost (20-fold) | |
|---|---|---|---|---|---|---|
| 0 | vhid_HA1 | 0.820 | 0.851 | ±0.010 | 5 | 0.845 |
| 1 | H3N2 | 0.585 | 0.613 | ±0.018 | 5 | 0.613 |
| ≤1-way (depth 1) | ≤2-way (depth 2) | ≤3-way (depth 3) | ≤4-way (depth 4) | ≤6-way (depth 6) | |
|---|---|---|---|---|---|
| vhid_HA1 | 0.735 | 0.808 | 0.838 | 0.853 | 0.858 |
| H3N2 | 0.473 | 0.553 | 0.590 | 0.616 | 0.632 |
The structural dynamics diverge between the two panels:
While a third-order KAN could theoretically map these higher-order relationships, the exponential expansion of the parameter space reduces model interpretability. We treat the second-order KAN as a pragmatic baseline that visualizes the pairwise component. Evaluating the optimized tensor-product surfaces reveals clear biophysical patterns: synergistic escape regions (where co-occurring substitutions reduce titer beyond their additive expectations) and compensatory interaction surfaces.
To formally cross-examine the top KAN-nominated interactions, we fitted standard OLS interaction terms ($x_a \cdot x_b$) with HC3 robust standard errors, applying Benjamini–Hochberg (BH) correction alongside a non-parametric distance-correlation test:
We evaluated the alignment of our causal feature selection (bootstrap frequency $\ge 0.5$) against three distinct association screens: top-15 KAN features, top-15 XGBoost features (by gain), and top-15 univariate associations (by $R^2$).
Because the three association metrics are computed over identical feature spaces, they function as correlated screens rather than independent lines of evidence. Mutual alignment represents a multi-perspective validation of structural relevance rather than independent replication. In the Bedford panel, the causal discovery input was pre-screened using target association (filtering 123 loci to 60), meaning the univariate screen is mechanically related to the causal search input; the VHID panel (71 loci, unscreened) does not share this dependency.
Positions that consistently converge across all four independent and correlated screens represent our strongest candidate drivers:
Since our per-position features utilize a symmetric encoding (evaluating changes at an isolated column), the model cannot explicitly represent the gain or loss of N-linked glycosylation sequons ($\text{N-X-S/T}$ motifs, where $\text{X} \neq \text{P}$), which require a three-residue window. To incorporate this context, we mapped the convergent positions back to consensus HA1 sequences:
The primary causal selection loop relies on the Fisher-Z conditional independence test, which detects linear partial correlations. To verify whether functional features with purely non-linear dependencies were discarded, we re-tested positions flagged by $\ge 3$ predictive screens that exhibited low causal frequencies (Pattern-A positions) using the non-parametric Kernel Conditional Independence (KCI) test. We evaluated the null hypothesis: $$H_0: P \perp \text{HI_titer} \mid \text{Discovered Parents}$$
The results are summarized below (reporting the median $p$-values across 3 independent seeded runs on 1,000-row subsamples):
| dataset | screen_k | n_kci_rows | seconds | status | n_fisherz | n_kci | fisherz_parents | kci_parents | only_under_kci | only_under_fisherz | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | vhid_HA1 | 25 | 1000 | 180.2 | killed (> 180s — KCI-PC intractable at this sc... | 4 | NaN | pos144;pos156;pos158;pos189 | |||
| 1 | H3N2 | 25 | 1000 | 180.2 | killed (> 180s — KCI-PC intractable at this sc... | 7 | NaN | pos11;pos143;pos167;pos168;pos199;pos200;pos288 |
We evaluated the structural replication between the VHID and Bedford datasets by mapping discovered loci to shared mature H3 positions and calculating Jaccard similarity metrics against a 20,000-draw permutation null:
| set | observed J | shared positions | null mean | p |
|---|---|---|---|---|
| PC | 0.167 | 158, 189 | 0.035 | 0.062 |
| GES | 0.182 | 133, 276 | 0.035 | 0.051 |
| Bootstrap (freq≥0.5) | 0.182 | 158, 189 | 0.034 | 0.047 |
The structural overlap exceeds chance expectations across all sets, demonstrating stable structural replication. However, the specific positions driving this replication depend on the algorithm: constraint-based PC and the bootstrap selection replicate positions 158 and 189 (bootstrap $p=0.047$), whereas score-based GES localizes its cross-dataset intersection at positions 133 and 276.
If the target variable operates as a pure causal sink, the remaining selected parents could serve as a valid backdoor adjustment set to isolate a position's specific interventional effect. However, the d-separation goodness-of-fit test rejects the simple sink-star structure due to dense parent-parent adjacencies. This indicates that conditioning on co-parents can introduce confounding via unmodeled mediators or colliders. We therefore interpret these estimates as partial regression coefficients rather than as identified causal effects.
| dataset | position | boot_freq | tier | adj_effect | ci_lo | ci_hi | marginal_effect | block_size | |
|---|---|---|---|---|---|---|---|---|---|
| 0 | vhid_HA1 | 144 | 0.505 | moderate | -0.0113 | -0.0129 | -0.0096 | -0.0194 | 1 |
| 1 | vhid_HA1 | 156 | 1.000 | high | -0.0134 | -0.0170 | -0.0098 | -0.0633 | 1 |
| 2 | vhid_HA1 | 158 | 0.950 | high | -0.0166 | -0.0189 | -0.0142 | -0.0385 | 1 |
| 3 | vhid_HA1 | 189 | 1.000 | high | -0.0340 | -0.0358 | -0.0320 | -0.0420 | 1 |
| 4 | vhid_HA1 | 289 | 0.955 | high | 0.0239 | 0.0166 | 0.0311 | 0.0424 | 1 |
| 5 | H3N2 | 11 | 1.000 | high | -0.0091 | -0.0113 | -0.0068 | -0.0276 | 9 |
| 6 | H3N2 | 143 | 1.000 | high | -0.0112 | -0.0149 | -0.0074 | -0.0430 | 1 |
| 7 | H3N2 | 167 | 1.000 | high | -0.0021 | -0.0030 | -0.0010 | -0.0143 | 1 |
| 8 | H3N2 | 168 | 1.000 | high | -0.0068 | -0.0087 | -0.0049 | -0.0279 | 1 |
| 9 | H3N2 | 199 | 1.000 | high | -0.0142 | -0.0158 | -0.0127 | -0.0287 | 1 |
| 10 | H3N2 | 200 | 0.650 | moderate | -0.0062 | -0.0076 | -0.0049 | -0.0207 | 1 |
| 11 | H3N2 | 203 | 0.995 | high | -0.0022 | -0.0029 | -0.0015 | -0.0060 | 1 |
| 12 | H3N2 | 288 | 0.815 | moderate | -0.0096 | -0.0109 | -0.0083 | -0.0234 | 1 |
The partial-regression coefficients were estimated using ordinary least squares, controlling for the co-parent set, paired with bootstrap 95% confidence intervals:
To separate functional drivers from passenger mutations, we mapped bootstrap selection frequencies against backdoor-adjusted effect sizes:
The target variable is bounded by a left-censoring floor representing the assay's lower detection limit (undetectable titers $<10$ are encoded at a floor value of 5.0). This affects 493 pairs ($\le 10$) in VHID and 616 pairs in Bedford. Because these values concentrate in high-antigenic-distance regimes (52% of top-quartile Grantham pairs in VHID are censored vs. 0% in the bottom quartile; Mann–Whitney $p < 10^{-100}$), we evaluated whether effect rankings are artifacts of censoring configurations.
We recomputed the adjusted effects under three sensitivity states: (a) as shipped, (b) dropping all censored rows, and (c) recoding the floor value to 10.0. The estimated signs and overall performance ranks remained stable across all states. The only adjustments were single-step rank swaps among the lowest-impact positions (e.g., VHID 144$\leftrightarrow$156). At the same time, the primary convergent drivers (133, 158, 189) maintained stable parameters, confirming that left-censoring does not systematically bias our classifications of primary drivers.
To transition from overall population-level effects to token-level (per-pair) credit attribution, we executed an identifiability audit:
To evaluate the structural validity of the discovered titer-sink graph, we performed three complementary macro-validation tests:
| group | bootstrap_freq | |
|---|---|---|
| 0 | G144 | 1.000 |
| 1 | G158 | 1.000 |
| 2 | G189 | 1.000 |
| 3 | G156 | 1.000 |
| 4 | G289 | 0.995 |
| group | bootstrap_freq | |
|---|---|---|
| 0 | G143 | 1.000 |
| 1 | G203 | 1.000 |
| 2 | G199 | 1.000 |
| 3 | G11 | 1.000 |
| 4 | G288 | 1.000 |
| 5 | G200 | 1.000 |
| 6 | G168 | 1.000 |
| 7 | G167 | 0.965 |
The global goodness-of-fit test systematically rejects the simplified sink-star structure across both datasets ($p < 0.05$). This rejection occurs because the graph does not account for residual parent-parent dependencies arising from shared phylogenetic history. Crucially, this does not invalidate the identification of the target's primary parent set; rather, it indicates that the graph functions as a localized feature-selection model for direct target parents rather than a complete generative model of the sequence-population structure. The linkage-group bootstrap stability scores approach 1.0 for the primary epitope groups, demonstrating that the identities of these driver blocks are highly reproducible under resampling.
To evaluate whether preserving substitution magnitude impacts structural discovery, we executed an independent replication of the structural workflow on the VHID dataset using a continuous encoding scheme. This modification aligns with three structural revisions:
We validated the continuous 12-property $L_2$ scalar against standard Grantham distances across the active alignment columns. The continuous metrics display high correlation while maintaining enhanced precision regarding residue-specific volume and charge trajectories.
The continuous pipeline over the VHID dataset ($n=2751$) yields a High Confidence Markov blanket encompassing positions {156, 189, 278, 289}.
Comparing this with our binary results reveals a stable core: positions 156, 189, and 289 maintain high confidence across both encodings (e.g., position 289 yields a binary stability of 0.955 and a continuous stability of 0.960). The encodings diverge at two points: position 158 (High Confidence under binary flags) drops to unstable ($0.490$) under the continuous metric. In contrast, position 278 (Site C) is promoted from low binary stability ($0.40$) to high continuous stability ($0.970$). This divergence indicates that certain positions operate as binary switches, while others depend on the specific physicochemical distance of the substitution.
| method | threshold | ci_test | alpha | titer_adjacency | titer_parents_caveated | n_adjacent | wall_seconds | |
|---|---|---|---|---|---|---|---|---|
| 0 | FCI_fisherz_screened | 0.8 | fisherz | 0.01 | pos_133;pos_156;pos_189;pos_190;pos_278;pos_289 | pos_189;pos_190;pos_278 | 6 | 12.2 |
| 1 | PC_fisherz_screened | 0.8 | fisherz | 0.01 | pos_133;pos_156;pos_189;pos_190;pos_278;pos_289 | pos_156;pos_189;pos_190;pos_278;pos_289 | 6 | 6.1 |
| 2 | BOSS_BIC_screened | 0.8 | BIC_score | NaN | pos_53;pos_62;pos_83;pos_94;pos_135;pos_155;po... | pos_53;pos_62;pos_83;pos_94;pos_135;pos_155;po... | 15 | 47.9 |
| locus | position | adjacency_selection_freq | tier | |
|---|---|---|---|---|
| 0 | pos_189 | 189 | 1.000 | HIGH |
| 1 | pos_278 | 278 | 0.970 | HIGH |
| 2 | pos_289 | 289 | 0.960 | HIGH |
| 3 | pos_156 | 156 | 0.905 | HIGH |
| 4 | pos_133 | 133 | 0.860 | MOD |
| 5 | pos_158 | 158 | 0.490 | UNSTABLE |
| 6 | pos_190 | 190 | 0.390 | UNSTABLE |
| 7 | pos_126 | 126 | 0.350 | UNSTABLE |
| 8 | pos_157 | 157 | 0.165 | UNSTABLE |
| 9 | pos_262 | 262 | 0.165 | UNSTABLE |
| 10 | pos_193 | 193 | 0.150 | UNSTABLE |
| 11 | pos_106 | 106 | 0.075 | UNSTABLE |
| 12 | pos_79 | 79 | 0.060 | UNSTABLE |
| 13 | pos_44 | 44 | 0.050 | UNSTABLE |
| 14 | pos_159 | 159 | 0.035 | UNSTABLE |
| 15 | pos_307 | 307 | 0.015 | UNSTABLE |
| 16 | pos_163 | 163 | 0.015 | UNSTABLE |
| 17 | pos_260 | 260 | 0.015 | UNSTABLE |
| 18 | pos_248 | 248 | 0.015 | UNSTABLE |
| 19 | pos_244 | 244 | 0.015 | UNSTABLE |
| 20 | pos_173 | 173 | 0.015 | UNSTABLE |
| 21 | pos_2 | 2 | 0.015 | UNSTABLE |
| 22 | pos_160 | 160 | 0.015 | UNSTABLE |
| 23 | pos_144 | 144 | 0.015 | UNSTABLE |
| 24 | pos_143 | 143 | 0.015 | UNSTABLE |
| 25 | pos_137 | 137 | 0.015 | UNSTABLE |
| 26 | pos_135 | 135 | 0.015 | UNSTABLE |
| 27 | pos_175 | 175 | 0.005 | UNSTABLE |
| 28 | pos_310 | 310 | 0.005 | UNSTABLE |
| 29 | pos_261 | 261 | 0.005 | UNSTABLE |
| 30 | pos_62 | 62 | 0.005 | UNSTABLE |
| 31 | pos_276 | 276 | 0.005 | UNSTABLE |
Rerunning PC target-adjacency searches across binary, Grantham, and continuous $L_2$ encodings on the VHID panel confirms that positions 144, 156, 189, and 289 are robust across all three frameworks (pairwise Jaccard similarities $0.50\text{--}0.63$).
Exploratory analysis mapping individual property dimensions shows that because single amino acid substitutions modify all 12 property axes simultaneously, individual properties are structurally non-identifiable (partial correlations collapse to zero when conditioning axes on one another). Marginal correlations can rank which axis covaries most strongly with titer shifts (e.g., hydrogen-bond-acceptor properties at position 158; $\beta$-sheet preferences at position 189), but these cannot be interpreted as isolated causal effects.
By integrating target-oriented causal discovery with interpretable machine learning, this study establishes a structural framework to separate HA positions that drive antigenic escape from linked passenger mutations. Evaluated strictly on hemagglutination-inhibition data without structural or structural epitope priors, the pipeline maps its highest-confidence selections to classical HA head antigenic sites, rediscovering residues implicated in immune evasion across both H3N2 datasets. The primary convergent core—encompassing mature positions 156 and 189 in VHID, and 133, 158, and 189 in Bedford—localizes to antigenic site B (flanking the receptor-binding domain) and site A. Position 189 is documented as a primary determinant of H3N2 cluster transitions; recovering this signal directly from observational titers indicates that the feature selection maps to verified antigenic mechanisms rather than dataset-specific artifacts.
Our validation battery highlights the structural boundaries of observational serology. Rejection of the simplified sink-star graph in global d-separation tests indicates that, while the pipeline isolates immediate target parents, it does not capture the dense network of phylogenetic dependencies among them. Consequently, adjusted effect sizes represent partial-regression coefficients rather than fully identified causal parameters.
Furthermore, our framework demonstrates that selection stability does not inherently imply functional causality; passenger mutations tightly linked to functional loci can achieve high bootstrap frequencies. This is illustrated by position 156 in the VHID dataset, which displays high selection frequency alongside small, non-robust effect sizes, characterizing it as a stable hitchhiker.
Phylogenetic linkage imposes physical limits on the resolution of individual residues in observational datasets. This is pronounced in the Bedford H3N2 panel, where the largest co-evolving linkage blocks encompass 88 and 55 positions, binding multiple head residues into single covarying units that cannot be resolved without interventional data. Additionally, raw HI titers integrate multiple biophysical phenotypes, conflating head-epitope antibody binding with variations in receptor-binding avidity and unmodeled glycosylation structures. Because avidity-associated residues (including 145, 189, and 193) overlap our parent sets, individual residue attributions remain mechanistically complex under a raw-titer target.
These constraints guide the evaluation of sequence-to-antigenic maps for prospective surveillance. Grouped cross-validation establishes realistic generalization boundaries: when forecasting titers against entirely unseen reference antisera, median predictive performance settles at $R^2 \approx 0.615$ for VHID and $\approx 0.498$ for Bedford, down from random-split baselines near $0.85$. Furthermore, temporal transport analysis indicates that forward-in-time predictions can become unstable when viral evolution crosses major cluster boundaries that are absent from the training data.
In conclusion, this pipeline provides a transparent, self-auditing framework that maps its own structural limits. While observational data can isolate co-evolving blocks and prioritize candidate drivers, resolving individual-residue causality within dense lineages requires integration with prospective reverse genetics, deep mutational scanning escape maps, and structurally isolated serological assays.
Data: influenza-hi-antigenic-distance
repository (CC-BY-4.0). Code and this notebook are
released alongside it. Causal discovery uses the causal-learn
library; the KAN is a
custom PyTorch implementation in src/bspline_kan.py. The full pipeline — linkage
collapse, causal discovery, B-spline KAN, and cross-method convergence — is packaged
as the reusable kan-causal-antigenic-workflow skill.