Skip to content

Commit

Permalink
added mouse clocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Camillo authored and Lucas Camillo committed Dec 11, 2023
1 parent f76cb96 commit 165fc72
Show file tree
Hide file tree
Showing 13 changed files with 1,342 additions and 670 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ With a growing number of aging clocks and biomarkers of aging, comparing and ana

## 📝 To-Do List

- [ ] Incorporate more murine DNA methylation clocks
- [ ] Integrate scAge and scRNAseq clocks (and datasets)
- [ ] Incorporate murine DNA methylation and proteomic clocks (and datasets)
- [ ] Incorporate proteomic clocks (and datasets)

## ❓ Can't find an aging clock?

Expand Down
2 changes: 1 addition & 1 deletion clocks/notebooks/bitage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
" 'species': 'C elegans',\n",
" 'data_type': 'transcriptomics',\n",
" 'year': 2021,\n",
" 'implementation_approved_by_author(s)': '',\n",
" 'implementation_approved_by_author(s)': '',\n",
" 'preprocessing': weights_dict['preprocessing'], \n",
" 'postprocessing': weights_dict['postprocessing'], \n",
" 'citation': \"Meyer, David H., and Björn Schumacher. \\\"BiT age: A transcriptome‐based aging clock near the theoretical limit of accuracy.\\\" Aging cell 20.3 (2021): e13320.\",\n",
Expand Down
10 changes: 9 additions & 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": 14,
"execution_count": 7,
"id": "59eb29df-0597-4d45-b2e6-8825670effe2",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -40,6 +40,14 @@
"\n",
"torch.save(combined_dictionary, '../metadata/all_clock_metadata.pt')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "047fee95-c914-4c3b-872b-c108696caa1b",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
197 changes: 197 additions & 0 deletions clocks/notebooks/meermultitissue.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"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": 9,
"id": "46c6fc26-9a6b-4027-bd01-601b70eb401a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"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": 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,
"id": "b9f484b1-f501-41b7-9565-82e03bfe97dc",
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv('coefficients.csv')\n",
"\n",
"intercept = df['Position'].iloc[-1]\n",
"\n",
"df = df[0:-2]\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,
"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": 23,
"id": "7b4c3f6b-72af-4e99-84c4-65b8ef58c91d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"LinearModel(\n",
" (linear): Linear(in_features=435, out_features=1, bias=True)\n",
")"
]
},
"execution_count": 23,
"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": 30,
"id": "e32706f0-ce07-455e-bb17-1993c1c0e152",
"metadata": {},
"outputs": [],
"source": [
"weights_dict = {\n",
" 'preprocessing': \"times100\", \n",
" 'preprocessing_helper': None,\n",
" 'postprocessing': None,\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': 2018,\n",
" 'implementation_approved_by_author(s)': '⌛',\n",
" 'preprocessing': weights_dict['preprocessing'], \n",
" '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",
"}"
]
},
{
"cell_type": "code",
"execution_count": 31,
"id": "34136f3c-92b8-4641-a103-381d3a7dd857",
"metadata": {},
"outputs": [],
"source": [
"torch.save(weights_dict, '../weights/meermultitissue.pt')\n",
"torch.save(metadata_dict, '../metadata/meermultitissue.pt')"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "303e9b76-993f-4691-af9d-1151b3c7638f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"os.system(\"rm coefficients.xlsx\")\n",
"os.system(\"rm coefficients.csv\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6f111912-501e-4d2c-a592-1cc9829092dd",
"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 165fc72

Please sign in to comment.