-
Notifications
You must be signed in to change notification settings - Fork 0
/
.Rhistory
512 lines (512 loc) · 38.8 KB
/
.Rhistory
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
506
507
508
509
510
511
512
overlaps_CpGs_Blueprint <- findOverlaps(Blueprint_Granges, CpGs_pchic_GRanges)
match_hit_CpGs_Blueprint <- data.frame(mcols(Blueprint_Granges[queryHits(overlaps_CpGs_Blueprint),]),
data.frame(mcols(CpGs_pchic_GRanges[subjectHits(overlaps_CpGs_Blueprint),])))
message("=== CpGs nodes associated to a promoter in blueprint data ===")
CpGs_nodes_promoter <- match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Promoter == "P", "ID"]
length(unique(CpGs_nodes_promoter))
message("=== Genes from promoter blueprint network associated to CpGsnodes from sig ===")
CpGs_promoter <- match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Promoter == "P", "Gene_name"]
length(unique(CpGs_promoter))
message("=== CPGsnodes that are NOT associated with a promoter from blueprint network ===")
CpGs_not_promoter <- match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Promoter == "O", "ID"]
length(unique(CpGs_not_promoter))
Genes_sig_CpGs_sig <- CpGs_promoter[CpGs_promoter %in% Final.Tumor.RNAseq.sig]
message("=== Number of BPmetCan promoter-associated CpGs that are in gene list from BPRNA signature ===")
length(Genes_sig_CpGs_sig)
message("=== Number of genes from CpGs sig that are in gene list from BPRNA signature ===")
length(unique(Genes_sig_CpGs_sig))
Neighbor_network <- unique(rbind(pchic[pchic$IDbait %in% match_hit_CpGs_Pchic$ID,],pchic[pchic$IDoe %in% match_hit_CpGs_Pchic$ID,]))[,c(1:3,11, 5:8,12, 10)]
colnames(Neighbor_network) <- rep(c("chr", "start", "end", "ID", "Gene_name"), 2)
Neighbor_nodes <- unique(rbind(Neighbor_network[,c(1:5)], Neighbor_network[,c(6:10)]))
# promoter dans le reseau BP qui correspondent a un cpg dans les données pchic
Promoter_neighbors <- match_hit_BP_promoter_pchic[match_hit_BP_promoter_pchic$ID %in% Neighbor_nodes$ID, ]
message("=== Number of neighbor nodes in promoter ===")
length(unique(Promoter_neighbors$ID))
message("=== Number of promoter of genes in neighbor CpGs sig ===")
Promoter_neighbors_genes <- unique(Promoter_neighbors$Gene_name)
length(Promoter_neighbors_genes)
Neighbor_not_prom_network <- unique(rbind(pchic[pchic$IDbait %in% CpGs_not_promoter,],pchic[pchic$IDoe %in% CpGs_not_promoter,]))[,c(1:3,11, 5:8,12, 10)]
colnames(Neighbor_not_prom_network) <- rep(c("chr", "start", "end", "ID", "Gene_name"), 2)
Neighbor_not_prom_nodes <- unique(rbind(Neighbor_not_prom_network[,c(1:5)], Neighbor_not_prom_network[,c(6:10)]))
# promoter dans le reseau BP qui correspondent a un cpg dans les données pchic
Promoter_neighbors_of_not_prom <- match_hit_BP_promoter_pchic[match_hit_BP_promoter_pchic$ID %in% Neighbor_not_prom_nodes$ID, ]
message("=== Number of neighbor nodes promoter from non promoter Cpg ===")
length(unique(Promoter_neighbors_of_not_prom$ID))
message("=== Number of promoter of genes in neighbor CpGs sig non promoter ===")
Promoter_neighbors_of_not_prom_genes <- unique(Promoter_neighbors_of_not_prom$Gene_name)
length(Promoter_neighbors_of_not_prom_genes)
table (Promoter_neighbors_of_not_prom_genes %in% Final.Tumor.RNAseq.sig)
ID_nodes_intersect <- match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Promoter == "P" & match_hit_CpGs_Blueprint$Gene_name %in% Final.Tumor.RNAseq.sig, "ID"]
Neighbor_intersect_signature <- unique(rbind(pchic[pchic$IDbait %in% ID_nodes_intersect,],pchic[pchic$IDoe %in% ID_nodes_intersect,]))[,c(1:3,11, 5:8,12, 10)]
colnames(Neighbor_intersect_signature) <- rep(c("chr", "start", "end", "ID", "Gene_name"), 2)
Neighbor_intersect_signature_nodes <- unique(rbind(Neighbor_intersect_signature[,c(1:5)], Neighbor_intersect_signature[,c(6:10)]))
# promoter dans le reseau BP qui correspondent a un cpg dans les données pchic
Promoter_neighbor_intersect_signature <- match_hit_BP_promoter_pchic[match_hit_BP_promoter_pchic$ID %in% Neighbor_intersect_signature_nodes$ID, ]
message("=== Number of neighbor nodes promoter from non promoter Cpg ===")
length(unique(Promoter_neighbor_intersect_signature$ID))
message("=== Number of promoter of genes in neighbor CpGs sig non promoter ===")
Promoter_neighbor_intersect_signature <- unique(Promoter_neighbor_intersect_signature$Gene_name)
length(Promoter_neighbor_intersect_signature)
table(Promoter_neighbor_intersect_signature %in% Final.Tumor.RNAseq.sig)
Promoter_neighbor_intersect_signature[Promoter_neighbor_intersect_signature %ni% Final.Tumor.RNAseq.sig & Promoter_neighbor_intersect_signature != ""]
Final.Tumor.RNAseq.sig
Promoter_neighbor_intersect_signature[Promoter_neighbor_intersect_signature %ni% Final.Tumor.RNAseq.sig & !str_detect(Promoter_neighbor_intersect_signature, ".") ]
Promoter_neighbor_intersect_signature[Promoter_neighbor_intersect_signature %ni% Final.Tumor.RNAseq.sig & str_detect(Promoter_neighbor_intersect_signature, ".") ]
Promoter_neighbor_intersect_signature[Promoter_neighbor_intersect_signature %ni% Final.Tumor.RNAseq.sig && str_detect(Promoter_neighbor_intersect_signature, ".")]
Promoter_neighbor_intersect_signature[Promoter_neighbor_intersect_signature %ni% Final.Tumor.RNAseq.sig & str_detect(".", Promoter_neighbor_intersect_signature)]
Promoter_neighbor_intersect_signature[Promoter_neighbor_intersect_signature %ni% Final.Tumor.RNAseq.sig & str_detect(Promoter_neighbor_intersect_signature, "-")]
Promoter_neighbor_intersect_signature[Promoter_neighbor_intersect_signature %ni% Final.Tumor.RNAseq.sig & !str_detect(Promoter_neighbor_intersect_signature, "-")]
Promoter_neighbor_intersect_signature[Promoter_neighbor_intersect_signature %ni% Final.Tumor.RNAseq.sig & !str_detect(Promoter_neighbor_intersect_signature, "[\.-]")]
Promoter_neighbor_intersect_signature[Promoter_neighbor_intersect_signature %ni% Final.Tumor.RNAseq.sig & !str_detect(Promoter_neighbor_intersect_signature, "[.-]")]
length(Promoter_neighbor_intersect_signature[Promoter_neighbor_intersect_signature %ni% Final.Tumor.RNAseq.sig & !str_detect(Promoter_neighbor_intersect_signature, "[.-]")])
# setwd("~/Github/Ting_signature_analyses/")
annotation_methylation_CpGs <- read.csv("BPmetCan.hg19.csv", stringsAsFactors = F)
annotation_methylation_CpGs$seqnames <- substr(annotation_methylation_CpGs$seqnames, 4, 6)
load("pchic.RData")
pchic <- data.frame(pchic[rowSums(pchic[,11:20] >= 0) >= 1, 1:10]) %>% na.omit(.)
List_Promoter <- unique(paste(pchic$baitChr, pchic$baitStart, sep = "_"))
colnames(pchic)[c(1:5, 6:10)] <- rep(c("chr", "start", "end", "ID", "Name"), 2)
PCHiC_bed <- unique(rbind(pchic[, c(1:3, 5)], pchic[, c(6:8, 10)]))
PCHiC_GRange <- GRanges(
seqnames = PCHiC_bed$chr,
IRanges(start = PCHiC_bed$start, end = PCHiC_bed$end),
Gene_Pchic = PCHiC_bed$Name,
start_fragment = PCHiC_bed$start,
end_fragment = PCHiC_bed$end
)
PCHiC_GRange$ID <- paste(PCHiC_bed$chr, PCHiC_bed$start, sep = "_")
colnames(pchic) <- c("chr_bait", "start_bait", "end_bait", "ID_bait", "Name_bait", "chr_oe", "start_oe", "end_oe", "ID_oe", "Name_oe")
pchic$IDbait <- paste(pchic$chr_bait, pchic$start_bait, sep = "_")
pchic$IDoe <- paste(pchic$chr_oe, pchic$start_oe, sep = "_")
Blueprint_network <- read.csv("BLUEPRINT_fragments_good.tsv", sep = "\t", stringsAsFactors = F)
Blueprint_network <- dplyr::select(Blueprint_network, "chr", "start", "end", "type", "ensembl", "gene_names", "intronic_regions", "type")
Blueprint_network <- Blueprint_network %>% separate_rows(., gene_names, sep = " ")
Final.Tumor.RNAseq.sig <- read.delim("BPRNACan_150.txt", stringsAsFactors = F)
Final.Tumor.RNAseq.sig <- Final.Tumor.RNAseq.sig[, "Gene"]
Blueprint_Granges <- GRanges(
seqnames = Blueprint_network$chr,
ranges = IRanges(start = Blueprint_network$start, end = Blueprint_network$end),
Gene_name = Blueprint_network$gene_names,
Promoter = Blueprint_network$type
)
overlaps_Blueprint_pchic <- findOverlaps(PCHiC_GRange, Blueprint_Granges)
# partie metadata du granges en data frame, puis merge des deux metadata de phic_grange et BP_grange
match_hit_BP_Pchic <- data.frame(mcols(PCHiC_GRange[queryHits(overlaps_Blueprint_pchic), ]),
data.frame(mcols(Blueprint_Granges[subjectHits(overlaps_Blueprint_pchic), ])),
stringsAsFactors = T)
message("=== Number of nodes in BP network ===")
length(unique(match_hit_BP_Pchic$ID))
message("== Number of promoters nodes in BP network ===")
match_hit_BP_promoter_pchic <- match_hit_BP_Pchic[match_hit_BP_Pchic$Promoter == "P",]
length(unique(match_hit_BP_promoter_pchic$ID))
Genes_BP <- unique( unlist( str_split(match_hit_BP_Pchic$Gene_name, " ") ) )
Genes_BP_Promoter_signature <- Genes_BP[Genes_BP %in% Final.Tumor.RNAseq.sig]
message("== Number of Promoter in BPRNACan signature ==")
length(Genes_BP_Promoter_signature)
CpGs_GRanges <- GRanges(
seqnames = annotation_methylation_CpGs$seqnames,
ranges = IRanges(start = annotation_methylation_CpGs$start, end = annotation_methylation_CpGs$end),
chr_cpg = annotation_methylation_CpGs$seqnames
)
overlaps_CpGs_pchic <- findOverlaps(PCHiC_GRange, CpGs_GRanges)
match_hit_CpGs_Pchic <- data.frame(mcols(PCHiC_GRange[queryHits(overlaps_CpGs_pchic),]), data.frame(mcols(CpGs_GRanges[subjectHits(overlaps_CpGs_pchic),])))
message("=== Number of CpGs from BPmetCan matching a node in the network ===")
length(unique(match_hit_CpGs_Pchic$ID))
CpGs_pchic_GRanges <- GRanges(
seqnames = match_hit_CpGs_Pchic$chr_cpg,
ranges = IRanges(start = match_hit_CpGs_Pchic$start_fragment, end = match_hit_CpGs_Pchic$end_fragment),
chr_cpg = match_hit_CpGs_Pchic$chr_cpg,
ID = match_hit_CpGs_Pchic$ID
)
overlaps_CpGs_Blueprint <- findOverlaps(Blueprint_Granges, CpGs_pchic_GRanges)
match_hit_CpGs_Blueprint <- data.frame(mcols(Blueprint_Granges[queryHits(overlaps_CpGs_Blueprint),]),
data.frame(mcols(CpGs_pchic_GRanges[subjectHits(overlaps_CpGs_Blueprint),])))
message("=== CpGs nodes associated to a promoter in blueprint data ===")
CpGs_nodes_promoter <- match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Promoter == "P", "ID"]
length(unique(CpGs_nodes_promoter))
message("=== Genes from promoter blueprint network associated to CpGsnodes from sig ===")
CpGs_promoter <- match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Promoter == "P", "Gene_name"]
length(unique(CpGs_promoter))
message("=== CPGsnodes that are NOT associated with a promoter from blueprint network ===")
CpGs_not_promoter <- match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Promoter == "O", "ID"]
length(unique(CpGs_not_promoter))
CpGs_pchic_GRanges <- GRanges(
seqnames = match_hit_CpGs_Pchic$chr_cpg,
ranges = IRanges(start = match_hit_CpGs_Pchic$start_fragment, end = match_hit_CpGs_Pchic$end_fragment),
chr_cpg = match_hit_CpGs_Pchic$chr_cpg,
ID = match_hit_CpGs_Pchic$ID
)
overlaps_CpGs_Blueprint <- findOverlaps(Blueprint_Granges, CpGs_pchic_GRanges)
match_hit_CpGs_Blueprint <- data.frame(mcols(Blueprint_Granges[queryHits(overlaps_CpGs_Blueprint),]),
data.frame(mcols(CpGs_pchic_GRanges[subjectHits(overlaps_CpGs_Blueprint),])))
message("=== CpGs nodes associated to a promoter in blueprint data ===")
CpGs_nodes_promoter <- match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Promoter == "P", "ID"]
length(unique(CpGs_nodes_promoter))
message("=== Genes from promoter blueprint network associated to CpGsnodes from sig ===")
CpGs_promoter <- match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Promoter == "P", "Gene_name"]
length(unique(CpGs_promoter))
message("=== CPGsnodes that are NOT associated with a promoter from blueprint network ===")
CpGs_not_promoter <- match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Promoter == "O", "ID"]
length(unique(CpGs_not_promoter))
779+348
# setwd("~/Github/Ting_signature_analyses/")
annotation_methylation_CpGs <- read.csv("BPmetCan.hg19.csv", stringsAsFactors = F)
annotation_methylation_CpGs$seqnames <- substr(annotation_methylation_CpGs$seqnames, 4, 6)
load("pchic.RData")
pchic <- data.frame(pchic[rowSums(pchic[,11:20] >= 0) >= 1, 1:10]) %>% na.omit(.)
List_Promoter <- unique(paste(pchic$baitChr, pchic$baitStart, sep = "_"))
colnames(pchic)[c(1:5, 6:10)] <- rep(c("chr", "start", "end", "ID", "Name"), 2)
PCHiC_bed <- unique(rbind(pchic[, c(1:3, 5)], pchic[, c(6:8, 10)]))
PCHiC_GRange <- GRanges(
seqnames = PCHiC_bed$chr,
IRanges(start = PCHiC_bed$start, end = PCHiC_bed$end),
Gene_Pchic = PCHiC_bed$Name,
start_fragment = PCHiC_bed$start,
end_fragment = PCHiC_bed$end
)
PCHiC_GRange$ID <- paste(PCHiC_bed$chr, PCHiC_bed$start, sep = "_")
colnames(pchic) <- c("chr_bait", "start_bait", "end_bait", "ID_bait", "Name_bait", "chr_oe", "start_oe", "end_oe", "ID_oe", "Name_oe")
pchic$IDbait <- paste(pchic$chr_bait, pchic$start_bait, sep = "_")
pchic$IDoe <- paste(pchic$chr_oe, pchic$start_oe, sep = "_")
Blueprint_network <- read.csv("BLUEPRINT_fragments_good.tsv", sep = "\t", stringsAsFactors = F)
Blueprint_network <- dplyr::select(Blueprint_network, "chr", "start", "end", "type", "ensembl", "gene_names", "intronic_regions", "type")
Blueprint_network <- Blueprint_network %>% separate_rows(., gene_names, sep = " ")
Final.Tumor.RNAseq.sig <- read.delim("BPRNACan_150.txt", stringsAsFactors = F)
Final.Tumor.RNAseq.sig <- Final.Tumor.RNAseq.sig[, "Gene"]
Blueprint_Granges <- GRanges(
seqnames = Blueprint_network$chr,
ranges = IRanges(start = Blueprint_network$start, end = Blueprint_network$end),
Gene_name = Blueprint_network$gene_names,
Promoter = Blueprint_network$type
)
overlaps_Blueprint_pchic <- findOverlaps(PCHiC_GRange, Blueprint_Granges)
# partie metadata du granges en data frame, puis merge des deux metadata de phic_grange et BP_grange
match_hit_BP_Pchic <- data.frame(mcols(PCHiC_GRange[queryHits(overlaps_Blueprint_pchic), ]),
data.frame(mcols(Blueprint_Granges[subjectHits(overlaps_Blueprint_pchic), ])),
stringsAsFactors = T)
message("=== Number of nodes in BP network ===")
length(unique(match_hit_BP_Pchic$ID))
message("== Number of promoters nodes in BP network ===")
match_hit_BP_promoter_pchic <- match_hit_BP_Pchic[match_hit_BP_Pchic$Promoter == "P",]
length(unique(match_hit_BP_promoter_pchic$ID))
Genes_BP <- unique( unlist( str_split(match_hit_BP_Pchic$Gene_name, " ") ) )
Genes_BP_Promoter_signature <- Genes_BP[Genes_BP %in% Final.Tumor.RNAseq.sig]
message("== Number of Promoter in BPRNACan signature ==")
length(Genes_BP_Promoter_signature)
View(Blueprint_network)
20582-249511
overlaps_Blueprint_pchic <- findOverlaps(PCHiC_GRange, Blueprint_Granges)
# partie metadata du granges en data frame, puis merge des deux metadata de phic_grange et BP_grange
match_hit_BP_Pchic <- data.frame(mcols(PCHiC_GRange[queryHits(overlaps_Blueprint_pchic), ]),
data.frame(mcols(Blueprint_Granges[subjectHits(overlaps_Blueprint_pchic), ])),
stringsAsFactors = T)
message("=== Number of nodes in BP network ===")
length(unique(match_hit_BP_Pchic$ID))
message("== Number of promoters nodes in BP network ===")
match_hit_BP_promoter_pchic <- match_hit_BP_Pchic[match_hit_BP_Pchic$Promoter == "P",]
length(unique(match_hit_BP_promoter_pchic$ID))
Genes_BP <- unique( unlist( str_split(match_hit_BP_Pchic$Gene_name, " ") ) )
Genes_BP_Promoter_signature <- Genes_BP[Genes_BP %in% Final.Tumor.RNAseq.sig]
message("== Number of Promoter in BPRNACan signature ==")
length(Genes_BP_Promoter_signature)
CpGs_GRanges <- GRanges(
seqnames = annotation_methylation_CpGs$seqnames,
ranges = IRanges(start = annotation_methylation_CpGs$start, end = annotation_methylation_CpGs$end),
chr_cpg = annotation_methylation_CpGs$seqnames
)
overlaps_CpGs_pchic <- findOverlaps(PCHiC_GRange, CpGs_GRanges)
match_hit_CpGs_Pchic <- data.frame(mcols(PCHiC_GRange[queryHits(overlaps_CpGs_pchic),]), data.frame(mcols(CpGs_GRanges[subjectHits(overlaps_CpGs_pchic),])))
message("=== Number of CpGs from BPmetCan matching a node in the network ===")
length(unique(match_hit_CpGs_Pchic$ID))
CpGs_pchic_GRanges <- GRanges(
seqnames = match_hit_CpGs_Pchic$chr_cpg,
ranges = IRanges(start = match_hit_CpGs_Pchic$start_fragment, end = match_hit_CpGs_Pchic$end_fragment),
chr_cpg = match_hit_CpGs_Pchic$chr_cpg,
ID = match_hit_CpGs_Pchic$ID
)
overlaps_CpGs_Blueprint <- findOverlaps(Blueprint_Granges, CpGs_pchic_GRanges)
match_hit_CpGs_Blueprint <- data.frame(mcols(Blueprint_Granges[queryHits(overlaps_CpGs_Blueprint),]),
data.frame(mcols(CpGs_pchic_GRanges[subjectHits(overlaps_CpGs_Blueprint),])))
message("=== CpGs nodes associated to a promoter in blueprint data ===")
CpGs_nodes_promoter <- match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Promoter == "P", "ID"]
length(unique(CpGs_nodes_promoter))
message("=== Genes from promoter blueprint network associated to CpGsnodes from sig ===")
CpGs_promoter <- match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Promoter == "P", "Gene_name"]
length(unique(CpGs_promoter))
message("=== CPGsnodes that are NOT associated with a promoter from blueprint network ===")
CpGs_not_promoter <- match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Promoter == "O", "ID"]
length(unique(CpGs_not_promoter))
Genes_sig_CpGs_sig <- CpGs_promoter[CpGs_promoter %in% Final.Tumor.RNAseq.sig]
message("=== Number of BPmetCan promoter-associated CpGs that are in gene list from BPRNA signature ===")
length(Genes_sig_CpGs_sig)
message("=== Number of genes from CpGs sig that are in gene list from BPRNA signature ===")
length(unique(Genes_sig_CpGs_sig))
Neighbor_network <- unique(rbind(pchic[pchic$IDbait %in% match_hit_CpGs_Pchic$ID,],pchic[pchic$IDoe %in% match_hit_CpGs_Pchic$ID,]))[,c(1:3,11, 5:8,12, 10)]
colnames(Neighbor_network) <- rep(c("chr", "start", "end", "ID", "Gene_name"), 2)
Neighbor_nodes <- unique(rbind(Neighbor_network[,c(1:5)], Neighbor_network[,c(6:10)]))
# promoter dans le reseau BP qui correspondent a un cpg dans les données pchic
Promoter_neighbors <- match_hit_BP_promoter_pchic[match_hit_BP_promoter_pchic$ID %in% Neighbor_nodes$ID, ]
message("=== Number of neighbor nodes in promoter ===")
length(unique(Promoter_neighbors$ID))
message("=== Number of promoter of genes in neighbor CpGs sig ===")
Promoter_neighbors_genes <- unique(Promoter_neighbors$Gene_name)
length(Promoter_neighbors_genes)
Neighbor_not_prom_network <- unique(rbind(pchic[pchic$IDbait %in% CpGs_not_promoter,],pchic[pchic$IDoe %in% CpGs_not_promoter,]))[,c(1:3,11, 5:8,12, 10)]
colnames(Neighbor_not_prom_network) <- rep(c("chr", "start", "end", "ID", "Gene_name"), 2)
Neighbor_not_prom_nodes <- unique(rbind(Neighbor_not_prom_network[,c(1:5)], Neighbor_not_prom_network[,c(6:10)]))
# promoter dans le reseau BP qui correspondent a un cpg dans les données pchic
Promoter_neighbors_of_not_prom <- match_hit_BP_promoter_pchic[match_hit_BP_promoter_pchic$ID %in% Neighbor_not_prom_nodes$ID, ]
message("=== Number of neighbor nodes promoter from non promoter Cpg ===")
length(unique(Promoter_neighbors_of_not_prom$ID))
message("=== Number of promoter of genes in neighbor CpGs sig non promoter ===")
Promoter_neighbors_of_not_prom_genes <- unique(Promoter_neighbors_of_not_prom$Gene_name)
length(Promoter_neighbors_of_not_prom_genes)
table (Promoter_neighbors_of_not_prom_genes %in% Final.Tumor.RNAseq.sig)
ID_nodes_intersect <- match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Promoter == "P" & match_hit_CpGs_Blueprint$Gene_name %in% Final.Tumor.RNAseq.sig, "ID"]
Neighbor_intersect_signature <- unique(rbind(pchic[pchic$IDbait %in% ID_nodes_intersect,],pchic[pchic$IDoe %in% ID_nodes_intersect,]))[,c(1:3,11, 5:8,12, 10)]
colnames(Neighbor_intersect_signature) <- rep(c("chr", "start", "end", "ID", "Gene_name"), 2)
Neighbor_intersect_signature_nodes <- unique(rbind(Neighbor_intersect_signature[,c(1:5)], Neighbor_intersect_signature[,c(6:10)]))
# promoter dans le reseau BP qui correspondent a un cpg dans les données pchic
Promoter_neighbor_intersect_signature <- match_hit_BP_promoter_pchic[match_hit_BP_promoter_pchic$ID %in% Neighbor_intersect_signature_nodes$ID, ]
message("=== Number of neighbor nodes promoter from non promoter Cpg ===")
length(unique(Promoter_neighbor_intersect_signature$ID))
message("=== Number of promoter of genes in neighbor CpGs sig non promoter ===")
Promoter_neighbor_intersect_signature <- unique(Promoter_neighbor_intersect_signature$Gene_name)
length(Promoter_neighbor_intersect_signature)
table(Promoter_neighbor_intersect_signature %in% Final.Tumor.RNAseq.sig)
length(Promoter_neighbor_intersect_signature[Promoter_neighbor_intersect_signature %ni% Final.Tumor.RNAseq.sig & !str_detect(Promoter_neighbor_intersect_signature, "[.-]")])
Promoter_neighbors_genes_sig <- Promoter_neighbors_genes[Promoter_neighbors_genes %in% Final.Tumor.RNAseq.sig]
message("=== Number of promoters from BPRNA signature genes in neighborhood of CpGs sig ===")
length(unique(Promoter_neighbors_genes_sig))
unik_CpGs_promoter <- unique(CpGs_promoter)
solo_genes <- unik_CpGs_promoter[unik_CpGs_promoter %ni% Final.Tumor.RNAseq.sig]
message("=== Genes associated with a promoter in BPmetCan, that are not present in BPRNACan ===")
length(solo_genes)
solo_genes
genes_for_GO <- unique( unlist( str_split(Promoter_neighbors_genes, " ") ) )
write.table(genes_for_GO, "cpgs_genes.txt", row.names = F, col.names = F, quote = F)
# launch on pantherDB http://geneontology.org
GO <-read.table("analysis.txt", sep="\t", header=T, skip = 11)[,c(1,7)]
sessionInfo()
ID_nodes_intersect <- match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Promoter == "P" & match_hit_CpGs_Blueprint$Gene_name %in% Final.Tumor.RNAseq.sig, "ID"]
Neighbor_intersect_signature <- unique(rbind(pchic[pchic$IDbait %in% ID_nodes_intersect,],pchic[pchic$IDoe %in% ID_nodes_intersect,]))[,c(1:3,11, 5:8,12, 10)]
colnames(Neighbor_intersect_signature) <- rep(c("chr", "start", "end", "ID", "Gene_name"), 2)
Neighbor_intersect_signature_nodes <- unique(rbind(Neighbor_intersect_signature[,c(1:5)], Neighbor_intersect_signature[,c(6:10)]))
# promoter dans le reseau BP qui correspondent a un cpg dans les données pchic
Promoter_neighbor_intersect_signature <- match_hit_BP_promoter_pchic[match_hit_BP_promoter_pchic$ID %in% Neighbor_intersect_signature_nodes$ID, ]
message("=== Number of neighbor nodes promoter from non promoter Cpg ===")
length(unique(Promoter_neighbor_intersect_signature$ID))
message("=== Number of promoter of genes in neighbor CpGs sig non promoter ===")
Promoter_neighbor_intersect_signature <- unique(Promoter_neighbor_intersect_signature$Gene_name)
length(Promoter_neighbor_intersect_signature)
table(Promoter_neighbor_intersect_signature %in% Final.Tumor.RNAseq.sig)
length(Promoter_neighbor_intersect_signature[Promoter_neighbor_intersect_signature %ni% Final.Tumor.RNAseq.sig & !str_detect(Promoter_neighbor_intersect_signature, "[.-]")])
ID_nodes_intersect <- match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Promoter == "P" & match_hit_CpGs_Blueprint$Gene_name %in% Final.Tumor.RNAseq.sig, "ID"]
Neighbor_intersect_signature <- unique(rbind(pchic[pchic$IDbait %in% ID_nodes_intersect,],pchic[pchic$IDoe %in% ID_nodes_intersect,]))[,c(1:3,11, 5:8,12, 10)]
colnames(Neighbor_intersect_signature) <- rep(c("chr", "start", "end", "ID", "Gene_name"), 2)
Neighbor_intersect_signature_nodes <- unique(rbind(Neighbor_intersect_signature[,c(1:5)], Neighbor_intersect_signature[,c(6:10)]))
# promoter dans le reseau BP qui correspondent a un cpg dans les données pchic
Promoter_neighbor_intersect_signature <- match_hit_BP_promoter_pchic[match_hit_BP_promoter_pchic$ID %in% Neighbor_intersect_signature_nodes$ID, ]
message("=== Number of neighbor nodes of the CpGs sig in promoter of Genes from the signature ===")
length(unique(Promoter_neighbor_intersect_signature$ID))
message("=== Number of promoter of genes in neighbor CpGs sig of Genes from the signature ===")
Promoter_neighbor_intersect_signature <- unique(Promoter_neighbor_intersect_signature$Gene_name)
length(Promoter_neighbor_intersect_signature)
table(Promoter_neighbor_intersect_signature %in% Final.Tumor.RNAseq.sig)
length(Promoter_neighbor_intersect_signature[Promoter_neighbor_intersect_signature %ni% Final.Tumor.RNAseq.sig & !str_detect(Promoter_neighbor_intersect_signature, "[.-]")])
255-132
76+52
132
128+132
132+76+52
Promoter_neighbors_genes_sig <- Promoter_neighbors_genes[Promoter_neighbors_genes %in% Final.Tumor.RNAseq.sig]
message("=== Number of promoters from BPRNA signature genes in neighborhood of CpGs sig ===")
length(unique(Promoter_neighbors_genes_sig))
Blueprint_network <- read.csv("BLUEPRINT_fragments_good.tsv", sep = "\t", stringsAsFactors = F) %>%
dplyr::select(., "chr", "start", "end", "type", "ensembl", "gene_names", "intronic_regions", "type") %>%
separate_rows(., gene_names, sep = " ")
View(Blueprint_network)
Final.Tumor.RNAseq.sig <- read.delim("BPRNACan_150.txt", stringsAsFactors = F) %>%
.[, "Gene"]
match_hit_BP_Pchic$Gene_name
Genes_BP <- unique(match_hit_BP_Pchic$Gene_name)
Genes_BP
Genes_BP_Promoter_signature <- Genes_BP[Genes_BP %in% Final.Tumor.RNAseq.sig]
Genes_BP_Promoter_signature
overlaps_Blueprint_pchic <- findOverlaps(PCHiC_GRange, Blueprint_Granges)
# partie metadata du granges en data frame, puis merge des deux metadata de phic_grange et BP_grange
match_hit_BP_Pchic <- data.frame(mcols(PCHiC_GRange[queryHits(overlaps_Blueprint_pchic), ]),
data.frame(mcols(Blueprint_Granges[subjectHits(overlaps_Blueprint_pchic), ])),
stringsAsFactors = T)
message("=== Number of nodes in BP network ===")
Nodes_in_BP_network <- unique(match_hit_BP_Pchic$ID)
length(Nodes_in_BP_network)
message("== Number of promoters nodes in BP network ===")
match_hit_BP_promoter_pchic <- match_hit_BP_Pchic[match_hit_BP_Pchic$Promoter == "P",]
Nodes_in_BP_Promoter <- unique(match_hit_BP_promoter_pchic$ID)
length(Nodes_in_BP_Promoter)
Genes_BP <- unique(match_hit_BP_Pchic$Gene_name)
Genes_BP_Promoter_signature <- Genes_BP[Genes_BP %in% Final.Tumor.RNAseq.sig]
message("== Number of Promoter in BPRNACan signature ==")
length(Genes_BP_Promoter_signature)
CpGs_GRanges <- GRanges(
seqnames = annotation_methylation_CpGs$seqnames,
ranges = IRanges(start = annotation_methylation_CpGs$start, end = annotation_methylation_CpGs$end),
chr_cpg = annotation_methylation_CpGs$seqnames
)
overlaps_CpGs_pchic <- findOverlaps(PCHiC_GRange, CpGs_GRanges)
match_hit_CpGs_Pchic <- data.frame(mcols(PCHiC_GRange[queryHits(overlaps_CpGs_pchic),]), data.frame(mcols(CpGs_GRanges[subjectHits(overlaps_CpGs_pchic),])))
message("=== Number of CpGs from BPmetCan matching a node in the network ===")
Nodes_in_CpG <- unique(match_hit_CpGs_Pchic$ID)
length(Nodes_in_CpG)
CpGs_pchic_GRanges <- GRanges(
seqnames = match_hit_CpGs_Pchic$chr_cpg,
ranges = IRanges(start = match_hit_CpGs_Pchic$start_fragment, end = match_hit_CpGs_Pchic$end_fragment),
chr_cpg = match_hit_CpGs_Pchic$chr_cpg,
ID = match_hit_CpGs_Pchic$ID
)
overlaps_CpGs_Blueprint <- findOverlaps(Blueprint_Granges, CpGs_pchic_GRanges)
match_hit_CpGs_Blueprint <- data.frame(mcols(Blueprint_Granges[queryHits(overlaps_CpGs_Blueprint),]),
data.frame(mcols(CpGs_pchic_GRanges[subjectHits(overlaps_CpGs_Blueprint),])))
message("=== CpGs nodes associated to a promoter in blueprint data ===")
CpGs_nodes_promoter <- unique(match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Promoter == "P", "ID"])
length(CpGs_nodes_promoter)
message("=== Genes from promoter blueprint network associated to CpGsnodes from sig ===")
CpGs_promoter <- unique(match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Promoter == "P", "Gene_name"])
length(CpGs_promoter)
message("=== CPGsnodes that are NOT associated with a promoter from blueprint network ===")
CpGs_not_promoter <- unique(match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Promoter == "O", "ID"])
length(CpGs_not_promoter)
Genes_sig_CpGs_sig <- CpGs_promoter[CpGs_promoter %in% Final.Tumor.RNAseq.sig]
message("=== Number of BPmetCan promoter-associated CpGs that are in gene list from BPRNA signature ===")
length(Genes_sig_CpGs_sig)
message("=== Number of genes from CpGs sig that are in gene list from BPRNA signature ===")
length(unique(Genes_sig_CpGs_sig))
Genes_sig_CpGs_sig <- match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Gene_name %in% Final.Tumor.RNAseq.sig & match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Promoter == "P"], "Gene_name"]
Genes_sig_CpGs_sig <- match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Gene_name %in% Final.Tumor.RNAseq.sig & match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Promoter == "P",], "Gene_name"]
Genes_sig_CpGs_sig <- match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Gene_name %in% Final.Tumor.RNAseq.sig & match_hit_CpGs_Blueprint$Promoter == "P", "Gene_name"]
Nodes_with_CpGs_sig_and_gene_sig <- match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Gene_name %in% Final.Tumor.RNAseq.sig & match_hit_CpGs_Blueprint$Promoter == "P", "Gene_name"]
message("=== Number of BPmetCan promoter-associated CpGs nodes that are in gene list from BPRNA signature ===")
length(Nodes_with_CpGs_sig_and_gene_sig)
message("=== Number of genes from CpGs sig that are in gene list from BPRNA signature ===")
length(unique(Genes_sig_CpGs_sig))
Neighbor_network <- unique(rbind(pchic[pchic$IDbait %in% match_hit_CpGs_Pchic$ID,],pchic[pchic$IDoe %in% match_hit_CpGs_Pchic$ID,]))[,c(1:3,11, 5:8,12, 10)]
colnames(Neighbor_network) <- rep(c("chr", "start", "end", "ID", "Gene_name"), 2)
Neighbor_nodes <- unique(rbind(Neighbor_network[,c(1:5)], Neighbor_network[,c(6:10)]))
# promoter dans le reseau BP qui correspondent a un cpg dans les données pchic
Promoter_neighbors <- match_hit_BP_promoter_pchic[match_hit_BP_promoter_pchic$ID %in% Neighbor_nodes$ID, ]
message("=== Number of neighbor nodes in promoter ===")
Nodes_promoter_neighbor_CpG_sig <- unique(Promoter_neighbors$ID)
length(Nodes_promoter_neighbor_CpG_sig)
message("=== Number of promoter of genes in neighbor CpGs sig ===")
Promoter_neighbors_genes <- unique(Promoter_neighbors$Gene_name)
length(Promoter_neighbors_genes)
Neighbor_network <- unique(rbind(pchic[pchic$IDbait %in% match_hit_CpGs_Pchic$ID,],pchic[pchic$IDoe %in% match_hit_CpGs_Pchic$ID,]))[,c(1:3,11, 5:8,12, 10)]
colnames(Neighbor_network) <- rep(c("chr", "start", "end", "ID", "Gene_name"), 2)
Neighbor_nodes <- unique(rbind(Neighbor_network[,c(1:5)], Neighbor_network[,c(6:10)]))
# promoter dans le reseau BP qui correspondent a un cpg dans les données pchic
Promoter_neighbors <- match_hit_BP_promoter_pchic[match_hit_BP_promoter_pchic$ID %in% Neighbor_nodes$ID, ]
message("=== Number of neighbor nodes of CpGs sig in promoter ===")
Nodes_promoter_neighbor_CpG_sig <- unique(Promoter_neighbors$ID)
length(Nodes_promoter_neighbor_CpG_sig)
message("=== Number of promoter of genes in neighbor CpGs sig ===")
Promoter_neighbors_genes <- unique(Promoter_neighbors$Gene_name)
length(Promoter_neighbors_genes)
Neighbor_not_prom_network <- unique(rbind(pchic[pchic$IDbait %in% CpGs_not_promoter,],pchic[pchic$IDoe %in% CpGs_not_promoter,]))[,c(1:3,11, 5:8,12, 10)]
colnames(Neighbor_not_prom_network) <- rep(c("chr", "start", "end", "ID", "Gene_name"), 2)
Neighbor_not_prom_nodes <- unique(rbind(Neighbor_not_prom_network[,c(1:5)], Neighbor_not_prom_network[,c(6:10)]))
# promoter dans le reseau BP qui correspondent a un cpg dans les données pchic
Promoter_neighbors_of_not_prom <- match_hit_BP_promoter_pchic[match_hit_BP_promoter_pchic$ID %in% Neighbor_not_prom_nodes$ID, ]
message("=== Number of neighbor nodes promoter from non promoter Cpg ===")
length(unique(Promoter_neighbors_of_not_prom$ID))
message("=== Number of promoter of genes in neighbor CpGs sig non promoter ===")
Promoter_neighbors_of_not_prom_genes <- unique(Promoter_neighbors_of_not_prom$Gene_name)
length(Promoter_neighbors_of_not_prom_genes)
table (Promoter_neighbors_of_not_prom_genes %in% Final.Tumor.RNAseq.sig)
Neighbor_not_prom_network <- unique(rbind(pchic[pchic$IDbait %in% CpGs_not_promoter,],pchic[pchic$IDoe %in% CpGs_not_promoter,]))[,c(1:3,11, 5:8,12, 10)]
colnames(Neighbor_not_prom_network) <- rep(c("chr", "start", "end", "ID", "Gene_name"), 2)
Neighbor_not_prom_nodes <- unique(rbind(Neighbor_not_prom_network[,c(1:5)], Neighbor_not_prom_network[,c(6:10)]))
Promoter_neighbors_of_not_prom <- match_hit_BP_promoter_pchic[match_hit_BP_promoter_pchic$ID %in% Neighbor_not_prom_nodes$ID, ]
message("=== Number of neighbor nodes promoter from non promoter Cpg ===")
Nodes_neighbor_non_prom_CpGs_sig <- unique(Promoter_neighbors_of_not_prom$ID)
length(Nodes_neighbor_non_prom_CpGs_sig)
message("=== Number of promoter of genes in neighbor CpGs sig non promoter ===")
Promoter_neighbors_of_not_prom_genes <- unique(Promoter_neighbors_of_not_prom$Gene_name)
length(Promoter_neighbors_of_not_prom_genes)
table (Promoter_neighbors_of_not_prom_genes %in% Final.Tumor.RNAseq.sig)
Non_sig_genes_CpGs_neighbor <- Promoter_neighbors_of_not_prom_genes[Promoter_neighbors_of_not_prom_genes %ni% Final.Tumor.RNAseq.sig]
length(Non_sig_genes_CpGs_neighbor)
table (Promoter_neighbors_of_not_prom_genes %in% Final.Tumor.RNAseq.sig)
Neighbor_not_prom_network <- unique(rbind(pchic[pchic$IDbait %in% CpGs_not_promoter,],pchic[pchic$IDoe %in% CpGs_not_promoter,]))[,c(1:3,11, 5:8,12, 10)]
colnames(Neighbor_not_prom_network) <- rep(c("chr", "start", "end", "ID", "Gene_name"), 2)
Neighbor_not_prom_nodes <- unique(rbind(Neighbor_not_prom_network[,c(1:5)], Neighbor_not_prom_network[,c(6:10)]))
Promoter_neighbors_of_not_prom <- match_hit_BP_promoter_pchic[match_hit_BP_promoter_pchic$ID %in% Neighbor_not_prom_nodes$ID, ]
message("=== Number of neighbor nodes promoter from non promoter Cpg ===")
Nodes_neighbor_non_prom_CpGs_sig <- unique(Promoter_neighbors_of_not_prom$ID)
length(Nodes_neighbor_non_prom_CpGs_sig)
message("=== Number of genes in neighbor CpGs sig non promoter ===")
Promoter_neighbors_of_not_prom_genes <- unique(Promoter_neighbors_of_not_prom$Gene_name)
length(Promoter_neighbors_of_not_prom_genes)
message("=== Number of non sig genes in the neighborhood of CpGs sig non promoter ===")
Non_sig_genes_CpGs_neighbor <- Promoter_neighbors_of_not_prom_genes[Promoter_neighbors_of_not_prom_genes %ni% Final.Tumor.RNAseq.sig]
length(Non_sig_genes_CpGs_neighbor)
table (Promoter_neighbors_of_not_prom_genes %in% Final.Tumor.RNAseq.sig)
ID_nodes_intersect <- match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Promoter == "P" & match_hit_CpGs_Blueprint$Gene_name %in% Final.Tumor.RNAseq.sig, "ID"]
Neighbor_intersect_signature <- unique(rbind(pchic[pchic$IDbait %in% ID_nodes_intersect,],pchic[pchic$IDoe %in% ID_nodes_intersect,]))[,c(1:3,11, 5:8,12, 10)]
colnames(Neighbor_intersect_signature) <- rep(c("chr", "start", "end", "ID", "Gene_name"), 2)
Neighbor_intersect_signature_nodes <- unique(rbind(Neighbor_intersect_signature[,c(1:5)], Neighbor_intersect_signature[,c(6:10)]))
# promoter dans le reseau BP qui correspondent a un cpg dans les données pchic
Promoter_neighbor_intersect_signature <- match_hit_BP_promoter_pchic[match_hit_BP_promoter_pchic$ID %in% Neighbor_intersect_signature_nodes$ID, ]
message("=== Number of neighbor nodes of the CpGs sig in promoter of Genes from the signature ===")
length(unique(Promoter_neighbor_intersect_signature$ID))
message("=== Number of promoter of genes in neighbor CpGs sig of Genes from the signature ===")
Promoter_neighbor_intersect_signature <- unique(Promoter_neighbor_intersect_signature$Gene_name)
length(Promoter_neighbor_intersect_signature)
table(Promoter_neighbor_intersect_signature %in% Final.Tumor.RNAseq.sig)
length(Promoter_neighbor_intersect_signature[Promoter_neighbor_intersect_signature %ni% Final.Tumor.RNAseq.sig & !str_detect(Promoter_neighbor_intersect_signature, "[.-]")])
Nodes_intersect <- match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Promoter == "P" & match_hit_CpGs_Blueprint$Gene_name %in% Final.Tumor.RNAseq.sig, "ID"]
Neighbor_intersect_signature <- unique(rbind(pchic[pchic$IDbait %in% Nodes_intersect,],pchic[pchic$IDoe %in% Nodes_intersect,]))[,c(1:3,11, 5:8,12, 10)]
colnames(Neighbor_intersect_signature) <- rep(c("chr", "start", "end", "ID", "Gene_name"), 2)
Neighbor_intersect_signature_nodes <- unique(rbind(Neighbor_intersect_signature[,c(1:5)], Neighbor_intersect_signature[,c(6:10)]))
Promoter_neighbor_intersect_signature <- match_hit_BP_promoter_pchic[match_hit_BP_promoter_pchic$ID %in% Neighbor_intersect_signature_nodes$ID, ]
message("=== Number of neighbor nodes of the CpGs sig in promoter of Genes from the signature ===")
length(unique(Promoter_neighbor_intersect_signature$ID))
message("=== Number of promoter of genes in neighbor CpGs sig of Genes from the signature ===")
Promoter_neighbor_intersect_signature <- unique(Promoter_neighbor_intersect_signature$Gene_name)
length(Promoter_neighbor_intersect_signature)
table(Promoter_neighbor_intersect_signature %in% Final.Tumor.RNAseq.sig)
length(Promoter_neighbor_intersect_signature[Promoter_neighbor_intersect_signature %ni% Final.Tumor.RNAseq.sig & !str_detect(Promoter_neighbor_intersect_signature, "[.-]")])
Nodes_intersect <- match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Promoter == "P" & match_hit_CpGs_Blueprint$Gene_name %in% Final.Tumor.RNAseq.sig, "ID"]
Neighbor_intersect_signature <- unique(rbind(pchic[pchic$IDbait %in% Nodes_intersect,],pchic[pchic$IDoe %in% Nodes_intersect,]))[,c(1:3,11, 5:8,12, 10)]
colnames(Neighbor_intersect_signature) <- rep(c("chr", "start", "end", "ID", "Gene_name"), 2)
Neighbor_intersect_signature_nodes <- unique(rbind(Neighbor_intersect_signature[,c(1:5)], Neighbor_intersect_signature[,c(6:10)]))
Promoter_neighbor_intersect_signature <- match_hit_BP_promoter_pchic[match_hit_BP_promoter_pchic$ID %in% Neighbor_intersect_signature_nodes$ID, ]
message("=== Number of neighbor nodes of the CpGs sig in promoter of Genes from the signature ===")
Nodes_neigbhor_intersection_CpGs_genes_sig <- unique(Promoter_neighbor_intersect_signature$ID)
length(Nodes_neigbhor_intersection_CpGs_genes_sig)
message("=== Number of promoter of genes in neighbor CpGs sig of Genes from the signature ===")
Promoter_neighbor_intersect_signature <- unique(Promoter_neighbor_intersect_signature$Gene_name)
length(Promoter_neighbor_intersect_signature)
table(Promoter_neighbor_intersect_signature %in% Final.Tumor.RNAseq.sig)
length(Promoter_neighbor_intersect_signature[Promoter_neighbor_intersect_signature %ni% Final.Tumor.RNAseq.sig & !str_detect(Promoter_neighbor_intersect_signature, "[.-]")])
Nodes_intersect <- match_hit_CpGs_Blueprint[match_hit_CpGs_Blueprint$Promoter == "P" & match_hit_CpGs_Blueprint$Gene_name %in% Final.Tumor.RNAseq.sig, "ID"]
Neighbor_intersect_signature <- unique(rbind(pchic[pchic$IDbait %in% Nodes_intersect,],pchic[pchic$IDoe %in% Nodes_intersect,]))[,c(1:3,11, 5:8,12, 10)]
colnames(Neighbor_intersect_signature) <- rep(c("chr", "start", "end", "ID", "Gene_name"), 2)
Neighbor_intersect_signature_nodes <- unique(rbind(Neighbor_intersect_signature[,c(1:5)], Neighbor_intersect_signature[,c(6:10)]))
Promoter_neighbor_intersect_signature <- match_hit_BP_promoter_pchic[match_hit_BP_promoter_pchic$ID %in% Neighbor_intersect_signature_nodes$ID, ]
message("=== Number of neighbor nodes of the CpGs sig in promoter of Genes sig ===")
Nodes_neigbhor_intersection_CpGs_genes_sig <- unique(Promoter_neighbor_intersect_signature$ID)
length(Nodes_neigbhor_intersection_CpGs_genes_sig)
message("=== Number of promoter genes in neighbor CpGs sig of Genes sig ===")
Promoter_neighbor_intersect_signature <- unique(Promoter_neighbor_intersect_signature$Gene_name)
length(Promoter_neighbor_intersect_signature)
message("=== Number of non sig genes in the neighborhood of CpGs sig and Genes sig ===")
Non_sig_genes_CpGs_Genes_neighbor <- Promoter_neighbor_intersect_signature[Promoter_neighbor_intersect_signature %ni% Final.Tumor.RNAseq.sig]
length(Non_sig_genes_CpGs_Genes_neighbor)
Promoter_neighbors_genes_sig <- Promoter_neighbors_genes[Promoter_neighbors_genes %in% Final.Tumor.RNAseq.sig]
message("=== Number of promoters from BPRNA signature genes in neighborhood of CpGs sig ===")
length(unique(Promoter_neighbors_genes_sig))
unik_CpGs_promoter <- unique(CpGs_promoter)
solo_genes <- unik_CpGs_promoter[unik_CpGs_promoter %ni% Final.Tumor.RNAseq.sig]
message("=== Genes associated with a promoter in BPmetCan, that are not present in BPRNACan ===")
length(solo_genes)