Skip to content

Commit

Permalink
added two mouse clocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Camillo authored and Lucas Camillo committed Dec 12, 2023
1 parent ae82bbd commit c67a68c
Show file tree
Hide file tree
Showing 22 changed files with 1,061 additions and 527 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ With a growing number of aging clocks and biomarkers of aging, comparing and ana

## 📝 To-Do List

- [ ] Incorporate more murine DNA methylation clocks
- [ ] Add torch data loader for age prediction of large datasets
- [ ] Integrate scAge and scRNAseq clocks (and datasets)
- [X] Incorporate more murine DNA methylation clocks
- [X] Add torch data loader for age prediction of large datasets
- [ ] Add other blood chemistry biological age clocks (KD age)
- [ ] Incorporate proteomic clocks (and datasets)
- [ ] Integrate scAge clocks (this is proving to be difficult)
- [ ] Integrate scRNAseq clocks (and datasets)

## ❓ Can't find an aging clock?

Expand Down
Binary file added clocks/notebooks/coefficients.xlsx
Binary file not shown.
2 changes: 1 addition & 1 deletion clocks/notebooks/join_metadata.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 1,
"id": "59eb29df-0597-4d45-b2e6-8825670effe2",
"metadata": {},
"outputs": [],
Expand Down
45 changes: 16 additions & 29 deletions clocks/notebooks/meermultitissue.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 59,
"id": "fb157849-5454-4a60-8548-fff633fff764",
"metadata": {},
"outputs": [],
Expand All @@ -15,7 +15,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 57,
"id": "46c6fc26-9a6b-4027-bd01-601b70eb401a",
"metadata": {},
"outputs": [
Expand All @@ -25,7 +25,7 @@
"0"
]
},
"execution_count": 9,
"execution_count": 57,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -36,34 +36,22 @@
},
{
"cell_type": "code",
"execution_count": 1,
"id": "bf89303a-6e7f-4585-a439-655fe0a79b05",
"metadata": {},
"outputs": [],
"source": [
"# You have to manually open Excel and convert to .csv (multi tissue, whole lifespan)"
]
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 52,
"id": "b9f484b1-f501-41b7-9565-82e03bfe97dc",
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv('coefficients.csv')\n",
"\n",
"intercept = df['Position'].iloc[-1]\n",
"df = pd.read_excel('ClockData/elife-40675-supp3-v2.xlsx', sheet_name='Whole lifespan multi-tissue', nrows=435)\n",
"\n",
"df = df[0:-2]\n",
"intercept = 234.64\n",
"\n",
"df['feature'] = df['Chromosome'].astype(str) + ':' + df['Position'].astype(int).astype(str)\n",
"df['coefficient'] = df['Weight']"
]
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 53,
"id": "a284fe99-dc47-4f0c-b2ff-274e136e7020",
"metadata": {},
"outputs": [],
Expand All @@ -76,7 +64,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 62,
"id": "7b4c3f6b-72af-4e99-84c4-65b8ef58c91d",
"metadata": {},
"outputs": [
Expand All @@ -88,29 +76,29 @@
")"
]
},
"execution_count": 23,
"execution_count": 62,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"model = pya.models.LinearModel(len(features))\n",
"\n",
"model.linear.weight.data = weights\n",
"model.linear.bias.data = intercept\n",
"model.linear.weight.data = weights*100/30.5\n",
"model.linear.bias.data = intercept/30.5\n",
"\n",
"model"
]
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 63,
"id": "e32706f0-ce07-455e-bb17-1993c1c0e152",
"metadata": {},
"outputs": [],
"source": [
"weights_dict = {\n",
" 'preprocessing': \"times100\", \n",
" 'preprocessing': None, \n",
" 'preprocessing_helper': None,\n",
" 'postprocessing': None,\n",
" 'postprocessing_helper': None,\n",
Expand All @@ -127,13 +115,13 @@
" 'postprocessing': weights_dict['postprocessing'], \n",
" 'citation': \"Meer, Margarita V., et al. \\\"A whole lifespan mouse multi-tissue DNA methylation clock.\\\" Elife 7 (2018): e40675.\",\n",
" 'doi': \"https://doi.org/10.7554/eLife.40675\",\n",
" \"notes\": \"Predicts age in days\",\n",
" \"notes\": None,\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 64,
"id": "34136f3c-92b8-4641-a103-381d3a7dd857",
"metadata": {},
"outputs": [],
Expand All @@ -160,8 +148,7 @@
}
],
"source": [
"os.system(\"rm coefficients.xlsx\")\n",
"os.system(\"rm coefficients.csv\")"
"os.system(\"rm coefficients.xlsx\")"
]
},
{
Expand Down
152 changes: 152 additions & 0 deletions clocks/notebooks/petkovichblood.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"id": "fb157849-5454-4a60-8548-fff633fff764",
"metadata": {},
"outputs": [],
"source": [
"import torch\n",
"import pandas as pd\n",
"import pyaging as pya\n",
"import os"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "49adac4a-82e5-4fae-a0e0-26dcce5661bf",
"metadata": {},
"outputs": [],
"source": [
"os.system(\"curl -o coefficients.xlsx https://elifesciences.org/download/aHR0cHM6Ly9jZG4uZWxpZmVzY2llbmNlcy5vcmcvYXJ0aWNsZXMvNDA2NzUvZWxpZmUtNDA2NzUtc3VwcDMtdjIueGxzeA--/elife-40675-supp3-v2.xlsx?_hash=qzOMc4yUFACfDFG%2FlgxkFTHWt%2BSXSmP9zz1BM3oOTRM%3D\")"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "b9f484b1-f501-41b7-9565-82e03bfe97dc",
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_excel('coefficients.xlsx', sheet_name='Blood', nrows=90)\n",
"\n",
"intercept = 0.0\n",
"\n",
"df['feature'] = df['Chromosome'].astype(str) + ':' + df['Position'].astype(int).astype(str)\n",
"df['coefficient'] = df['Weight']"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "a284fe99-dc47-4f0c-b2ff-274e136e7020",
"metadata": {},
"outputs": [],
"source": [
"features = df['feature'].tolist()\n",
"\n",
"weights = torch.tensor(df['coefficient'].tolist()).unsqueeze(0)\n",
"intercept = torch.tensor([intercept])"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "7b4c3f6b-72af-4e99-84c4-65b8ef58c91d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"LinearModel(\n",
" (linear): Linear(in_features=90, out_features=1, bias=True)\n",
")"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"model = pya.models.LinearModel(len(features))\n",
"\n",
"model.linear.weight.data = weights\n",
"model.linear.bias.data = intercept\n",
"\n",
"model"
]
},
{
"cell_type": "code",
"execution_count": 40,
"id": "e32706f0-ce07-455e-bb17-1993c1c0e152",
"metadata": {},
"outputs": [],
"source": [
"weights_dict = {\n",
" 'preprocessing': None, \n",
" 'preprocessing_helper': None,\n",
" 'postprocessing': \"petkovichblood\",\n",
" 'postprocessing_helper': None,\n",
" 'features': features,\n",
" 'weight_dict': model.state_dict(),\n",
"}\n",
"\n",
"metadata_dict = {\n",
" 'species': 'Mus musculus',\n",
" 'data_type': 'methylation',\n",
" 'year': 2017,\n",
" 'implementation_approved_by_author(s)': '⌛',\n",
" 'preprocessing': weights_dict['preprocessing'], \n",
" 'postprocessing': weights_dict['postprocessing'], \n",
" 'citation': \"Petkovich, Daniel A., et al. \\\"Using DNA methylation profiling to evaluate biological age and longevity interventions.\\\" Cell metabolism 25.4 (2017): 954-960.\",\n",
" 'doi': \"https://doi.org/10.1016/j.cmet.2017.03.016\",\n",
" \"notes\": None,\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 41,
"id": "34136f3c-92b8-4641-a103-381d3a7dd857",
"metadata": {},
"outputs": [],
"source": [
"torch.save(weights_dict, '../weights/petkovichblood.pt')\n",
"torch.save(metadata_dict, '../metadata/petkovichblood.pt')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "83334bff-17c3-447c-9e37-fcb68edef5df",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.17"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit c67a68c

Please sign in to comment.