-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFig1CD_BioSites.R
62 lines (47 loc) · 2.01 KB
/
Fig1CD_BioSites.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
60
61
62
setwd("~/Dropbox/Sugrue2020_MS/GitHub_FINAL_SUGRUE2021/data/")
data <- read.csv("MASTER_Betas_Minfi_Normalised.csv", stringsAsFactors = F)
sample <- read.csv("datPredictedAgeN18FinalJosephZoller.csv", stringsAsFactors = F)
library(ggplot2)
library(dplyr)
#transpose, make cgid column headers
tdata <- as.data.frame(t(data[, -c(1:2)]))
colnames(tdata) <- data$ExternalSampleID
#make new dataframe with probes of interest only, add age
corrdata <- select(tdata, "cg10708287", "cg12097121", "cg16071226", "cg00953859")
corrdata$Age <- sample$Age
colnames(corrdata) <- c("FGF8", "HOXC4", "PAX5", "PAX6", "Age")
longcorrdata = melt(corrdata, id.vars = c("Age"),
measure.vars = c("FGF8", "HOXC4", "PAX5", "PAX6"))
colnames(longcorrdata) <- c("Age", "Gene", "Methylation")
longcorrdata$Age=as.numeric(longcorrdata$Age)
longcorrdata$Methylation=as.numeric(longcorrdata$Methylation)
#multiply by 100 to give methylation %
longcorrdata$Methylation <- longcorrdata$Methylation * 100
ggplot(longcorrdata, aes(x=Age, y=Methylation, colour=Gene)) +
geom_jitter(width=0.1) +
stat_smooth(method="lm", formula=y~log(x), fill="grey") +
ylab("Methylation (%)") +
xlab("Age (Years)") +
theme_classic()
#####1D: IGF1
IGF1corr <- select(tdata, "cg18266944")
IGF1corr$Age <- sample$Age
IGF1corr$Female <- sample$Female
IGF1corr$Tissue <- sample$Tissue
IGF1corr <- subset(IGF1corr, Female=="Female")
IGF1corr <- subset(IGF1corr, Tissue=="Ear")
colnames(IGF1corr) <- c("IGF1", "Age")
longIGF1 = melt(IGF1corr, id.vars = c("Age"),
measure.vars = c("IGF1"))
colnames(longIGF1) <- c("Age", "Gene", "Methylation")
longIGF1$Age=as.numeric(longIGF1$Age)
longIGF1$Methylation=as.numeric(longIGF1$Methylation)
#multiply by 100 to give methylation %
longIGF1$Methylation <- longIGF1$Methylation * 100
#plot
ggplot(longIGF1, aes(x=Age, y=Methylation, colour=Gene)) +
geom_jitter(width=0.1) +
stat_smooth(method="lm", formula=y~log(x), fill="grey") +
ylab("Methylation (%)") +
xlab("Age (Years)") +
theme_classic()