Tools for mortality and aging analysis using the Saturating Removal model
Project description
SRtools
A comprehensive Python library for analyzing mortality and aging data using the Saturating Removal (SR) model. The SR model is a stochastic differential equation model that describes aging as a process of damage accumulation and removal, providing a mechanistic framework for understanding survival and mortality patterns.
Overview
SRtools provides tools for:
- SR Model Simulation: Simulate aging trajectories using various SR model variants
- Survival Analysis: Analyze death times, survival curves, and hazard functions
- Parameter Estimation: Fit SR model parameters to data using maximum likelihood and Bayesian methods
- Life Table Analysis: Work with aggregate survival data from life tables
- Parametric Fitting: Fit Weibull, Gompertz, and Makeham-Gompertz distributions to survival data
- Bayesian Inference: Perform MCMC sampling for parameter estimation and uncertainty quantification
Installation
Requirements
- Python 3.10+
- NumPy >= 1.21.0
- Pandas >= 1.3.0
- SciPy >= 1.7.0
- Matplotlib >= 3.4.0
- And other dependencies (see
requirements.txt)
Install from source
git clone <repository-url>
cd SRtools
pip install -e ".[dev]"
Install from PyPI
The PyPI distribution name is srtools-aging because srtools is already used
by an unrelated project. The Python import name remains SRtools:
pip install srtools-aging
Or install dependencies directly:
pip install -r requirements.txt
Web app
The Streamlit web app lives in app/ and is intentionally separate from the
core package. Streamlit is not a dependency of SRtools.
For a deployed/stable app environment:
pip install -r app/requirements.txt
streamlit run app/streamlit_app.py
For local development against this checkout:
pip install -e ".[app]"
streamlit run app/streamlit_app.py
Quick Start
Basic SR Model Simulation
from SRtools import SR_lf
# Create an SR model simulation
# Parameters: eta, beta, kappa, epsilon, xc, npeople, nsteps, t_end
model = SR_lf(
eta=0.5, # Damage production rate
beta=50, # Damage removal parameter
kappa=0.5, # Removal saturation parameter
epsilon=50, # Noise parameter
xc=17.0, # Critical damage threshold
npeople=10000,
nsteps=5000,
t_end=110
)
# Access survival and hazard functions
survival_times, survival_values = model.getSurvival()
hazard_times, hazard_values = model.getHazard()
# Plot survival curve
model.plotSurvival()
Working with Death Times Data
from SRtools import Dataset
import numpy as np
# Create dataset from death times
death_times = np.array([...]) # Your death times data
events = np.ones_like(death_times) # Event indicators (1 = death, 0 = censored)
dataset = Dataset(death_times, events)
# Calculate survival and hazard
survival_times, survival_values = dataset.getSurvival()
hazard_times, hazard_values = dataset.getHazard()
# Plot results
dataset.plotSurvival()
dataset.plotHazard()
Life Table Analysis
from SRtools import Life_table
import numpy as np
# Create life table from age bins and number alive
ages = np.array([0, 10, 20, 30, 40, 50, 60, 70, 80, 90])
n_alive = np.array([1000, 950, 900, 800, 600, 400, 200, 80, 20, 2])
life_table = Life_table(ages, n_alive)
# Access survival and hazard
survival_times, survival_values = life_table.getSurvival()
hazard_times, hazard_values = life_table.getHazard()
Bayesian Parameter Estimation
from SRtools import Dataset
from SRtools.sr_mcmc import run_mcmc
# Load your data
dataset = Dataset(death_times, events)
# Run MCMC to estimate SR model parameters
# See sr_mcmc.py for detailed usage
Core Components
Dataset Classes
Dataset: Base class for working with individual death times dataDatasetCollection: Manage multiple datasetsLife_table: Work with aggregate survival data from life tables
SR Model Variants
SR: Standard SR model with full parameter set and parent class for advanced models.
It is recommended to work with these:
SR_Hetro: SR model with population heterogeneity (most advanced)SR_lf: SR model integrated with lifelines library (recommended for general use)
Parametric Fitters
WeibullFitter: Fit Weibull distribution to survival dataExtendedWeibullFitter: Extended Weibull fittingGompertzFitter: Fit Gompertz distributionMakehamGompertzFitter: Fit Makeham-Gompertz distributionGompertzMakehamFitter: Alternative Makeham-Gompertz fitting
Bayesian Analysis
Posterior: Analyze samples from MCMC to calculate and analyze posterior probabilitiesJointPosterior: Joint posterior analysis on several MCMC runssr_mcmc: MCMC sampling functionality using emcee and some supporting utilities and analysis
Utilities
Guess: Simple tool for inital parameter estimationplotting_utils: Visualization utilities for the comparison of parameters and CI's estimated from different runsdistance_metrics: Distance metrics for model comparison (most of them are likelihoods and not distances)readResults: Read and analyze saved resultsreadResultsBaysian: Read Bayesian analysis results
SR Model Description
The SR model describes the evolution of damage (X) over time:
dX/dt = eta * t - (beta * X) / (X + kappa) + sqrt(2 * epsilon) * xi
Where:
- eta: Damage production rate (linear growth)
- beta: Damage removal parameter
- kappa: Removal saturation parameter
- epsilon: Stochastic noise parameter
- xc: Critical damage threshold (death occurs when X > xc)
- xi: White noise (Wiener process)
Death occurs when the damage X exceeds the critical threshold xc.
Key Features
- Flexible Simulation: Multiple SR model variants and simulation methods
- Efficient Computation: Uses Numba JIT compilation for performance
- Comprehensive Analysis: Survival curves, hazard functions, cumulative hazards
- Statistical Fitting: Maximum likelihood and Bayesian parameter estimation
- Visualization: Built-in plotting functions for survival and hazard analysis
- Life Table Support: Work with aggregate survival data
- MCMC Integration: Full Bayesian inference using emcee
Documentation
For detailed API documentation, see the docstrings in individual modules. Key modules include:
SRmodellib.py: Core SR model implementationdeathTimesDataSet.py: Dataset handling and survival analysislife_table.py: Life table analysissr_mcmc.py: MCMC sampling and Bayesian inferenceweibullFitter.py: Weibull distribution fittingmakhamGompertzFitter.py: Gompertz-Makeham fitting
Deprecated Modules
The following modules are deprecated and should not be used in new code:
probability.pyprior_gen.pylife_table_old.py
Use life_table.py instead of life_table_old.py. For prior generation and probability calculations, use the functionality in sr_mcmc.py and samples_utils.py.
Examples
See the ... notebooks for example usage.
Citation
If you use SRtools in your research, please cite the relevant papers on the SR model of aging:
-
- Naveh Raz, Yifan Yang, Glen Pridham et al. A damage accumulation model reveals strategies of aging across species, 08 July 2025, PREPRINT (Version 1) available at Research Square [https://doi.org/10.21203/rs.3.rs-6946440/v1]
-
- Karin, O., Agrawal, A., Porat, Z. et al. Senescent cell turnover slows with age providing an explanation for the Gompertz law. Nat Commun 10, 5495 (2019). https://doi.org/10.1038/s41467-019-13192-4
License
MIT. See LICENSE.
Contributing
[Add contributing guidelines here]
Contact
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file srtools_aging-0.1.0.tar.gz.
File metadata
- Download URL: srtools_aging-0.1.0.tar.gz
- Upload date:
- Size: 236.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74ad6824990616014dc07c93d93ef1c204a7a0889bc47e368c64cc0419e110d9
|
|
| MD5 |
121602997067425636c0b6f645ee112f
|
|
| BLAKE2b-256 |
f97abcee23f651d451eae041ccabff2e9e94a2b634f64cddda2e0dbef951a540
|
Provenance
The following attestation bundles were made for srtools_aging-0.1.0.tar.gz:
Publisher:
release.yml on NavehRaz/SRtools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
srtools_aging-0.1.0.tar.gz -
Subject digest:
74ad6824990616014dc07c93d93ef1c204a7a0889bc47e368c64cc0419e110d9 - Sigstore transparency entry: 1553726478
- Sigstore integration time:
-
Permalink:
NavehRaz/SRtools@747393cd360f2341898952f577faffd0dae5162b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/NavehRaz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@747393cd360f2341898952f577faffd0dae5162b -
Trigger Event:
push
-
Statement type:
File details
Details for the file srtools_aging-0.1.0-py3-none-any.whl.
File metadata
- Download URL: srtools_aging-0.1.0-py3-none-any.whl
- Upload date:
- Size: 249.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50705f05b51e0d597c8bd5f5da5f2aee6dbfda0c97eb0ca44e7397b5fab3568d
|
|
| MD5 |
4b7706535e23f7ef9ed8c3b8004ec9aa
|
|
| BLAKE2b-256 |
e958c5d619393f39082b217a23bc2f01d414e99bd268b27b24519e5ab4822a8d
|
Provenance
The following attestation bundles were made for srtools_aging-0.1.0-py3-none-any.whl:
Publisher:
release.yml on NavehRaz/SRtools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
srtools_aging-0.1.0-py3-none-any.whl -
Subject digest:
50705f05b51e0d597c8bd5f5da5f2aee6dbfda0c97eb0ca44e7397b5fab3568d - Sigstore transparency entry: 1553726506
- Sigstore integration time:
-
Permalink:
NavehRaz/SRtools@747393cd360f2341898952f577faffd0dae5162b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/NavehRaz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@747393cd360f2341898952f577faffd0dae5162b -
Trigger Event:
push
-
Statement type: