agingclockbench 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,3 @@
1
+ from agingclockbench.datasets.loaders import load_nhanes_sample
2
+
3
+ __all__ = ["load_nhanes_sample"]
@@ -0,0 +1,54 @@
1
+ """Dataset loaders for bundled reference data."""
2
+
3
+ from pathlib import Path
4
+
5
+ import pandas as pd
6
+
7
+ _DATA_DIR = Path(__file__).parent
8
+
9
+
10
+ def load_nhanes_sample() -> pd.DataFrame:
11
+ """Load the bundled NHANES 1999-2000 sample (N=4,086 complete cases).
12
+
13
+ Source: CDC National Health and Nutrition Examination Survey 1999-2000,
14
+ with mortality linkage from NCHS Public-Use Linked Mortality Files.
15
+ All biomarkers are complete (no missing values). Participants are 20-85 years
16
+ old.
17
+
18
+ Columns
19
+ -------
20
+ seqn : int — NHANES participant sequence number
21
+ age : float — chronological age in years
22
+ sex : str — 'male' or 'female'
23
+ albumin_g_dl : float — albumin (g/dL)
24
+ creatinine_mg_dl : float — creatinine (mg/dL)
25
+ glucose_mg_dl : float — glucose (mg/dL)
26
+ crp_mg_l : float — C-reactive protein (mg/L)
27
+ lymphocyte_pct : float — lymphocyte percentage (%)
28
+ mcv_fl : float — mean corpuscular volume (fL)
29
+ rdw_pct : float — red cell distribution width (%)
30
+ alp_u_l : float — alkaline phosphatase (U/L)
31
+ wbc_k_ul : float — white blood cell count (10³/μL)
32
+ mortstat : int — vital status at follow-up (1=deceased, 0=alive/censored)
33
+ permth_exm : float — months from examination to death or censoring
34
+
35
+ Returns
36
+ -------
37
+ pd.DataFrame with 4,086 rows and 14 columns.
38
+
39
+ Examples
40
+ --------
41
+ >>> df = load_nhanes_sample()
42
+ >>> len(df)
43
+ 4086
44
+ >>> list(df.columns[:4])
45
+ ['seqn', 'age', 'sex', 'albumin_g_dl']
46
+ """
47
+ parquet_path = _DATA_DIR / "nhanes_sample.parquet"
48
+ if not parquet_path.exists():
49
+ raise FileNotFoundError(
50
+ f"Bundled NHANES sample not found at {parquet_path}.\n"
51
+ "This file should be included in the installed package. "
52
+ "If you installed from source, run: python -m agingclockbench.datasets.build"
53
+ )
54
+ return pd.read_parquet(parquet_path)
@@ -0,0 +1,3 @@
1
+ from agingclockbench.utils.validation import validate_dataframe
2
+
3
+ __all__ = ["validate_dataframe"]
@@ -0,0 +1,10 @@
1
+ """Input validation helpers."""
2
+
3
+ import pandas as pd
4
+
5
+
6
+ def validate_dataframe(df: pd.DataFrame, required_cols: list[str]) -> None:
7
+ """Raise ValueError if any required column is missing from df."""
8
+ missing = [c for c in required_cols if c not in df.columns]
9
+ if missing:
10
+ raise ValueError(f"Input DataFrame is missing columns: {missing}")
@@ -0,0 +1,183 @@
1
+ Metadata-Version: 2.4
2
+ Name: agingclockbench
3
+ Version: 0.1.0
4
+ Summary: Benchmark biological aging clocks on your data — PhenoAge, KDM, DunedinPACE proxy
5
+ License: MIT
6
+ License-File: LICENSE
7
+ Keywords: aging,biomarkers,aging-clocks,longevity,biological-age,phenoage,kdm,nhanes,mortality
8
+ Author: Aaditya Geddam
9
+ Author-email: aaditya.geddam@gmail.com
10
+ Requires-Python: >=3.11,<4.0
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
20
+ Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
21
+ Requires-Dist: click (>=8.1.0)
22
+ Requires-Dist: lifelines (>=0.28.0)
23
+ Requires-Dist: matplotlib (>=3.8.0)
24
+ Requires-Dist: numpy (>=1.26.0)
25
+ Requires-Dist: pandas (>=2.2.0)
26
+ Requires-Dist: plotly (>=5.17.0)
27
+ Requires-Dist: pyarrow (>=13.0.0)
28
+ Requires-Dist: pydantic (>=2.3.0)
29
+ Requires-Dist: scipy (>=1.13.0)
30
+ Requires-Dist: seaborn (>=0.13.0)
31
+ Project-URL: Documentation, https://aadityageddam-ux.github.io/aging_clock_bench/
32
+ Project-URL: Homepage, https://aadityageddam-ux.github.io/aging_clock_bench/
33
+ Project-URL: Repository, https://github.com/aadityageddam-ux/aging_clock_bench
34
+ Description-Content-Type: text/markdown
35
+
36
+ # AgingClockBench
37
+
38
+ [![PyPI version](https://badge.fury.io/py/agingclockbench.svg)](https://badge.fury.io/py/agingclockbench)
39
+ [![Tests](https://github.com/aadityageddam-ux/aging_clock_bench/actions/workflows/test.yml/badge.svg)](https://github.com/aadityageddam-ux/aging_clock_bench/actions/workflows/test.yml)
40
+ [![Coverage](https://img.shields.io/badge/coverage-89%25-brightgreen)](https://github.com/aadityageddam-ux/aging_clock_bench)
41
+ [![Docs](https://img.shields.io/badge/docs-GitHub%20Pages-blue)](https://aadityageddam-ux.github.io/aging_clock_bench/)
42
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
43
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue)](https://www.python.org/downloads/)
44
+
45
+ **Benchmark biological aging clocks on your data in minutes.**
46
+
47
+ Multiple biological aging clocks exist — PhenoAge, KDM, DunedinPACE — but no standard tool lets researchers compare them side-by-side. AgingClockBench is the **first open-source Python package** implementing multiple clocks with a unified interface and reproducible mortality-validated benchmarking.
48
+
49
+ 📖 **[Full Documentation](https://aadityageddam-ux.github.io/aging_clock_bench/)**
50
+
51
+ ---
52
+
53
+ ## Install
54
+
55
+ ```bash
56
+ pip install agingclockbench
57
+ ```
58
+
59
+ Requires Python 3.11+.
60
+
61
+ ---
62
+
63
+ ## Quick Start
64
+
65
+ ```python
66
+ from agingclockbench import PhenoAge, KDM, BenchmarkSuite
67
+ from agingclockbench.datasets import load_nhanes_sample
68
+
69
+ # Load bundled NHANES 1999-2000 (N=4,086, 20-year mortality follow-up)
70
+ df = load_nhanes_sample()
71
+
72
+ # Compute biological ages
73
+ results = {
74
+ "PhenoAge": PhenoAge().transform(df),
75
+ "KDM": KDM().transform(df),
76
+ }
77
+
78
+ # Benchmark against mortality
79
+ suite = BenchmarkSuite(mortality_col="mortstat", followup_col="permth_exm")
80
+ report = suite.run(df, results)
81
+
82
+ print(report.to_dataframe())
83
+ ```
84
+
85
+ ```
86
+ Clock Pearson r Mort HR (per SD accel) Mort p-value
87
+ PhenoAge 0.930 1.83 0.000001
88
+ KDM 0.677 1.41 0.000001
89
+ ```
90
+
91
+ ```python
92
+ report.plot_km_survival() # Kaplan-Meier by acceleration quartile
93
+ report.plot_comparison() # biological age vs chronological age
94
+ report.to_html("report.html") # interactive Plotly report
95
+ ```
96
+
97
+ ---
98
+
99
+ ## CLI
100
+
101
+ ```bash
102
+ # Benchmark on bundled NHANES with HTML report
103
+ agingclockbench benchmark --data bundled --clocks all --report
104
+
105
+ # Your own data
106
+ agingclockbench benchmark \
107
+ --data my_cohort.csv \
108
+ --clocks PhenoAge KDM \
109
+ --mortality-col vital_status \
110
+ --followup-col followup_months \
111
+ --output ./results/
112
+ ```
113
+
114
+ ---
115
+
116
+ ## Implemented Clocks
117
+
118
+ | Clock | Reference | Biomarkers | Key metric (NHANES) |
119
+ |-------|-----------|-----------|---------------------|
120
+ | **PhenoAge** | Levine et al. 2018 *Aging Cell* | 9 blood | Pearson r=0.93, HR=1.83 |
121
+ | **KDM** | Klemera & Doubal 2006 *Mech Ageing Dev* | 8 blood | Pearson r=0.68, HR=1.41 |
122
+ | **DunedinPACEProxy** | Proxy (NOT Belsky 2022) | 7 blood | pace corr w/ PhenoAge accel r=0.84 |
123
+
124
+ > **Note:** DunedinPACEProxy is a blood-biomarker approximation. The real DunedinPACE requires DNA methylation data (Illumina EPIC array).
125
+
126
+ ---
127
+
128
+ ## Features
129
+
130
+ - ✅ **Unified interface** — all clocks share the same `transform()` API
131
+ - ✅ **Validated** — PhenoAge implementation cross-validated against reference; zero numerical difference on N=4,086 NHANES participants
132
+ - ✅ **Mortality benchmarking** — Cox PH hazard ratios, Kaplan-Meier curves
133
+ - ✅ **Bundled data** — NHANES 1999-2000 with 20-year mortality follow-up, ready to use
134
+ - ✅ **Interactive reports** — Plotly HTML with comparison plots and benchmark table
135
+ - ✅ **CLI tool** — `agingclockbench benchmark` works out of the box
136
+ - ✅ **89% test coverage** — 76+ tests, CI/CD on every push
137
+
138
+ ---
139
+
140
+ ## Documentation
141
+
142
+ | Resource | Link |
143
+ |----------|------|
144
+ | Full docs | [aadityageddam-ux.github.io/aging_clock_bench](https://aadityageddam-ux.github.io/aging_clock_bench/) |
145
+ | Quickstart | [docs/quickstart](https://aadityageddam-ux.github.io/aging_clock_bench/quickstart/) |
146
+ | PhenoAge algorithm | [docs/algorithms/phenoage](https://aadityageddam-ux.github.io/aging_clock_bench/algorithms/phenoage/) |
147
+ | FAQ | [docs/faq](https://aadityageddam-ux.github.io/aging_clock_bench/faq/) |
148
+ | Example notebooks | [examples/](examples/) |
149
+
150
+ ---
151
+
152
+ ## Citation
153
+
154
+ If you use AgingClockBench in your research, please cite:
155
+
156
+ ```bibtex
157
+ @software{geddam2026agingclockbench,
158
+ author = {Geddam, Aaditya},
159
+ title = {AgingClockBench: Benchmarking biological aging clocks},
160
+ url = {https://github.com/aadityageddam-ux/aging_clock_bench},
161
+ year = {2026}
162
+ }
163
+ ```
164
+
165
+ **Also cite the underlying clock papers:**
166
+
167
+ - Levine ME, et al. *Aging Cell.* 2018. (PhenoAge)
168
+ - Klemera P, Doubal S. *Mech Ageing Dev.* 2006. (KDM)
169
+
170
+ ---
171
+
172
+ ## Contributing
173
+
174
+ Contributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md).
175
+
176
+ To add a new clock, implement the `BaseClock` interface — see the [FAQ](https://aadityageddam-ux.github.io/aging_clock_bench/faq/#how-do-i-add-a-new-clock).
177
+
178
+ ---
179
+
180
+ ## License
181
+
182
+ MIT © Aaditya Geddam
183
+
@@ -0,0 +1,22 @@
1
+ agingclockbench/__init__.py,sha256=g3RTmbyvlBvHY_vNY99QqWIlbxWLYw3qTGmtospxcjk,383
2
+ agingclockbench/benchmarks/__init__.py,sha256=wwd4cyk88Sg9RCNxRLsOVd77FbHOvP-XTwnivWkrYqo,162
3
+ agingclockbench/benchmarks/metrics.py,sha256=t-CHTmTMjDg4t8zCHQvQrpDPiwD8-fc9gPEU5qzw5NQ,700
4
+ agingclockbench/benchmarks/plots.py,sha256=sddHj759tq7_hFaZMhg3TUNZAKXhrnfsCbALL95zjds,9655
5
+ agingclockbench/benchmarks/suite.py,sha256=mWu4uVFLk8KmJGi0pYeEN1QCoq40QV3NauC4BvSfFJ0,9641
6
+ agingclockbench/cli.py,sha256=YDLeYfDI_bVZTAZxdy1XAnjF9QihaLGKgz6QoxsWYXo,5650
7
+ agingclockbench/clocks/__init__.py,sha256=io2YgI0K8ZI9fPHYAInl21GPLGk1HNfl8MtSlVOf4x8,302
8
+ agingclockbench/clocks/base.py,sha256=ZXj1AAYRZjszgf98SvQ6nNCUyrep_S0nRee2u8-KZeY,1487
9
+ agingclockbench/clocks/dunedinpace.py,sha256=srkBPrsjNfxs5h6tE4qLDA3VNoGgwU4hSGWcMb0KuwY,5639
10
+ agingclockbench/clocks/kdm.py,sha256=rZoh-WQVQ2dElVJFf_jKP6EpqLwBPV7bi6DaWnaRqlM,7067
11
+ agingclockbench/clocks/phenoage.py,sha256=c6yNBOlpsLsqama53BuvUDZp-xHFnBNQ6pquBwgVVZg,5865
12
+ agingclockbench/config.py,sha256=H44ipvRA9k2B8vMcygbpTLQOUaP-FlQ7Q7fO9cUjZVw,101
13
+ agingclockbench/datasets/__init__.py,sha256=LdhvZbM4SaYzejba8GX2iSJ32dmfN7J-pfXgR-yNHKc,98
14
+ agingclockbench/datasets/loaders.py,sha256=ARoJmzH1-FIo1nOV5IrvhAa-AeaBfBMBDwISuDEqLgs,2026
15
+ agingclockbench/datasets/nhanes_sample.parquet,sha256=wq4b8DplDuQ0ptJ8IDXkLJMgVQsvFjHgbrH6DPn9qSc,83940
16
+ agingclockbench/utils/__init__.py,sha256=zixmsyfK5er4Td5ojGjjHVivwE2re0OJwiQCkYMXdHc,98
17
+ agingclockbench/utils/validation.py,sha256=EUL5wALV0rVBbI8VetrO-ANx_cgyP0qlRsYGVGemLeY,356
18
+ agingclockbench-0.1.0.dist-info/METADATA,sha256=-JzlkaNX983dwNiJVCahUaVgg1utAC180cCl6ofu-E4,6550
19
+ agingclockbench-0.1.0.dist-info/WHEEL,sha256=EGEvSphFYqXKs23-kQBeyNoJP1nrT8ZJKQoi5p5DYL8,88
20
+ agingclockbench-0.1.0.dist-info/entry_points.txt,sha256=6noLfhRpuq6EkoSsCyV56xnG_daYauXFjhHrTT9ibLw,59
21
+ agingclockbench-0.1.0.dist-info/licenses/LICENSE,sha256=_chuVHJJdKuUZ2igQszY3gJmce-B5nr6I1tTo5F1xOs,1079
22
+ agingclockbench-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 2.4.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ agingclockbench=agingclockbench.cli:cli
3
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Aaditya Srivant Geddam
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.