Metadata-Version: 2.4
Name: aging_metaclock
Version: 0.1.1
Summary: Reproducible analysis and plotting workflows for MetaClock
Requires-Python: <3.12,>=3.11
Description-Content-Type: text/markdown
Requires-Dist: anndata==0.12.7
Requires-Dist: joblib==1.5.2
Requires-Dist: lightgbm==4.6.0
Requires-Dist: lifelines==0.30.3
Requires-Dist: matplotlib==3.10.8
Requires-Dist: mrmr-selection==0.2.8
Requires-Dist: numpy==2.3.5
Requires-Dist: pandas==2.3.3
Requires-Dist: pymupdf==1.26.6
Requires-Dist: pyarrow==23.0.1
Requires-Dist: pyaging==0.1.30
Requires-Dist: rdata==1.0.0
Requires-Dist: scikit-learn==1.8.0
Requires-Dist: scipy==1.17.0
Requires-Dist: statsmodels==0.14.6
Requires-Dist: torch==2.9.1

# MetaClock workflow

![MetaClock workflow diagram](diagram.png)


## Project overview

MetaClock is an integrated framework that combines
predictions from multiple established epigenetic clocks into meta
models. This repository organizes the reproducible downstream workflows used
to evaluate chronological-age prediction, quantify generalization across array
platforms, tissues, and species, and study biological-age associations with
disease and interventions.

## Environment

Install [uv](https://docs.astral.sh/uv/) and create the locked Python 3.11
environment from the repository root:

```bash
uv sync --frozen
```

## MetaClock Python package

The `aging_metaclock` distribution provides the importable `metaclock` package.
Install it from PyPI using Python 3.11:

```bash
python -m pip install aging_metaclock
```

For local development, install from the repository root:

```bash
python -m pip install -e .
```

### Input contract

`metaclock.fit()` accepts an `.h5ad`
file in pyaging's standard orientation:

- rows are samples;
- columns are DNAm or phenotype features;
- feature names are stored in `adata.var_names`;
- the numeric training response is stored in `adata.obs["age"]` by default.

Clocks that use phenotype covariates, such as GrimAge, require those covariates
in the input matrix and `adata.var_names` according to pyaging's input rules.

### Fit and predict

Pass any ordered list of pyaging component-model names.

```
import metaclock

component_model_list = [
    "horvath2013",
    "hannum",
    "dnamphenoage",
]

model = metaclock.fit(
    train_adata,
    component_model_list,
    "elastic_net",
    target="age",
)

predicted_age = model.predict(test_adata)
```

The three positional arguments are the input data, component-model list, and
model architecture. Set `pyaging_dir` when using a specific local pyaging
weight cache.

To run the component clocks without fitting a meta-model:
```python
component_outputs = metaclock.predict_components(
    test_adata,
    component_model_list,
)
```



