chronaeon 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. chronaeon-0.1.0/LICENSE +21 -0
  2. chronaeon-0.1.0/PKG-INFO +246 -0
  3. chronaeon-0.1.0/README.md +219 -0
  4. chronaeon-0.1.0/pyproject.toml +46 -0
  5. chronaeon-0.1.0/setup.cfg +4 -0
  6. chronaeon-0.1.0/src/chronaeon/__init__.py +65 -0
  7. chronaeon-0.1.0/src/chronaeon/alignment.py +200 -0
  8. chronaeon-0.1.0/src/chronaeon/autoclock.py +2600 -0
  9. chronaeon-0.1.0/src/chronaeon/beast_export.py +508 -0
  10. chronaeon-0.1.0/src/chronaeon/cli.py +991 -0
  11. chronaeon-0.1.0/src/chronaeon/dating.py +60 -0
  12. chronaeon-0.1.0/src/chronaeon/dating_divergence.py +440 -0
  13. chronaeon-0.1.0/src/chronaeon/dating_io.py +518 -0
  14. chronaeon-0.1.0/src/chronaeon/dating_kernels.py +215 -0
  15. chronaeon-0.1.0/src/chronaeon/dating_models.py +1288 -0
  16. chronaeon-0.1.0/src/chronaeon/dating_pipeline.py +1021 -0
  17. chronaeon-0.1.0/src/chronaeon/dating_plots.py +472 -0
  18. chronaeon-0.1.0/src/chronaeon/dudas.py +346 -0
  19. chronaeon-0.1.0/src/chronaeon/geo.py +921 -0
  20. chronaeon-0.1.0/src/chronaeon/r0.py +940 -0
  21. chronaeon-0.1.0/src/chronaeon/sketch.py +302 -0
  22. chronaeon-0.1.0/src/chronaeon/triage.py +803 -0
  23. chronaeon-0.1.0/src/chronaeon.egg-info/PKG-INFO +246 -0
  24. chronaeon-0.1.0/src/chronaeon.egg-info/SOURCES.txt +40 -0
  25. chronaeon-0.1.0/src/chronaeon.egg-info/dependency_links.txt +1 -0
  26. chronaeon-0.1.0/src/chronaeon.egg-info/entry_points.txt +2 -0
  27. chronaeon-0.1.0/src/chronaeon.egg-info/requires.txt +11 -0
  28. chronaeon-0.1.0/src/chronaeon.egg-info/top_level.txt +1 -0
  29. chronaeon-0.1.0/tests/test_autoclock.py +191 -0
  30. chronaeon-0.1.0/tests/test_autoclock_construction.py +309 -0
  31. chronaeon-0.1.0/tests/test_autoclock_helpers_extra.py +178 -0
  32. chronaeon-0.1.0/tests/test_autoclock_imports.py +51 -0
  33. chronaeon-0.1.0/tests/test_autoclock_triage.py +237 -0
  34. chronaeon-0.1.0/tests/test_cli.py +177 -0
  35. chronaeon-0.1.0/tests/test_dating.py +1633 -0
  36. chronaeon-0.1.0/tests/test_geo.py +136 -0
  37. chronaeon-0.1.0/tests/test_imports.py +27 -0
  38. chronaeon-0.1.0/tests/test_r0.py +215 -0
  39. chronaeon-0.1.0/tests/test_recursive_autoclock.py +266 -0
  40. chronaeon-0.1.0/tests/test_sketch_and_alignment.py +95 -0
  41. chronaeon-0.1.0/tests/test_triage.py +58 -0
  42. chronaeon-0.1.0/tests/test_triage_extended.py +206 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sergei L. Kosakovsky Pond and HyphAeon Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,246 @@
1
+ Metadata-Version: 2.4
2
+ Name: chronaeon
3
+ Version: 0.1.0
4
+ Summary: ChronAeon: Ultra-Fast Molecular Clock Dating, Phylodynamics, and Genomic Surveillance
5
+ Author-email: "Sergei L. Kosakovsky Pond" <spond@temple.edu>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/veg/HyphAeon
8
+ Project-URL: Bug Tracker, https://github.com/veg/HyphAeon/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
13
+ Requires-Python: >=3.8
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: hyphaeon-core>=0.1.0
17
+ Requires-Dist: biopython>=1.80
18
+ Requires-Dist: numpy>=1.22.0
19
+ Requires-Dist: scipy>=1.9.0
20
+ Requires-Dist: pandas>=1.5.0
21
+ Requires-Dist: scikit-learn>=1.0
22
+ Requires-Dist: matplotlib>=3.5
23
+ Requires-Dist: tn93>=1.2.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=7.0; extra == "dev"
26
+ Dynamic: license-file
27
+
28
+ # ChronAeon
29
+
30
+ **The Velocity of Time** — Ultra-fast molecular clock dating, phylodynamics, and genomic surveillance.
31
+
32
+ ChronAeon operates along the **TAXON / LINEAGE** axis of the HyphAeon foundation model, providing sub-second execution for tree-free continuous manifold dating, attention-derived covariance, and planetary-scale genomic screening.
33
+
34
+ ## Target Audience
35
+
36
+ Public health agencies (CDC, WHO, UKHSA), outbreak epidemiologists, hospital infection control teams.
37
+
38
+ ## Installation
39
+
40
+ ChronAeon requires Python ≥ 3.8 and PyTorch ≥ 2.0. At runtime it auto-selects
41
+ the best available device (CUDA → Apple MPS → CPU), so no manual configuration
42
+ is needed regardless of which install path you choose.
43
+
44
+ ```bash
45
+ pip install chronaeon
46
+ ```
47
+
48
+ | Method | Command | Torch | GPU? |
49
+ | :--- | :--- | :--- | :--- |
50
+ | **pip** (default) | `pip install chronaeon` | CUDA-bundled wheel (~550 MB) | NVIDIA GPU if driver matches; else CPU |
51
+ | **pip** (CPU-only) | `pip install torch --index-url https://download.pytorch.org/whl/cpu` then `pip install chronaeon` | CPU-only wheel (~200 MB) | CPU |
52
+ | **Bioconda** | `conda install -c bioconda chronaeon` | CPU-only `pytorch` from conda-forge | CPU only |
53
+ | **NVIDIA Jetson** | See [issue #31](https://github.com/veg/HyphAeon/issues/31) | JetPack-native wheel (cp38 only) | Jetson GPU |
54
+
55
+ You can always install a specific PyTorch build before installing ChronAeon if
56
+ none of the above defaults suit your system (e.g. a particular CUDA version,
57
+ a custom wheel, or a CPU-only build on a server without GPU).
58
+
59
+ > [!NOTE]
60
+ > **Model weights** are downloaded automatically from [Hugging Face](https://huggingface.co/datamonkey/hyphaeon)
61
+ > on first use (cached in `~/.cache/hyphaeon/`). No authentication or token is
62
+ > required. Use `--model-variant viral` to select the viral-tuned variant, or
63
+ > `--weights /path/to/checkpoint` to use a local file.
64
+
65
+ ## CLI Subcommands
66
+
67
+ | Command | Aliases | Description |
68
+ | :--- | :--- | :--- |
69
+ | `chronaeon date` | `dating`, `clock`, `mrca` | Molecular clock calibration, tMRCA dating |
70
+ | `chronaeon autoclock` | `deconvolve`, `multiclock` | Hierarchical multi-clock deconvolution |
71
+ | `chronaeon triage` | `radar`, `sieve`, `qc`, `qc-stream`, `stream-qc`, `chronaeon-sieve` | Streaming genomic QC triage / outbreak radar |
72
+ | `chronaeon phylogeo` | `geo`, `spatial`, `dispersal` | Discrete phylogeography |
73
+ | `chronaeon dynamics` | `r0`, `rt`, `growth`, `phylodynamics` | Phylodynamic R₀/Rₜ estimation |
74
+ | `chronaeon sketch` | `cluster`, `bin`, `centrifuge` | MinHash sketching & binning |
75
+ | `chronaeon align` | `thread`, `codon-align` | Reference-guided codon alignment |
76
+
77
+ ## Key Capabilities
78
+
79
+ - **tMRCA Dating** — Continuous sequence manifold dating using attention-derived covariance (`compute_neural_covariance_kernel`)
80
+ - **AutoClock** — Hierarchical multi-clock deconvolution for complex evolutionary scenarios
81
+ - **Triage/Radar** — Stream 100k genomes in minutes, detect emerging clades, flag anomalous spillover branches
82
+ - **Phylogeography** — Continuous spatial dispersal reconstruction
83
+ - **Phylodynamics** — R₀/Rₜ growth rate estimation from heterochronous sequences
84
+
85
+ ## The Radar & Microscope Flywheel
86
+
87
+ ChronAeon is the **Radar**: rapidly screens genomes, detects emerging clades, and infers origin dates. HyphAeon is the **Microscope**: dissects *why* flagged clades emerged — identifying positive selection bursts and epistatic rewiring. Together they form a collaborative flywheel for genomic surveillance and deep evolutionary analysis.
88
+
89
+ ## Reproducible Benchmark Examples
90
+
91
+ ### Example 1: Heterochronous Molecular Clock Calibration & MRCA Dating
92
+
93
+ Replicating the landmark study of **Bette Korber et al. (Science 2000)** dating the origin of HIV-1 group M to ~1931:
94
+
95
+ ```bash
96
+ # Full Heterochronous Dating: Centered OLS + Attention PGLS + Latent Manifold Collapse
97
+ chronaeon date \
98
+ -a chronaeon/examples/korber_env_gp160.fasta \
99
+ --root-taxon CONSENSUS \
100
+ --no-tree \
101
+ --method all \
102
+ -o chronaeon/examples/korber_dating_results.json \
103
+ -c chronaeon/examples/korber_dating_taxa.csv \
104
+ --plot-path chronaeon/examples/korber_clock_diagnostic.png
105
+ ```
106
+
107
+ #### Output Summary:
108
+ ```text
109
+ =========================================================================================================
110
+ Method / Estimator Estimated t_MRCA 95% Confidence Interval Rate (μ / year) R^2
111
+ ---------------------------------------------------------------------------------------------------------
112
+ 1. Standard OLS (TempEst RTT) 1930.82 [1866.5, 1945.8] 0.001874 0.472
113
+ 2. HyphAeon Attention PGLS 1927.57 [1916.4, 1938.7] 0.001875 0.518
114
+ 3. Latent Manifold Collapse 1975.96 [Non-Parametric Coalescent] 0.017032 [Var/yr] 0.429
115
+ ---------------------------------------------------------------------------------------------------------
116
+
117
+ [*] Flagged Temporal Outliers (|Z| >= 2.5):
118
+ • Z59ZR.ZHU: Sampling Date=1959.5, Predicted Date=1933.4 (Discrepancy: -26.09 yr, Z=-5.40)
119
+ ```
120
+
121
+ * **Accurate Ancestor Dating**: Recovers $t_{\text{MRCA}} = 1930.8$ (OLS) and $1927.6$ (Attention PGLS), closely reproducing Korber et al.'s supercomputer maximum-likelihood estimate of **1931.4 [1914.5, 1944.0]** and Thorne's MCMC relaxed clock (**1922–1929 [1889–1952]**) in seconds.
122
+ * **Resolving Pseudoreplication**: Cross-taxa attention covariance $\boldsymbol{\Sigma} = \mathbf{A}_{\text{fused}} + \lambda\mathbf{I}$ whitens shared phylogenetic history, preventing false statistical precision without requiring tree inference.
123
+ * **Historical Validation**: Accurately isolates the 1959 Léopoldville archival isolate `Z59ZR.ZHU` as a temporal outlier relative to the contemporary 1983–1997 cohort.
124
+ * **Comprehensive Guide**: See [`DATING_GUIDE.md`](DATING_GUIDE.md) for full mathematical formulation, intra-host clinical applications (e.g. CD4+ T cell latent reservoir integration timing in CAP286), and CLI documentation.
125
+
126
+ ---
127
+
128
+ ### Example 2: Discrete Phylogeography & Spatial Transmission Networks
129
+
130
+ Replicating the landmark discrete phylogeography study of **Philippe Lemey et al. (PLoS Comput Biol 2009)** reconstructing the epicentral origin and dispersal corridors of Avian Influenza A (H5N1) across 7 Chinese provinces:
131
+
132
+ ```bash
133
+ # Run the built-in worked example with a single command
134
+ chronaeon phylogeo --example --no-neural
135
+ ```
136
+
137
+ Or execute directly on custom alignments and metadata:
138
+ ```bash
139
+ chronaeon phylogeo \
140
+ -a chronaeon/examples/H5N1_HA_geo.fasta \
141
+ -g chronaeon/examples/H5N1_HA_metadata.csv \
142
+ -t chronaeon/examples/H5N1_HA.nwk \
143
+ --no-neural \
144
+ --n-perms 1000 \
145
+ --min-bf 3.0 \
146
+ --geojson chronaeon/examples/H5N1_HA_geo.geojson \
147
+ -o chronaeon/examples/H5N1_HA_geo_results.json \
148
+ -c chronaeon/examples/H5N1_HA_routes.csv \
149
+ --plot-path chronaeon/examples/H5N1_HA_geo_diagnostic.png
150
+ ```
151
+
152
+ #### Output Summary:
153
+ ```text
154
+ =========================================================================================================
155
+ Rank Geographic Region Posterior P(Root) Isolates Role / Dynamics
156
+ ---------------------------------------------------------------------------------------------------------
157
+ 1 Guangdong 1.0000 15 Source / Exporter ★ EPICENTER
158
+ 2 Fujian 0.0000 8 Source / Exporter
159
+ 3 Guangxi 0.0000 27 Source / Exporter
160
+ 4 Hebei 0.0000 3 Sink / Importer
161
+ 5 Henan 0.0000 8 Source / Exporter
162
+ 6 HongKong 0.0000 28 Sink / Importer
163
+ 7 Hunan 0.0000 9 Sink / Importer
164
+ ---------------------------------------------------------------------------------------------------------
165
+
166
+ [*] Statistically Supported Transmission Routes (BF >= 3.0 or FDR <= 0.10):
167
+ Source Target (Sink) Flux Z-Score p-value FDR q Bayes Factor Support
168
+ ---------------------------------------------------------------------------------------------------------
169
+ Guangdong Fujian 0.36515 3.63 0.0060 0.2517 247.5 Decisive (BF >= 100)
170
+ Henan Hebei 0.20412 3.92 0.0559 1.0000 43.0 Strong (10 <= BF < 100)
171
+ Guangdong Guangxi 0.24845 1.33 0.1578 1.0000 13.4 Strong (10 <= BF < 100)
172
+ Fujian Hebei 0.20412 1.69 0.1948 1.0000 10.4 Strong (10 <= BF < 100)
173
+ Henan Hunan 0.11785 0.76 0.3986 1.0000 3.8 Substantial (3 <= BF < 10)
174
+ Fujian Henan 0.12500 0.67 0.4226 1.0000 3.4 Substantial (3 <= BF < 10)
175
+ Guangdong HongKong 0.14639 0.40 0.4426 1.0000 3.2 Substantial (3 <= BF < 10)
176
+ ```
177
+
178
+ #### Key Innovations over BEAST (Lemey et al. 2009):
179
+ * **Ultra-Fast Speed (< 1 Second vs. Hours)**: Replaces tens of millions of MCMC iterations over $2^{K(K-1)/2}$ graph configurations with closed-form ancestral state reconstruction and vectorized matrix permutations.
180
+ * **Naturally Asymmetric Directed Migration**: Unlike BEAST's reversible rate matrix ($\mathbf{\Lambda} = \mu \mathbf{S} \mathbf{P}$, which enforces $s_{jk} = s_{kj}$), ChronAeon measures true directional transmission ($M_{jk} \ne M_{kj}$), capturing directional source-sink dynamics.
181
+ * **Vectorized Permutation BSSVS**: Generates exact empirical Bayes Factors ($\text{BF} \ge 3.0$) and Benjamini-Hochberg FDR $q$-values from 1,000 null permutations in $< 0.1$ seconds.
182
+ * **Spatial PGLS Epicenter**: Infers the continuous geographic epicenter coordinates ($28.10^\circ\text{N}, 111.83^\circ\text{E}$) with analytical 95% geographic confidence radii.
183
+ * **Modern Web GIS Export**: Generates standard GeoJSON feature collections (`.geojson`) compatible with Kepler.gl and Nextstrain/Auspice.
184
+
185
+ ---
186
+
187
+ ### Example 3: Phylodynamic R₀/Rₜ Estimation from Pandemic H1N1
188
+
189
+ Replicating the landmark phylodynamics study of **Fraser et al. (Science 2009)** estimating the early growth rate and basic reproduction number (R₀) of the 2009 H1N1 pandemic:
190
+
191
+ ```bash
192
+ # Run the built-in worked example with a single command
193
+ chronaeon dynamics --example
194
+ ```
195
+
196
+ Or execute directly on custom alignments and metadata:
197
+ ```bash
198
+ chronaeon dynamics \
199
+ -a chronaeon/examples/H1N1_2009_pandemic.fasta \
200
+ -t chronaeon/examples/H1N1_2009_pandemic.nwk \
201
+ --pathogen h1n1 \
202
+ --plot \
203
+ --plot-path chronaeon/examples/H1N1_2009_r0_diagnostic.png \
204
+ -o chronaeon/examples/H1N1_2009_r0_results.json \
205
+ -c chronaeon/examples/H1N1_2009_rt_skyline.csv
206
+ ```
207
+
208
+ #### Key Features:
209
+ * **Ultra-Fast Growth Rate Estimation**: Recovers epidemic growth rate ($r$) and basic reproduction number ($R_0$) in seconds from heterochronous sequence data, without MCMC.
210
+ * **Dynamic R(t) Skyline**: Sliding-window estimation of time-varying reproduction numbers ($R_t$) across the epidemic timeline, capturing waves and interventions.
211
+ * **Pathogen Presets**: Built-in generation intervals for common pathogens (`h1n1`, `ebola`, `sars-cov-2`, `measles`, `hiv_early`), or specify custom generation time and SD for gamma renewal models.
212
+ * **SEIR Renewal Model**: Optional latent period support for more realistic epidemic modeling.
213
+
214
+ ---
215
+
216
+ ### Example 4: Bayesian Warm-Start Bridge for BEAST MCMC (`--export-beast`)
217
+
218
+ ChronAeon functions as an upstream prior generator for full Bayesian MCMC engines (BEAST 1.x and BEAST X v10.5.0), eliminating the multi-million iteration burn-in penalty caused by arbitrary default priors (e.g. initial $\mu = 1.0$ and uncalibrated demographic starting trees):
219
+
220
+ ```bash
221
+ # 1. Run ChronAeon dating and export pre-populated BEAST XML in a single command:
222
+ chronaeon date \
223
+ -a alignment.fasta \
224
+ -d dates.csv \
225
+ --export-beast beast_warmstart.xml \
226
+ --beast-clock relaxed \
227
+ --beast-chain-length 10000000
228
+
229
+ # 2. Run BEAST with immediate Step-0 convergence:
230
+ beast -overwrite beast_warmstart.xml
231
+ ```
232
+
233
+ #### What ChronAeon Calibrates Inside the BEAST XML:
234
+ * **Substitution Rate ($\mu$)**: Sets initial `clock.rate` or `ucld.mean` directly to ChronAeon's empirical $\hat{\mu}$ (e.g. $2.0 \times 10^{-4}$), avoiding the 4-orders-of-magnitude likelihood chasm of cold-start runs.
235
+ * **Informative Rate Prior**: Embeds a data-driven `logNormalPrior` centered at $\ln(\hat{\mu})$ with variance proportional to the Fieller analytical standard error.
236
+ * **Root Height ($t_{\mathrm{MRCA}}$)**: Calibrates `treeModel.rootHeight` prior with a `normalPrior` centered at $t_{\max} - \hat{t}_{\mathrm{MRCA}}$ with standard deviation matching the 95% Fieller / Jackknife interval.
237
+ * **Coalescent Demography**: Initializes `constant.popSize` to $H / 2$, ensuring the starting coalescent tree matches the empirical time horizon.
238
+ * **AutoClock Multi-Clock Partitioning**: When used with `chronaeon autoclock --export-beast`, automatically emits partitioned taxon sets (`<taxa id="community_k">`) with lineage-specific local clock rates.
239
+
240
+ ---
241
+
242
+ ## Documentation
243
+
244
+ - [Dating Guide](DATING_GUIDE.md)
245
+ - [AutoClock Guide](AUTOCLOCK_GUIDE.md)
246
+ - [MRCA Dating Report](MRCA_DATING_REPORT.md)
@@ -0,0 +1,219 @@
1
+ # ChronAeon
2
+
3
+ **The Velocity of Time** — Ultra-fast molecular clock dating, phylodynamics, and genomic surveillance.
4
+
5
+ ChronAeon operates along the **TAXON / LINEAGE** axis of the HyphAeon foundation model, providing sub-second execution for tree-free continuous manifold dating, attention-derived covariance, and planetary-scale genomic screening.
6
+
7
+ ## Target Audience
8
+
9
+ Public health agencies (CDC, WHO, UKHSA), outbreak epidemiologists, hospital infection control teams.
10
+
11
+ ## Installation
12
+
13
+ ChronAeon requires Python ≥ 3.8 and PyTorch ≥ 2.0. At runtime it auto-selects
14
+ the best available device (CUDA → Apple MPS → CPU), so no manual configuration
15
+ is needed regardless of which install path you choose.
16
+
17
+ ```bash
18
+ pip install chronaeon
19
+ ```
20
+
21
+ | Method | Command | Torch | GPU? |
22
+ | :--- | :--- | :--- | :--- |
23
+ | **pip** (default) | `pip install chronaeon` | CUDA-bundled wheel (~550 MB) | NVIDIA GPU if driver matches; else CPU |
24
+ | **pip** (CPU-only) | `pip install torch --index-url https://download.pytorch.org/whl/cpu` then `pip install chronaeon` | CPU-only wheel (~200 MB) | CPU |
25
+ | **Bioconda** | `conda install -c bioconda chronaeon` | CPU-only `pytorch` from conda-forge | CPU only |
26
+ | **NVIDIA Jetson** | See [issue #31](https://github.com/veg/HyphAeon/issues/31) | JetPack-native wheel (cp38 only) | Jetson GPU |
27
+
28
+ You can always install a specific PyTorch build before installing ChronAeon if
29
+ none of the above defaults suit your system (e.g. a particular CUDA version,
30
+ a custom wheel, or a CPU-only build on a server without GPU).
31
+
32
+ > [!NOTE]
33
+ > **Model weights** are downloaded automatically from [Hugging Face](https://huggingface.co/datamonkey/hyphaeon)
34
+ > on first use (cached in `~/.cache/hyphaeon/`). No authentication or token is
35
+ > required. Use `--model-variant viral` to select the viral-tuned variant, or
36
+ > `--weights /path/to/checkpoint` to use a local file.
37
+
38
+ ## CLI Subcommands
39
+
40
+ | Command | Aliases | Description |
41
+ | :--- | :--- | :--- |
42
+ | `chronaeon date` | `dating`, `clock`, `mrca` | Molecular clock calibration, tMRCA dating |
43
+ | `chronaeon autoclock` | `deconvolve`, `multiclock` | Hierarchical multi-clock deconvolution |
44
+ | `chronaeon triage` | `radar`, `sieve`, `qc`, `qc-stream`, `stream-qc`, `chronaeon-sieve` | Streaming genomic QC triage / outbreak radar |
45
+ | `chronaeon phylogeo` | `geo`, `spatial`, `dispersal` | Discrete phylogeography |
46
+ | `chronaeon dynamics` | `r0`, `rt`, `growth`, `phylodynamics` | Phylodynamic R₀/Rₜ estimation |
47
+ | `chronaeon sketch` | `cluster`, `bin`, `centrifuge` | MinHash sketching & binning |
48
+ | `chronaeon align` | `thread`, `codon-align` | Reference-guided codon alignment |
49
+
50
+ ## Key Capabilities
51
+
52
+ - **tMRCA Dating** — Continuous sequence manifold dating using attention-derived covariance (`compute_neural_covariance_kernel`)
53
+ - **AutoClock** — Hierarchical multi-clock deconvolution for complex evolutionary scenarios
54
+ - **Triage/Radar** — Stream 100k genomes in minutes, detect emerging clades, flag anomalous spillover branches
55
+ - **Phylogeography** — Continuous spatial dispersal reconstruction
56
+ - **Phylodynamics** — R₀/Rₜ growth rate estimation from heterochronous sequences
57
+
58
+ ## The Radar & Microscope Flywheel
59
+
60
+ ChronAeon is the **Radar**: rapidly screens genomes, detects emerging clades, and infers origin dates. HyphAeon is the **Microscope**: dissects *why* flagged clades emerged — identifying positive selection bursts and epistatic rewiring. Together they form a collaborative flywheel for genomic surveillance and deep evolutionary analysis.
61
+
62
+ ## Reproducible Benchmark Examples
63
+
64
+ ### Example 1: Heterochronous Molecular Clock Calibration & MRCA Dating
65
+
66
+ Replicating the landmark study of **Bette Korber et al. (Science 2000)** dating the origin of HIV-1 group M to ~1931:
67
+
68
+ ```bash
69
+ # Full Heterochronous Dating: Centered OLS + Attention PGLS + Latent Manifold Collapse
70
+ chronaeon date \
71
+ -a chronaeon/examples/korber_env_gp160.fasta \
72
+ --root-taxon CONSENSUS \
73
+ --no-tree \
74
+ --method all \
75
+ -o chronaeon/examples/korber_dating_results.json \
76
+ -c chronaeon/examples/korber_dating_taxa.csv \
77
+ --plot-path chronaeon/examples/korber_clock_diagnostic.png
78
+ ```
79
+
80
+ #### Output Summary:
81
+ ```text
82
+ =========================================================================================================
83
+ Method / Estimator Estimated t_MRCA 95% Confidence Interval Rate (μ / year) R^2
84
+ ---------------------------------------------------------------------------------------------------------
85
+ 1. Standard OLS (TempEst RTT) 1930.82 [1866.5, 1945.8] 0.001874 0.472
86
+ 2. HyphAeon Attention PGLS 1927.57 [1916.4, 1938.7] 0.001875 0.518
87
+ 3. Latent Manifold Collapse 1975.96 [Non-Parametric Coalescent] 0.017032 [Var/yr] 0.429
88
+ ---------------------------------------------------------------------------------------------------------
89
+
90
+ [*] Flagged Temporal Outliers (|Z| >= 2.5):
91
+ • Z59ZR.ZHU: Sampling Date=1959.5, Predicted Date=1933.4 (Discrepancy: -26.09 yr, Z=-5.40)
92
+ ```
93
+
94
+ * **Accurate Ancestor Dating**: Recovers $t_{\text{MRCA}} = 1930.8$ (OLS) and $1927.6$ (Attention PGLS), closely reproducing Korber et al.'s supercomputer maximum-likelihood estimate of **1931.4 [1914.5, 1944.0]** and Thorne's MCMC relaxed clock (**1922–1929 [1889–1952]**) in seconds.
95
+ * **Resolving Pseudoreplication**: Cross-taxa attention covariance $\boldsymbol{\Sigma} = \mathbf{A}_{\text{fused}} + \lambda\mathbf{I}$ whitens shared phylogenetic history, preventing false statistical precision without requiring tree inference.
96
+ * **Historical Validation**: Accurately isolates the 1959 Léopoldville archival isolate `Z59ZR.ZHU` as a temporal outlier relative to the contemporary 1983–1997 cohort.
97
+ * **Comprehensive Guide**: See [`DATING_GUIDE.md`](DATING_GUIDE.md) for full mathematical formulation, intra-host clinical applications (e.g. CD4+ T cell latent reservoir integration timing in CAP286), and CLI documentation.
98
+
99
+ ---
100
+
101
+ ### Example 2: Discrete Phylogeography & Spatial Transmission Networks
102
+
103
+ Replicating the landmark discrete phylogeography study of **Philippe Lemey et al. (PLoS Comput Biol 2009)** reconstructing the epicentral origin and dispersal corridors of Avian Influenza A (H5N1) across 7 Chinese provinces:
104
+
105
+ ```bash
106
+ # Run the built-in worked example with a single command
107
+ chronaeon phylogeo --example --no-neural
108
+ ```
109
+
110
+ Or execute directly on custom alignments and metadata:
111
+ ```bash
112
+ chronaeon phylogeo \
113
+ -a chronaeon/examples/H5N1_HA_geo.fasta \
114
+ -g chronaeon/examples/H5N1_HA_metadata.csv \
115
+ -t chronaeon/examples/H5N1_HA.nwk \
116
+ --no-neural \
117
+ --n-perms 1000 \
118
+ --min-bf 3.0 \
119
+ --geojson chronaeon/examples/H5N1_HA_geo.geojson \
120
+ -o chronaeon/examples/H5N1_HA_geo_results.json \
121
+ -c chronaeon/examples/H5N1_HA_routes.csv \
122
+ --plot-path chronaeon/examples/H5N1_HA_geo_diagnostic.png
123
+ ```
124
+
125
+ #### Output Summary:
126
+ ```text
127
+ =========================================================================================================
128
+ Rank Geographic Region Posterior P(Root) Isolates Role / Dynamics
129
+ ---------------------------------------------------------------------------------------------------------
130
+ 1 Guangdong 1.0000 15 Source / Exporter ★ EPICENTER
131
+ 2 Fujian 0.0000 8 Source / Exporter
132
+ 3 Guangxi 0.0000 27 Source / Exporter
133
+ 4 Hebei 0.0000 3 Sink / Importer
134
+ 5 Henan 0.0000 8 Source / Exporter
135
+ 6 HongKong 0.0000 28 Sink / Importer
136
+ 7 Hunan 0.0000 9 Sink / Importer
137
+ ---------------------------------------------------------------------------------------------------------
138
+
139
+ [*] Statistically Supported Transmission Routes (BF >= 3.0 or FDR <= 0.10):
140
+ Source Target (Sink) Flux Z-Score p-value FDR q Bayes Factor Support
141
+ ---------------------------------------------------------------------------------------------------------
142
+ Guangdong Fujian 0.36515 3.63 0.0060 0.2517 247.5 Decisive (BF >= 100)
143
+ Henan Hebei 0.20412 3.92 0.0559 1.0000 43.0 Strong (10 <= BF < 100)
144
+ Guangdong Guangxi 0.24845 1.33 0.1578 1.0000 13.4 Strong (10 <= BF < 100)
145
+ Fujian Hebei 0.20412 1.69 0.1948 1.0000 10.4 Strong (10 <= BF < 100)
146
+ Henan Hunan 0.11785 0.76 0.3986 1.0000 3.8 Substantial (3 <= BF < 10)
147
+ Fujian Henan 0.12500 0.67 0.4226 1.0000 3.4 Substantial (3 <= BF < 10)
148
+ Guangdong HongKong 0.14639 0.40 0.4426 1.0000 3.2 Substantial (3 <= BF < 10)
149
+ ```
150
+
151
+ #### Key Innovations over BEAST (Lemey et al. 2009):
152
+ * **Ultra-Fast Speed (< 1 Second vs. Hours)**: Replaces tens of millions of MCMC iterations over $2^{K(K-1)/2}$ graph configurations with closed-form ancestral state reconstruction and vectorized matrix permutations.
153
+ * **Naturally Asymmetric Directed Migration**: Unlike BEAST's reversible rate matrix ($\mathbf{\Lambda} = \mu \mathbf{S} \mathbf{P}$, which enforces $s_{jk} = s_{kj}$), ChronAeon measures true directional transmission ($M_{jk} \ne M_{kj}$), capturing directional source-sink dynamics.
154
+ * **Vectorized Permutation BSSVS**: Generates exact empirical Bayes Factors ($\text{BF} \ge 3.0$) and Benjamini-Hochberg FDR $q$-values from 1,000 null permutations in $< 0.1$ seconds.
155
+ * **Spatial PGLS Epicenter**: Infers the continuous geographic epicenter coordinates ($28.10^\circ\text{N}, 111.83^\circ\text{E}$) with analytical 95% geographic confidence radii.
156
+ * **Modern Web GIS Export**: Generates standard GeoJSON feature collections (`.geojson`) compatible with Kepler.gl and Nextstrain/Auspice.
157
+
158
+ ---
159
+
160
+ ### Example 3: Phylodynamic R₀/Rₜ Estimation from Pandemic H1N1
161
+
162
+ Replicating the landmark phylodynamics study of **Fraser et al. (Science 2009)** estimating the early growth rate and basic reproduction number (R₀) of the 2009 H1N1 pandemic:
163
+
164
+ ```bash
165
+ # Run the built-in worked example with a single command
166
+ chronaeon dynamics --example
167
+ ```
168
+
169
+ Or execute directly on custom alignments and metadata:
170
+ ```bash
171
+ chronaeon dynamics \
172
+ -a chronaeon/examples/H1N1_2009_pandemic.fasta \
173
+ -t chronaeon/examples/H1N1_2009_pandemic.nwk \
174
+ --pathogen h1n1 \
175
+ --plot \
176
+ --plot-path chronaeon/examples/H1N1_2009_r0_diagnostic.png \
177
+ -o chronaeon/examples/H1N1_2009_r0_results.json \
178
+ -c chronaeon/examples/H1N1_2009_rt_skyline.csv
179
+ ```
180
+
181
+ #### Key Features:
182
+ * **Ultra-Fast Growth Rate Estimation**: Recovers epidemic growth rate ($r$) and basic reproduction number ($R_0$) in seconds from heterochronous sequence data, without MCMC.
183
+ * **Dynamic R(t) Skyline**: Sliding-window estimation of time-varying reproduction numbers ($R_t$) across the epidemic timeline, capturing waves and interventions.
184
+ * **Pathogen Presets**: Built-in generation intervals for common pathogens (`h1n1`, `ebola`, `sars-cov-2`, `measles`, `hiv_early`), or specify custom generation time and SD for gamma renewal models.
185
+ * **SEIR Renewal Model**: Optional latent period support for more realistic epidemic modeling.
186
+
187
+ ---
188
+
189
+ ### Example 4: Bayesian Warm-Start Bridge for BEAST MCMC (`--export-beast`)
190
+
191
+ ChronAeon functions as an upstream prior generator for full Bayesian MCMC engines (BEAST 1.x and BEAST X v10.5.0), eliminating the multi-million iteration burn-in penalty caused by arbitrary default priors (e.g. initial $\mu = 1.0$ and uncalibrated demographic starting trees):
192
+
193
+ ```bash
194
+ # 1. Run ChronAeon dating and export pre-populated BEAST XML in a single command:
195
+ chronaeon date \
196
+ -a alignment.fasta \
197
+ -d dates.csv \
198
+ --export-beast beast_warmstart.xml \
199
+ --beast-clock relaxed \
200
+ --beast-chain-length 10000000
201
+
202
+ # 2. Run BEAST with immediate Step-0 convergence:
203
+ beast -overwrite beast_warmstart.xml
204
+ ```
205
+
206
+ #### What ChronAeon Calibrates Inside the BEAST XML:
207
+ * **Substitution Rate ($\mu$)**: Sets initial `clock.rate` or `ucld.mean` directly to ChronAeon's empirical $\hat{\mu}$ (e.g. $2.0 \times 10^{-4}$), avoiding the 4-orders-of-magnitude likelihood chasm of cold-start runs.
208
+ * **Informative Rate Prior**: Embeds a data-driven `logNormalPrior` centered at $\ln(\hat{\mu})$ with variance proportional to the Fieller analytical standard error.
209
+ * **Root Height ($t_{\mathrm{MRCA}}$)**: Calibrates `treeModel.rootHeight` prior with a `normalPrior` centered at $t_{\max} - \hat{t}_{\mathrm{MRCA}}$ with standard deviation matching the 95% Fieller / Jackknife interval.
210
+ * **Coalescent Demography**: Initializes `constant.popSize` to $H / 2$, ensuring the starting coalescent tree matches the empirical time horizon.
211
+ * **AutoClock Multi-Clock Partitioning**: When used with `chronaeon autoclock --export-beast`, automatically emits partitioned taxon sets (`<taxa id="community_k">`) with lineage-specific local clock rates.
212
+
213
+ ---
214
+
215
+ ## Documentation
216
+
217
+ - [Dating Guide](DATING_GUIDE.md)
218
+ - [AutoClock Guide](AUTOCLOCK_GUIDE.md)
219
+ - [MRCA Dating Report](MRCA_DATING_REPORT.md)
@@ -0,0 +1,46 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "chronaeon"
7
+ version = "0.1.0"
8
+ authors = [
9
+ { name="Sergei L. Kosakovsky Pond", email="spond@temple.edu" },
10
+ ]
11
+ description = "ChronAeon: Ultra-Fast Molecular Clock Dating, Phylodynamics, and Genomic Surveillance"
12
+ readme = "README.md"
13
+ requires-python = ">=3.8"
14
+ license = { text = "MIT" }
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: OS Independent",
19
+ "Topic :: Scientific/Engineering :: Bio-Informatics",
20
+ ]
21
+ dependencies = [
22
+ "hyphaeon-core>=0.1.0",
23
+ "biopython>=1.80",
24
+ "numpy>=1.22.0",
25
+ "scipy>=1.9.0",
26
+ "pandas>=1.5.0",
27
+ "scikit-learn>=1.0",
28
+ "matplotlib>=3.5",
29
+ "tn93>=1.2.0",
30
+ ]
31
+
32
+ [project.optional-dependencies]
33
+ dev = ["pytest>=7.0"]
34
+
35
+ [project.scripts]
36
+ chronaeon = "chronaeon.cli:main"
37
+
38
+ [tool.setuptools.packages.find]
39
+ where = ["src"]
40
+
41
+ [tool.pytest.ini_options]
42
+ testpaths = ["tests"]
43
+
44
+ [project.urls]
45
+ "Homepage" = "https://github.com/veg/HyphAeon"
46
+ "Bug Tracker" = "https://github.com/veg/HyphAeon/issues"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,65 @@
1
+ """
2
+ ChronAeon: Ultra-Fast Molecular Clock Dating, Phylodynamics, and Genomic Surveillance.
3
+ """
4
+
5
+ from .dating import (
6
+ run_mrca_dating,
7
+ run_ols_dating,
8
+ run_pgls_dating,
9
+ run_restricted_spline_clock_dating,
10
+ run_powerlaw_clock_dating,
11
+ verify_coding_alignment,
12
+ parse_sample_dates,
13
+ generate_consensus_sequence,
14
+ generate_time_decay_consensus_sequence,
15
+ )
16
+ from .geo import (
17
+ run_phylogeography_analysis,
18
+ estimate_spatial_pgls_epicenter,
19
+ parse_geo_metadata,
20
+ )
21
+ from .r0 import (
22
+ run_r0_analysis,
23
+ compute_reproduction_numbers,
24
+ plot_r0_diagnostics,
25
+ PATHOGEN_PRESETS,
26
+ )
27
+ from .autoclock import (
28
+ AutoClockDeconvolution,
29
+ run_autoclock_deconvolution,
30
+ HierarchicalAutoClock,
31
+ run_hierarchical_autoclock,
32
+ fit_clock,
33
+ recursive_spectral_autoclock,
34
+ classify_community,
35
+ classify_leaf_community,
36
+ )
37
+ from .triage import ChronAeonSieve
38
+ from .sketch import (
39
+ CanonicalMinHashSketcher,
40
+ AlignmentFreeBinner,
41
+ AlignmentFreeCentrifuge,
42
+ )
43
+ from .alignment import (
44
+ ReferenceCodonAligner,
45
+ ReferenceGuidedCodonThreader,
46
+ )
47
+
48
+ __version__ = "0.1.0"
49
+ __all__ = [
50
+ "run_mrca_dating", "run_ols_dating", "run_pgls_dating",
51
+ "run_restricted_spline_clock_dating", "run_powerlaw_clock_dating",
52
+ "verify_coding_alignment", "parse_sample_dates",
53
+ "generate_consensus_sequence", "generate_time_decay_consensus_sequence",
54
+ "run_phylogeography_analysis", "estimate_spatial_pgls_epicenter",
55
+ "parse_geo_metadata",
56
+ "run_r0_analysis", "compute_reproduction_numbers",
57
+ "plot_r0_diagnostics", "PATHOGEN_PRESETS",
58
+ "AutoClockDeconvolution", "run_autoclock_deconvolution",
59
+ "HierarchicalAutoClock", "run_hierarchical_autoclock",
60
+ "fit_clock", "recursive_spectral_autoclock",
61
+ "classify_community", "classify_leaf_community",
62
+ "ChronAeonSieve",
63
+ "CanonicalMinHashSketcher", "AlignmentFreeBinner", "AlignmentFreeCentrifuge",
64
+ "ReferenceCodonAligner", "ReferenceGuidedCodonThreader",
65
+ ]