forked from rkoeck/saliva_methylome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03.1_preprocessingCellComposition.R
62 lines (34 loc) · 1.64 KB
/
03.1_preprocessingCellComposition.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
###########################################################################################################################
# Author: Rebekka Koeck
# Lab: Cellular Genomic Medicine, Clinical Genetics, Maastricht University (Medical Centre +)
# script purpose: preprocess the data for cell composition
# tissue: saliva
# method: preprocessing Noob (minfi)
# input: .idat files from each cohort / array type processed separately: IVF data (GSE196432), FLEHS 450k (GSE110128)
# samples deemed poor quality by RnBeads processing are not included
# output: noob normalised beta values for each sample at each CpG site
############################################################################################################################ preprocessing script for epigenetic age estimation
# load packages
message("loading packages")
suppressPackageStartupMessages(library(minfi))
suppressPackageStartupMessages(library(data.table))
suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(tibble))
# set data directories
message("loading files")
data.dir <- "idat/"
annotation.file <- "annotationExcluded.csv"
# load the annotation file
annotation <- read.csv(annotation.file) %>% select(-X)
annotation$Basename = as.character(annotation$Basename)
# load the idat files
RGSet = read.metharray.exp(data.dir, targets = annotation)
# process the data using preprocessNoob
message("preprocessing")
MSet = preprocessNoob(RGSet)
message("converting to ratio set")
ratioSet = ratioConvert(MSet)
# extract only the beta values
betas = getBeta(ratioSet)
# write the betas file out
write.csv(betas, file = "betas_Noob.csv")