-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenomic Location Overlap Stats
248 lines (203 loc) · 18.8 KB
/
Genomic Location Overlap Stats
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
#Load Data ######################################################
# Discovery Newborn Blood (CHDS) DMRs
CHDS_Combined_DMRs <- import("/CHDS /DMRichR/Combined/DMRs/DMRs.bed")
CHDS_Males_DMRs <- import("/CHDS /DMRichR/Males/DMRs/DMRs.bed")
CHDS_Females_DMRs <- import("/CHDS /DMRichR/Females/DMRs/DMRs.bed")
# Discovery Newborn Blood (CHDS) Universe
CHDS_Combined_Universe <- read.csv("/CHDS /DMRichR/Combined/Extra/bsseq_background.csv")
CHDS_Males_Universe <- read.csv("/CHDS /DMRichR/Males/Extra/bsseq_background.csv")
CHDS_Females_Universe <- read.csv("/CHDS /DMRichR/Females/Extra/bsseq_background.csv")
# Replication Newborn Blood (ReCHARGE/ECHO) DMRs
ECHO_Combined_DMRs <- import("/ReCHARGE:ECHO/ASD NDBS NovaSeq260/DMRichR/Combined/DMRs/DMRs.bed")
ECHO_Males_DMRs <- import("/ReCHARGE:ECHO/ASD NDBS NovaSeq260/DMRichR/Males/DMRs/DMRs.bed")
ECHO_Females_DMRs <- import("/ReCHARGE:ECHO/ASD NDBS NovaSeq260/DMRichR/Females/DMRs/DMRs.bed")
# Replication Newborn Blood (ReCHARGE/ECHO) Universe
ECHO_Combined_Universe <- read.csv("/ReCHARGE:ECHO/ASD NDBS NovaSeq260/DMRichR/Combined/Extra/bsseq_background.csv")
ECHO_Males_Universe <- read.csv("/ReCHARGE:ECHO/ASD NDBS NovaSeq260/DMRichR/Males/Extra/bsseq_background.csv")
ECHO_Females_Universe <- read.csv("/ReCHARGE:ECHO/ASD NDBS NovaSeq260/DMRichR/Females/Extra/bsseq_background.csv")
# Cord Blood DMRs
Cord_Combined_DMRs <- import("/CHDS /CordBlood/DMRichR/Combined/DMRs/DMRs.bed")
Cord_Females_DMRs <- import("/CHDS /CordBlood/DMRichR/Females/DMRs/DMRs.bed")
Cord_Males_DMRs <- import("/CHDS /CordBlood/DMRichR/Males/DMRs/DMRs.bed")
# Cord Blood Universe
Cord_Combined_Universe <- read.csv("/CHDS /CordBlood/DMRichR/Combined/Extra/bsseq_background.csv")
Cord_Females_Universe <- read.csv("/CHDS /CordBlood/DMRichR/Females/Extra/bsseq_background.csv")
Cord_Males_Universe <- read.csv("/CHDS /CordBlood/DMRichR/Males/Extra/bsseq_background.csv")
# Placenta DMRs
Placenta_Combined_DMRs <- import("/CHDS /Placenta/DMRichR/Combined/DMRs/DMRs.bed")
Placenta_Females_DMRs <- import("/CHDS /Placenta/DMRichR/Females/DMRs/DMRs.bed")
Placenta_Males_DMRs <- import("/CHDS /Placenta/DMRichR/Males/DMRs/DMRs.bed")
#Discovery Universe
Placenta_Combined_Universe <- read.csv("/CHDS /Placenta/DMRichR/Combined/Extra/bsseq_background.csv")
Placenta_Females_Universe <- read.csv("/CHDS /Placenta/DMRichR/Females/Extra/bsseq_background.csv")
Placenta_Males_Universe <- read.csv("/CHDS /Placenta/DMRichR/Males/Extra/bsseq_background.csv")
#Discovery DMRs
Cortex_Combined_DMRs <- import("/CHDS /Cortex/DMRichR/Combined/DMRs/DMRs.bed")
Cortex_Males_DMRs <- import("/CHDS /Cortex/DMRichR/Males/DMRs/DMRs.bed")
Cortex_Females_DMRs <- import("/CHDS /Cortex/DMRichR/Females/DMRs/DMRs.bed")
#Discovery Universe
Cortex_Combined_Universe <- read.csv("/CHDS /Cortex/DMRichR/Combined/Extra/bsseq_background.csv")
Cortex_Males_Universe <- read.csv("/CHDS /Cortex/DMRichR/Males/Extra/bsseq_background.csv")
Cortex_Females_Universe <- read.csv("/CHDS /Cortex/DMRichR/Females/Extra/bsseq_background.csv")
#Function to perform stats for number of genomic location overlaps and distance between DMRs ############################
sapply(c("reshape2", "tidyverse", "regioneR", "LOLA", "rtracklayer"), require, character.only = TRUE)
hg38 <- getGenome("hg38")
set.seed(5)
DMRpermTest <- function(A, B, genome, universe, Comparison, file){
message("[DMRpermTest] Performing permutation test of regions using regioneR.")
pt <- permTest(A = A, B = B, genome = genome, ntimes = 10000, universe = universe,
evaluate.function = c(numOverlaps, meanDistance), randomize.function = resampleRegions,
mc.set.seed = FALSE, force.parallel = TRUE, alternative = "auto")
stats <- data.frame("Comparison" = Comparison, "Overlap_observed" = pt$Function1$observed,
"Overlap_zscore" = pt$Function1$zscore, "Overlap_pvalue" = pt$Function1$pval,
"Distance_observed" = pt$Function2$observed, "Distance_zscore" = pt$Function2$zscore,
"Distance_pvalue" = pt$Function2$pval)
message("[DMRpermTest] Complete! Writing plot and returning stats.")
pdf(file = file, width = 10, height = 5)
plot(x = pt, ncol = 2)
dev.off()
return(stats)
}
# Supplemental Table: Females x Males for each tissue
CHDS_Males_CHDS_Females <- DMRpermTest(A=CHDS_Males_DMRs, B=CHDS_Females_DMRs, genome = hg38,
universe = commonRegions(CHDS_Males_Universe, CHDS_Females_Universe),
Comparison = "CHDS Females vs CHDS Males Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Females x Males/CHDS_Females_CHDS_Males_Overlap.pdf")
ECHO_Males_ECHO_Females <- DMRpermTest(A=ECHO_Males_DMRs, B=ECHO_Females_DMRs, genome = hg38,
universe = commonRegions(ECHO_Males_Universe, ECHO_Females_Universe),
Comparison = "ECHO Females vs ECHO Males Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Females x Males/ECHO_Females_ECHO_Males_Overlap.pdf")
Cord_Males_Cord_Females <- DMRpermTest(A=Cord_Males_DMRs, B=Cord_Females_DMRs, genome = hg38,
universe = commonRegions(Cord_Males_Universe, Cord_Males_Universe),
Comparison = "Cord Blood Females vs Cord Blood Males Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Females x Males/Cord_Females_Cord_Males_Overlap.pdf")
Placenta_Males_Placenta_Females <- DMRpermTest(A=Placenta_Males_DMRs, B=Placenta_Females_DMRs, genome = hg38,
universe = commonRegions(Placenta_Males_Universe, Placenta_Females_Universe),
Comparison = "Placenta Females vs Males Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Females x Males/Placenta_Females_Placenta_Males_Overlap.pdf")
Cortex_Males_Cortex_Females <- DMRpermTest(A=Cortex_Males_DMRs, B=Cortex_Females_DMRs, genome = hg38,
universe = commonRegions(Cortex_Males_Universe, Cortex_Females_Universe),
Comparison = "Cortex Females vs Cortex Males Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Females x Males/Cortex_Females_Cortex_Males_Overlap.pdf")
stats_females_males <- rbind(CHDS_Males_CHDS_Females,
ECHO_Males_ECHO_Females,
Placenta_Males_Placenta_Females,
Cord_Males_Cord_Females,
Cortex_Males_Cortex_Females)
write.xlsx(stats_females_males, file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Females x Males/Females_Males_stats.xlsx")
# Supplemental Table: Newborn Blood Replication
CHDS_Combined_ECHO_Combined <- DMRpermTest(A=CHDS_Combined_DMRs, B=ECHO_Combined_DMRs, genome = hg38,
universe = commonRegions(CHDS_Combined_Universe, ECHO_Combined_Universe),
Comparison = "NDBS Sex Combined Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/NDBS Replication/NDBS_SexCombined_Overlap.pdf")
CHDS_Females_ECHO_Females <- DMRpermTest(A=CHDS_Females_DMRs, B=ECHO_Females_DMRs, genome = hg38,
universe = commonRegions(CHDS_Females_Universe, ECHO_Females_Universe),
Comparison = "NDBS Females Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/NDBS Replication/NDBS_Females_Overlap.pdf")
CHDS_Males_ECHO_Males <- DMRpermTest(A=CHDS_Males_DMRs, B=ECHO_Males_DMRs, genome = hg38,
universe = commonRegions(CHDS_Males_Universe,ECHO_Males_Universe),
Comparison = "NDBS Males Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/NDBS Replication/NDBS_Males_Overlap.pdf")
stats_NDBS_Replication <- rbind(CHDS_V2_Combined_ECHO_V3_Combined,
CHDS_V2_Females_ECHO_V2_Females,
CHDS_V7_Males_ECHO_V3_Males)
write.xlsx(stats_NDBS_Replication, file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/NDBS Replication/NDBS_Replication_stats.xlsx")
# Supplemental Table: Sex Combined Tissue Comparisons
CHDS_Combined_Cord_Combined <- DMRpermTest(A=CHDS_Combined_DMRs, B=Cord_Combined_DMRs, genome = hg38,
universe = commonRegions(CHDS_Combined_Universe,Cord_Discovery_Combined_Universe),
Comparison = "CHDS vs Cord Sex Combined Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Combined Tissue Comparisons/CHDS_Combined_Cord_Combined_Overlap.pdf")
CHDS_Combined_Placenta_Combined <- DMRpermTest(A=CHDS_Combined_DMRs, B=Placenta_Combined_DMRs, genome = hg38,
universe = commonRegions(CHDS_Combined_Universe, Placenta_Combined_Universe),
Comparison = "CHDS vs Placenta Sex Combined Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Combined Tissue Comparisons/CHDS_Combined_Placenta_Combined_Overlap.pdf")
CHDS_Combined_Cortex_Combined <- DMRpermTest(A=CHDS_Combined_DMRs, B=Cortex_Combined_DMRs, genome = hg38,
universe = commonRegions(CHDS_Combined_Universe, Cortex_Combined_Universe),
Comparison = "CHDS vs Cortex Sex Combined Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Combined Tissue Comparisons/CHDS_Combined_Cortex_Combined_Overlap.pdf")
Cord_Combined_Placenta_Combined <- DMRpermTest(A=Cord_Discovery_Combined_DMRs, B=Placenta_Combined_DMRs, genome = hg38,
universe = commonRegions(Cord_Combined_Universe, Placenta_Combined_Universe),
Comparison = "Cord vs Placenta Sex Combined Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Combined Tissue Comparisons/Cord_Combined_Placenta_Combined_Overlap.pdf")
Cord_Combined_Cortex_Combined <- DMRpermTest(A=Cord_Combined_DMRs, B=Cortex_Combined_DMRs, genome = hg38,
universe = commonRegions(Cord_Combined_Universe, Cortex_Combined_Universe),
Comparison = "Cord vs Cortex Sex Combined Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Combined Tissue Comparisons/Cord_Combined_Placenta_Combined_Overlap.pdf")
Placenta_Combined_Cortex_Combined <- DMRpermTest(A=Placenta_Combined_DMRs, B=Cortex_Combined_DMRs, genome = hg38,
universe = commonRegions(Placenta_Combined_Universe, Cortex_Combined_Universe),
Comparison = "Placenta vs Cortex Sex Combined Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Combined Tissue Comparisons/Placenta_Combined_Cortex_Combined_Overlap.pdf")
stats_sex_combined <- rbind(CHDS_Combined_Cord_Combined,
CHDS_Combined_Placenta_Combined,
CHDS_Combined_Cortex_Combined,
Cord_Combined_Placenta_Combined,
Cord_Combined_Cortex_Combined,
Placenta_Combined_Cortex_Combined)
write.xlsx(stats_sex_combined, file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Combined Tissue Comparisons/Combined_Tissue_Comparisons_stats.xlsx")
# Supplemental Table: Females Tissue Comparisons
CHDS_Females_Cord_Females <- DMRpermTest(A=CHDS_Females_DMRs, B=Cord_Females_DMRs, genome = hg38,
universe = commonRegions(CHDS_Females_Universe,Cord_Females_Universe),
Comparison = "CHDS vs Cord Females Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Female Tissue Comparisons/CHDS_Cord_Females_Overlap.pdf")
CHDS_Females_Placenta_Females <- DMRpermTest(A=CHDS_Females_DMRs, B=Placenta_Females_DMRs, genome = hg38,
universe = commonRegions(CHDS_Females_Universe,Placenta_Females_Universe),
Comparison = "CHDS vs Placenta Females Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Female Tissue Comparisons/CHDS_Placenta_Females_Overlap.pdf")
CHDS_Females_Cortex_Females <- DMRpermTest(A=CHDS_Females_DMRs, B=Cortex_Females_DMRs, genome = hg38,
universe = commonRegions(CHDS_Females_Universe,Cortex_Females_Universe),
Comparison = "CHDS vs Cortex Females Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Female Tissue Comparisons/CHDS_Cortex_Females_Overlap.pdf")
Cord_Females_Placenta_Females <- DMRpermTest(A=Cord_Females_DMRs, B=Placenta_Females_DMRs, genome = hg38,
universe = commonRegions(Cord_Females_Universe,Placenta_Females_Universe),
Comparison = "Cord vs Placenta Females Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Female Tissue Comparisons/Cord_Placenta_Females_Overlap.pdf")
Cord_Females_Cortex_Females <- DMRpermTest(A=Cord_Females_DMRs, B=Cortex_Females_DMRs, genome = hg38,
universe = commonRegions(Cord_Females_Universe, Cortex_Females_Universe),
Comparison = "Cord vs Cortex Females Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Female Tissue Comparisons/Cord_Cortex_Females_Overlap.pdf")
Placenta_Females_Cortex_Females <- DMRpermTest(A=Placenta_Females_DMRs, B=Cortex_Females_DMRs, genome = hg38,
universe = commonRegions(Placenta_Females_Universe, Cortex_Females_Universe),
Comparison = "Placenta vs Cortex Females Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Female Tissue Comparisons/Placenta_Cortex_Females_Overlap.pdf")
stats_females <- rbind(CHDS_Females_Cord_Females,
CHDS_Females_Placenta_Females,
CHDS_Females_Cortex_Females,
Cord_Females_Placenta_Females,
Cord_Females_Cortex_Females,
Placenta_Females_Cortex_Females)
write.xlsx(stats_females, file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Female Tissue Comparisons/Female_Tissue_Comparisons_stats.xlsx")
# Supplemental Table: Males Tissue Comparisons
CHDS_Males_Cord_Males <- DMRpermTest(A=CHDS_Males_DMRs, B=Cord_Males_DMRs, genome = hg38,
universe = commonRegions(CHDS_Males_Universe,Cord_Males_Universe),
Comparison = "CHDS vs Cord Blood Males Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Male Tissue Comparisons/CHDS_Cord_Males_Overlap.pdf")
CHDS_Males_Placenta_Males <- DMRpermTest(A=CHDS_Males_DMRs, B=Placenta_Males_DMRs, genome = hg38,
universe = commonRegions(CHDS_Males_Universe,Placenta_Males_Universe),
Comparison = "CHDS vs Placenta Males Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Male Tissue Comparisons/CHDS_Placenta_Males_Overlap.pdf")
CHDS_Males_Cortex_Males <- DMRpermTest(A=CHDS_Males_DMRs, B=Cortex_Males_DMRs, genome = hg38,
universe = commonRegions(CHDS_Males_Universe,Cortex_Males_Universe),
Comparison = "CHDS vs Cortex Males Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Male Tissue Comparisons/CHDS_Cortex_Males_Overlap.pdf")
Cord_Males_Placenta_Males <- DMRpermTest(A=Cord_Males_DMRs, B=Placenta_Males_DMRs, genome = hg38,
universe = commonRegions(Cord_Males_Universe, Placenta_Males_Universe),
Comparison = "Cord vs Placenta Males Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Male Tissue Comparisons/Cord_Placenta_Males_Overlap.pdf")
Cord_Males_Cortex_Males <- DMRpermTest(A=Cord_Males_DMRs, B=Cortex_Males_DMRs, genome = hg38,
universe = commonRegions(Cord_Males_Universe, Cortex_Males_Universe),
Comparison = "Cord vs Cortex Males Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Male Tissue Comparisons/Cord_Cortex_Males_Overlap.pdf")
Placenta_Males_Cortex_Males <- DMRpermTest(A=Placenta_Males_DMRs, B=Cortex_Males_DMRs, genome = hg38,
universe = commonRegions(Placenta_Males_Universe, Cortex_Males_Universe),
Comparison = "Placenta vs Cortex Males Overlap",
file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Male Tissue Comparisons/Placenta_Cortex_Males_Overlap.pdf")
stats_males <- rbind(CHDS_Males_Cord_Males,
CHDS_Males_Placenta_Males,
CHDS_Males_Cortex_Males,
CHDS_Males_Cord_Males,
CHDS_Males_Placenta_Males,
CHDS_Males_Cortex_Males,
Cord_Males_Placenta_Males,
Cord_Males_Cortex_Males,
Placenta_Males_Cortex_Males)
write.xlsx(stats_males, file = "/CHDS /DMR_Overlap/DMRpermtest_Figures/Male Tissue Comparisons/Male_Tissue_Comparisons_stats.xlsx")