Skip to content

Code for the calculation and implementation of the PC Based epigenetic clocks

Notifications You must be signed in to change notification settings

MorganLevineLab/PC-Clocks

Repository files navigation

[The following information can also be found under the wiki pages]

Installation:

1. Please clone or download the zip file of this Github Repository.

2. Take note of where the installation occurred. Copy the path to that folder, including the final '/'.

3. Navigate to [https://yale.box.com/s/kq0b0a7lxckxjvaz7x5n4keaug7tewry] and download the files
      "Example_PCClock_Data.RData"  (Lehne et al. 2015, Technical Replicate Data)
      "CalcAllPCClocks.RData"

4. Place both RData files directly inside the Github Repository you cloned/ downloaded.

5. [Optional] If you wish to calculate ALL the PCs we used to train the PC clocks, not just the ones that were selected by the models, navigate to [https://yale.box.com/s/9eudzra5s8b0ckkwh66xi6iwuva4qct1] and download all 6 RData files--or the ones for the clocks you wish to utilize.
      If you chose to calculate all PCs, then ensure that you move all downloaded files from this link to the downloaded repository under the folder path "/PC-Clocks/Extras/AllPC_data/"
      Please note that predicting all PCs in new data will be memory and computationally intensive, so the code may run slowly. 
      Consider using a high performance computing cluster. A minimum of 16 GB+ of RAM is essential on a personal computer.
               
               
Essential Files:

template_get_PCClocks_script.R
    This is the template with instructions on how to run the code in this repository to get the PC Clock scores.
    
run_calcPCClocks.R
    This is the R function that will be used in the template to calculate the PC Clocks on your data. 

run_calcPCClocks_Accel.R
    This is the R function that is responsible for quickly calculating age acceleration for the various clocks in your sample.
    Most analyses will take advantage of these calculations rather than the raw clock scores.


To Run the Analysis:

1. Load in your phenotype (clinical and demographic) dataframe and methylation data to your R workspace.

2. Open the template_get_PCClocks_script.R and follow the instructions on that script.
      *PLEASE NOTE* that if you have multiple tissues and have missing CpGs (and will thus need to run imputation) that you should separate the tissues into separate dataframes and run each tissue through the functions separately so that imputation is performed separately in each tissue.

Additional Files for analyses:

TrainPCClocks.R
    This is an example script showing you how to perform analyses to train your own principal component-based epigenetic clock or biomarker.
    
Extras > CalcPCClocks_allPCs.R 
      This script will enable you how to calculate all the PCs we had available for training the clock, including PCs that are not used in our PC clock models. Note that calculation time is substantially longer.

Extras > CalcPCClocks_fullLength.R
    This script shows the stepwise original implementation of our PC clocks calculations. Use this if you are interested in manually running the individual steps of what is implemented in our single-line run_calcPCClocks.R function.  


About

Code for the calculation and implementation of the PC Based epigenetic clocks

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages