-
Notifications
You must be signed in to change notification settings - Fork 0
/
05_processROADMAP.Rmd
505 lines (360 loc) · 19.2 KB
/
05_processROADMAP.Rmd
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
---
title: "ROADMAP"
author: "Euan McDonnell"
date: "`r Sys.Date()`"
output: html_document
---
## Code
### Libraries
```{r}
library(ggplot2)
library(RColorBrewer)
library(stringr)
library(reticulate)
```
### Define Directories
```{r}
# Define directories
main_dir <- getwd()
data_dir <- paste0(main_dir, "/rawdata/")
res_dir <- paste0(main_dir, "/results/")
pca_dir <- paste0(main_dir, "/pca/")
dmr_dir <- paste0(res_dir, "dmr/")
roadmap_dir <- paste0(dmr_dir, "/ROADMAPstates/")
de_dir <- paste0(main_dir, "/differential_methylation/")
util_dir <- paste0(main_dir, "/utilities/")
log_dir <- paste0(main_dir, "/logs/")
```
### Source R scripts
```{r}
# Source script that sources files
source("install/source_rscripts.R")
# Source relevant scripts
SourceExternalScripts(paste0(util_dir, "R/"), "*.R$", ignore.case=FALSE)
```
### Define features
```{r}
# Set features
features <- c("Tss", "TssFlank", "Enhancer", "Transcribed", "Repressed")
# Check these match
feature_codes <- list(
c("TssA","TssBiv"),
c("TssAFlnk","BivFlnk"),
c("Enh","EnhG","EnhBiv"),
c("TxWk","Tx","TxFlnk"),
c("Quies","ReprPCWk","ReprPC","Het","ZNF/Rpts")
); names(feature_codes) <- features
```
### Group 15 ROADMAP states
```{r}
# Read in ROADMAP states bed file
allFeature_df <- read.table(paste0(roadmap_dir, "E049_15_coreMarks_dense.bed"), sep="\t", header=FALSE, skip=1)
allFeature_df$V4 <- gsub("[0-9][0-9]*_","",allFeature_df$V4)
# Loop over features
for (feat in names(feature_codes)) {
# Get relevant states
featStates <- allFeature_df[which(allFeature_df$V4 %in% feature_codes[[feat]]),]
print(paste0("##### WORKING ON :- ",feat, ", total states = ",nrow(featStates)))
# Enumerate feature states
print(paste0("##### Number of states = ",paste(c(table(featStates$V4)), collapse=", "), " for ",paste(names(table(featStates$V4)), collapse=", ")))
# Save
write.table(featStates, paste0(roadmap_dir, "E049_15_coreMarks_dense.",feat,"Only.bed"), quote=FALSE, col.names=FALSE, row.names=FALSE, sep="\t")
}
```
### Read in background data
```{r}
# Loop over ids and read in background feature sets
feature_df <- do.call("rbind",lapply(features, function(feat) {
# Read in
out_df <- read.table(paste0(roadmap_dir, "E049_15_coreMarks_dense.",feat,"Only.bed"), sep="\t", header=FALSE)
# Add feature
out_df <- cbind(out_df, FEATURE=feat)
# Return
return(out_df)
}))
# Tidy up feature codes
feature_df$V4 <- gsub(".*_","",feature_df$V4)
# Check for duplicates
feature_df <- feature_df[!duplicated(feature_df[,c("V1","V2","V3","V4")]),]
# Read in total, unsplit file and check none lost
if (!nrow(allFeature_df) == nrow(feature_df)) { stop("WARNING!! YOU HAVE LOST SOME SITES WHEN SPLITTING INTO STATES!!!")}
```
### Overlap DMRs
Prepare the up and down DMR sig data
```{r}
#get all dDMRs
dDMRs <- read.table(paste0(dmr_dir, "dmrff_results.stage_as_continuous.treat_log2FC0.1.tsv"), sep="\t", header=TRUE)
dDMRs_up <- dDMRs[ dDMRs$p.adjust <=0.05 & dDMRs$estimate > 0,]
dDMRs_down <- dDMRs[ dDMRs$p.adjust <=0.05 & dDMRs$estimate < 0,]
write.table(dDMRs_up,paste0(dmr_dir,"dmrff_results.stage_as_continuous.treat_log2FC0.1.up.tsv"),quote=FALSE, col.names=TRUE, row.names=FALSE, sep="\t")
write.table(dDMRs_down,paste0(dmr_dir,"dmrff_results.stage_as_continuous.treat_log2FC0.1.down.tsv"),quote=FALSE, col.names=TRUE, row.names=FALSE, sep="\t")
```
#### With ROADMAP features
Requires Bedtools, must be run on bash from the main project directory
```
# Include a check to see if these output files exist else error.
bash scripts/overlap_allROADMAP.sh $PWD "$PWD/results/dmr/" up True
bash scripts/overlap_allROADMAP.sh $PWD "$PWD/results/dmr/" down True
```
### Overlap DMRs
#### With ATAC regions
Running these aren't essential for the rest of this code.
```
bash scripts/overlap_allATAC.sh $PWD $PWD/results/dmr/ up True
bash scripts/overlap_allATAC.sh $PWD $PWD/results/dmr/ down True
```
### Read in overlap data
#### DMR
Note that some of the sex DMRs don't overlap with states of some features, so will error as no lines. This is fine.
Note that some DMRs overlap with multiple states, so there will be duplicates. This is fine.
```{r}
# Read in
## Stage
upStageDMR_ovlp_df <- ReadInOverlapDMRs(features, dmrSet="up_dDMR", in_dir=dmr_dir)
dnStageDMR_ovlp_df <- ReadInOverlapDMRs(features, dmrSet="down_dDMR", in_dir=dmr_dir)
allStageDMR_ovlp_df <- rbind(upStageDMR_ovlp_df, dnStageDMR_ovlp_df)
```
### Read in sig DMRs to check filtration
```{r eval=FALSE}
# Read in
dDMRs <- read.table(paste0(dmr_dir, "dmrff_results.stage_as_continuous.treat_log2FC0.1.tsv"), sep="\t", header=TRUE)
sDMRs <- read.table(paste0(dmr_dir, "dmrff_results.sex.tsv"), sep="\t", header=TRUE)
# Get sig
sig_dDMRs <- dDMRs[dDMRs$p.adjust < 0.05,]
sig_sDMRs <- sDMRs[sDMRs$p.adjust < 0.05,]
table(sig_dDMRs$CONTRAST)
table(sig_sDMRs$CONTRAST)
# Filter overlaps
## Stage
upStageDMR_ovlp_df <- upStageDMR_ovlp_df[which(upStageDMR_ovlp_df$V4 %in% sig_dDMRs$DMR_ID),]
dnStageDMR_ovlp_df <- dnStageDMR_ovlp_df[which(dnStageDMR_ovlp_df$V4 %in% sig_dDMRs$DMR_ID),]
allStageDMR_ovlp_df <- allStageDMR_ovlp_df[which(allStageDMR_ovlp_df$V4 %in% sig_dDMRs$DMR_ID),]
length(unique(upStageDMR_ovlp_df$V4)); length(unique(dnStageDMR_ovlp_df$V4)); length(unique(allStageDMR_ovlp_df$V4));
## Sex
upSexDMR_ovlp_df <- upSexDMR_ovlp_df[which(upSexDMR_ovlp_df$V4 %in% sig_sDMRs$DMR_ID),]
dnSexDMR_ovlp_df <- dnSexDMR_ovlp_df[which(dnSexDMR_ovlp_df$V4 %in% sig_sDMRs$DMR_ID),]
allSexDMR_ovlp_df <- allSexDMR_ovlp_df[which(allSexDMR_ovlp_df$V4 %in% sig_sDMRs$DMR_ID),]
length(unique(upSexDMR_ovlp_df$V4)); length(unique(dnSexDMR_ovlp_df$V4)); length(unique(allSexDMR_ovlp_df$V4));
# Check
if (length(unique(upStageDMR_ovlp_df$V4)) + length(unique(dnStageDMR_ovlp_df$V4)) != length(unique(allStageDMR_ovlp_df$V4))) {
warning("WARNING! Sum of number of up- and down- developmental DMRs does not equal total sig DMRs")
}
if (length(unique(upSexDMR_ovlp_df$V4)) + length(unique(dnSexDMR_ovlp_df$V4)) != length(unique(allSexDMR_ovlp_df$V4))) {
warning("WARNING! Sum of number of up- and down- developmental DMRs does not equal total sig DMRs")
}
```
### Check feature codes are consistent with paper
"The active states (associated with expressed genes) consist of active transcription start site (TSS) proximal promoter states (TssA, TssAFlnk), a transcribed state at the 5′ and 3′ end of genes showing both promoter and enhancer signatures (TxFlnk), actively transcribed states (Tx, TxWk), enhancer states (Enh, EnhG), and a state associated with zinc finger protein genes (ZNF/Rpts). The inactive states consist of constitutive heterochromatin (Het), bivalent regulatory states (TssBiv, BivFlnk, EnhBiv), repressed Polycomb states (ReprPC, ReprPCWk), and a quiescent state (Quies), which covered on average 68% of each reference epigenome"
This paper: https://www.nature.com/articles/s41598-020-58093-5#Sec4
```{r}
# Loop over and check feature codes match the overall features
for (feat in names(feature_codes)) {
# If feature codes don't match the overall features
print(feat)
if (!all(sort(feature_codes[[feat]]) == sort(unique(feature_df[feature_df$FEATURE == feat,]$V4)))) {
stop("WARNING - MISASSIGNED FEATURE CODES, CHECK YOUR GREP!!!!")
}
}
```
### Add feature groupings
```{r}
allFeature_df$V4 <- gsub(".*_","",allFeature_df$V4)
allFeature_df["FEATURE"] <- ""
for (feat in features) {
allFeature_df[which(allFeature_df$V4 %in% feature_codes[[feat]]),]["FEATURE"] <- feat
}
```
### Calculate frequencies
```{r}
# Calculate frequencies
## Background
backFreq <- CalcFreqFeatures(feature_df, set="Genome")
backFreqCheck <- CalcFreqFeatures(allFeature_df, set="Genome")
## Stage
allStageDMRFreq <- CalcFreqFeatures(rbind(upStageDMR_ovlp_df, dnStageDMR_ovlp_df), set="All (Sig) DMRs")
upStageDMRFreq <- CalcFreqFeatures(upStageDMR_ovlp_df, set="Up (Sig) DMRs")
dnStageDMRFreq <- CalcFreqFeatures(dnStageDMR_ovlp_df, set="Down (Sig) DMRs")
```
### Check background frequency counts
```{r}
# Enumerate combined feature counts
allFeatureCounts <- c(table(allFeature_df$V4))
for (feat in features) {
# Check if total count in background matches sum of 15 state-wise counts
print(feat)
countMatch <- sum(allFeatureCounts[feature_codes[[feat]]]) == backFreq[backFreq$FEATURE == feat,]$Count
# If not the case, stop
if (!countMatch) { stop("FREQUENCY OF YOUR BROAD STATE COUNTs IS NOT THE SUM OF THEIR RESPECTIVE 15 STATE COUNTS") }
}
```
### Plot
#### Prepare
```{r}
# Combine
freq_stageDMRs <- rbind(backFreq,
allStageDMRFreq,
upStageDMRFreq,
dnStageDMRFreq)
# freq_sexDMRs <- rbind(backFreq,
# allNSWidthSexDMRFreq,
# allSexDMRFreq,
# upSexDMRFreq,
# dnSexDMRFreq)
# freq_stageWidthDMRs <- rbind(backWidthFreq,
# allNSWidthStageDMRFreq,
# allWidthStageDMRFreq,
# upWidthStageDMRFreq,
# dnWidthStageDMRFreq)
# freq_sexWidthDMRs <- rbind(backWidthFreq,
# allNSWidthSexDMRFreq,
# allWidthSexDMRFreq,
# # upWidthSexDMRFreq,
# dnWidthSexDMRFreq)
# Define colours
feat_colors <- c("#FF0100", "#DD7095", "#FED800", "#008D00", "#BFBFBF")
names(feat_colors) <- str_to_title(gsub("tss","TSS",features))
# Tidy up names
freq_stageDMRs$Feature <- str_to_title(gsub("Tss","TSS",freq_stageDMRs$FEATURE))
# freq_sexDMRs$Feature <- str_to_title(gsub("Tss","TSS",freq_sexDMRs$Feature))
# freq_stageWidthDMRs$Feature <- str_to_title(gsub("Tss","TSS",freq_stageWidthDMRs$Feature))
# freq_sexWidthDMRs$Feature <- str_to_title(gsub("Tss","TSS",freq_sexWidthDMRs$Feature))
```
#### Stat test
##### Chi-squared (overall)
Chi squared. This test for any deviation over the whole distributions of test/background.
```{r}
# Loop over sets and test
sets2Test <- c("All (Sig) DMRs", "Up (Sig) DMRs", "Down (Sig) DMRs")
freq_stageDMRs$Set <- as.character(freq_stageDMRs$Set)
# freq_stageWidthDMRs$Set <- as.character(freq_stageWidthDMRs$Set)
## Count
stageChiSq <- do.call("rbind",lapply(sets2Test, function(feature) {
#
print(feature)
# Run test and return
return(TestChiSqEnrichment(freq_stageDMRs, testFeature=feature, backFeature="Genome"))
}))
## Width
# stageWidthChiSq <- do.call("rbind",lapply(sets2Test, function(feature) {
#
# #
# print(feature)
#
# # Run test and return
# return(TestChiSqEnrichment(freq_stageWidthDMRs, testFeature=feature, backFeature="Genome"))
#
# }))
# Save
colnames(stageChiSq) <- gsub("p[.]value","raw p.value", colnames(stageChiSq))
# colnames(stageWidthChiSq) <- gsub("p[.]value","raw p.value", colnames(stageWidthChiSq))
write.table(stageChiSq, paste0(dmr_dir, "stageDMROverlap_ROADMAPfeatures_featureCounts_chiSqTestResults.tsv"), sep="\t", quote=FALSE, row.names=FALSE)
# write.table(stageWidthChiSq, paste0(dmr_dir, "stageDMROverlap_ROADMAPfeatures_featuteWidths_chiSqTestResults.tsv"), sep="\t", quote=FALSE, row.names=FALSE)
```
##### Fisher's exact (per feature)
This tests for individual category-wise overlaps.
```{r}
# Stage
## Feature counts
upStageFish <- FeatureWiseFishers(inDF=freq_stageDMRs,testFeature="Up (Sig) DMRs", backFeature="All (Sig) DMRs")
dnStageFish <- FeatureWiseFishers(inDF=freq_stageDMRs,testFeature="Down (Sig) DMRs", backFeature="All (Sig) DMRs")
# Get to kbs
# freq_stageWidthDMRs_byKb <- freq_stageWidthDMRs
# freq_stageWidthDMRs_byKb["Count"] <- round( freq_stageWidthDMRs_byKb$Count / 1000 )
## Feature widths
# allStageWidthFish <- FeatureWiseFishers(inDF=freq_stageWidthDMRs_byKb,testFeature="All (Sig) DMRs", backFeature="All (Detected) DMRs", maxItems=maxCounts)
# upStageWidthFish <- FeatureWiseFishers(inDF=freq_stageWidthDMRs_byKb,testFeature="Up (Sig) DMRs", backFeature="All (Detected) DMRs", maxItems=maxCounts)
# dnStageWidthFish <- FeatureWiseFishers(inDF=freq_stageWidthDMRs_byKb,testFeature="Down (Sig) DMRs", backFeature="All (Detected) DMRs", maxItems=maxCounts)
# Sex
## Feature counts
# allSexFish <- FeatureWiseFishers(inDF=freq_sexDMRs,testFeature="All (Sig) DMRs", backFeature="All (Detected) DMRs")
# # upSexFish <- FeatureWiseFishers(inDF=freq_sexDMRs,testFeature="Up (Sig) DMRs", backFeature="All (Detected) DMRs")
# dnSexFish <- FeatureWiseFishers(inDF=freq_sexDMRs,testFeature="Down (Sig) DMRs", backFeature="All (Detected) DMRs")
#
# # Get to kbs
# freq_sexWidthDMRs_byKb <- freq_sexWidthDMRs
# freq_sexWidthDMRs_byKb["Count"] <- round( freq_sexWidthDMRs_byKb$Count / 1000 )
#
# ## Feature widths
# allSexWidthFish <- FeatureWiseFishers(inDF=freq_sexWidthDMRs_byKb,testFeature="All (Sig) DMRs", backFeature="All (Detected) DMRs", maxItems=maxCounts)
# # upSexWidthFish <- FeatureWiseFishers(inDF=freq_sexWidthDMRs_byKb,testFeature="Up (Sig) DMRs", backFeature="All (Detected) DMRs", maxItems=maxCounts)
# dnSexWidthFish <- FeatureWiseFishers(inDF=freq_sexWidthDMRs_byKb,testFeature="Down (Sig) DMRs", backFeature="All (Detected) DMRs", maxItems=maxCounts)
# Combine
StageFish <- rbind( upStageFish, dnStageFish)
# StageWidthFish <- rbind(allStageWidthFish, upStageWidthFish, dnStageWidthFish)
# SexFish <- rbind(allSexFish, dnSexFish) # upSexFish
# SexWidthFish <- rbind(allSexWidthFish, dnSexWidthFish) # upSexWidthFish
# Save
## Stage
write.table(StageFish, paste0(dmr_dir, "stageDMROverlap_ROADMAPfeatures_featureCounts_fishExactTestResults.tsv"), sep="\t", quote=FALSE, row.names=FALSE)
# write.table(StageWidthFish, paste0(dmr_dir, "stageDMROverlap_ROADMAPfeatures_featureWidthsInKb_fishExactTestResults.tsv"), sep="\t", quote=FALSE, row.names=FALSE)
# write.table(SexFish, paste0(dmr_dir, "sexDMROverlap_ROADMAPfeatures_featureCounts_fishExactTestResults.tsv"), sep="\t", quote=FALSE, row.names=FALSE)
# write.table(SexWidthFish, paste0(dmr_dir, "sexDMROverlap_ROADMAPfeatures_featureWidthsInKb_fishExactTestResults.tsv"), sep="\t", quote=FALSE, row.names=FALSE)
#
# # Check significant (with bonferonni adjustment)
# StageFish[StageFish$rawPValue < (0.05 / nrow(StageFish)),]
```
#### Plot
```{r}
# Properly order
freq_stageDMRs$Set <- factor(freq_stageDMRs$Set, levels=rev(c("All (Sig) DMRs", "Up (Sig) DMRs", "Down (Sig) DMRs", "Genome")))
# freq_sexDMRs$Set <- factor(freq_sexDMRs$Set, levels=rev(c("All (Detected) DMRs", "All (Sig) DMRs", "Up (Sig) DMRs", "Down (Sig) DMRs", "Genome")))
# freq_stageWidthDMRs$Set <- factor(freq_stageWidthDMRs$Set, levels=rev(c("All (Detected) DMRs", "All (Sig) DMRs", "Up (Sig) DMRs", "Down (Sig) DMRs", "Genome")))
# freq_sexWidthDMRs$Set <- factor(freq_sexWidthDMRs$Set, levels=rev(c("All (Detected) DMRs", "All (Sig) DMRs", "Up (Sig) DMRs", "Down (Sig) DMRs", "Genome")))
# Plot
dDMR_plt <- ggplot(freq_stageDMRs, aes(y=Set, x=Prop, fill=Feature)) +
geom_bar(stat="identity", color="black") +
scale_fill_manual(values=feat_colors) +
ylab("") + xlab("Proportion of States") +
ggtitle("Developmental Stage DMRs") +
theme_minimal(base_size=20) + theme(plot.title=element_text(size=36),
axis.title=element_text(size=32),
legend.text=element_text(size=16),
panel.grid.major.y = element_blank() ,
panel.grid.major.x = element_line( size=.1, color="darkgrey" ) )
# sDMR_plt <- ggplot(freq_sexDMRs, aes(y=Set, x=Prop, fill=Feature)) +
# geom_bar(stat="identity", color="black") +
# scale_fill_manual(values=feat_colors) +
# ylab("") + xlab("Proportion of States") +
# ggtitle("Sex DMRs") +
# theme_minimal(base_size=20) + theme(plot.title=element_text(size=36),
# axis.title=element_text(size=32),
# legend.text=element_text(size=16),
# panel.grid.major.y = element_blank() ,
# panel.grid.major.x = element_line( size=.1, color="darkgrey" ) )
# Save
ggsave(paste0(dmr_dir, "stageDMROverlap_ROADMAPfeatures_freqBarPlot.pdf"), dDMR_plt, width=4000, height=2000, units="px", device="pdf",bg="white")
# ggsave(paste0(dmr_dir, "stageDMROverlap_ROADMAPfeatures_freqBarPlot.pdf"), dDMR_plt, width=4000, height=2000, units="px", device="pdf",bg="white")
#
# ggsave(paste0(dmr_dir, "sexDMROverlap_ROADMAPfeatures_freqBarPlot.png"), sDMR_plt, width=4000, height=2000, units="px", device="png",bg="white")
# ggsave(paste0(dmr_dir, "sexDMROverlap_ROADMAPfeatures_freqBarPlot.pdf"), sDMR_plt, width=4000, height=2000, units="px", device="pdf",bg="white")
#
#
# # Plot
# dDMR_plt <- ggplot(freq_stageWidthDMRs, aes(y=Set, x=Prop, fill=Feature)) +
# geom_bar(stat="identity", color="black") +
# scale_fill_manual(values=feat_colors) +
# ylab("") + xlab("Proportion of Cumulative State Region Widths") +
# ggtitle("Developmental Stage DMRs") +
# theme_minimal(base_size=20) + theme(plot.title=element_text(size=36),
# axis.title=element_text(size=24),
# legend.text=element_text(size=16),
# panel.grid.major.y = element_blank() ,
# panel.grid.major.x = element_line( size=.1, color="darkgrey" ) )
# sDMR_plt <- ggplot(freq_sexWidthDMRs, aes(y=Set, x=Prop, fill=Feature)) +
# geom_bar(stat="identity", color="black") +
# scale_fill_manual(values=feat_colors) +
# ylab("") + xlab("Proportion of Cumulative State Region Widths") +
# ggtitle("Sex DMRs") +
# theme_minimal(base_size=20) + theme(plot.title=element_text(size=36),
# axis.title=element_text(size=24),
# legend.text=element_text(size=16),
# panel.grid.major.y = element_blank() ,
# panel.grid.major.x = element_line( size=.1, color="darkgrey" ) )
#
# # Save
# ggsave(paste0(dmr_dir, "stageDMROverlap_ROADMAPfeatures_proportionalCumulativeWidthBarPlot.png"), dDMR_plt, width=4000, height=2000, units="px", device="png",bg="white")
# ggsave(paste0(dmr_dir, "stageDMROverlap_ROADMAPfeatures_proportionalCumulativeWidthBarPlot.pdf"), dDMR_plt, width=4000, height=2000, units="px", device="pdf",bg="white")
#
# ggsave(paste0(dmr_dir, "sexDMROverlap_ROADMAPfeatures_proportionalCumulativeWidthBarPlot.png"), sDMR_plt, width=4000, height=2000, units="px", device="png",bg = "white")
# ggsave(paste0(dmr_dir, "sexDMROverlap_ROADMAPfeatures_proportionalCumulativeWidthBarPlot.pdf"), sDMR_plt, width=4000, height=2000, units="px", device="pdf",bg="white")
```