-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnalyse_overlap_signatures.Rmd
324 lines (258 loc) · 13.1 KB
/
Analyse_overlap_signatures.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
---
title: Analyse overlap signatures
output:
html_notebook: default
html_document: default
pdf_document: default
---
```{r, include = FALSE}
library(GenomicRanges)
library(stringr)
library(dplyr)
library(tidyr)
library(tidyverse)
"%ni%" <- Negate("%in%")
```
```{r}
# setwd("~/Github/Ting_signature_analyses/")
# BPmetCan signature
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[, 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) %>%
dplyr::select(., "chr", "start", "end", "type", "ensembl", "gene_names", "intronic_regions", "type") %>%
separate_rows(., gene_names, sep = " ")
# BPRNACan signature
Final.Tumor.RNAseq.sig <- read.delim("BPRNACan_150.txt", stringsAsFactors = F) %>%
.[, "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
)
```
Overlapping between Chromatin fragment from PCHiC data and Blueprint data
```{r}
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 (number of fragments) ===")
Nodes_in_BP_network <- unique(match_hit_BP_Pchic$ID)
length(Nodes_in_BP_network)
message("== Number of promoters nodes in BP network (number of fragments in promoter) ===")
match_hit_BP_promoter_pchic <- dplyr::filter(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 found in the network ==")
length(Genes_BP_Promoter_signature)
```
Overlapping between CpGs from BPmetCan signature and PCHiC data
```{r}
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)
```
Overlapping between the overlapped CpGs in PCHiC data and Blueprint data
```{r}
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 <- dplyr::filter(match_hit_CpGs_Blueprint, Promoter == "P") %>%
.$ID %>%
unique()
length(CpGs_nodes_promoter)
message("=== Genes from promoter blueprint network associated to CpGsnodes from sig ===")
CpGs_promoter <- dplyr::filter(match_hit_CpGs_Blueprint, Promoter == "P") %>%
.$Gene_name %>%
unique()
length(CpGs_promoter)
message("=== CPGsnodes that are NOT associated with a promoter from blueprint network ===")
CpGs_not_promoter <- dplyr::filter(match_hit_CpGs_Blueprint, Promoter == "O") %>%
.$ID %>%
unique()
length(CpGs_not_promoter)
```
Promoters from the overlaps between PCHiC blueprint and CpGs
```{r}
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 ===")
Genes_sig_in_CpG_sig <- unique(Nodes_with_CpGs_sig_and_gene_sig)
length(Genes_sig_in_CpG_sig)
```
Neighborhood of the CpGs signatures
```{r}
Neighbor_network <- rbind(pchic[pchic$IDbait %in% match_hit_CpGs_Pchic$ID,],
pchic[pchic$IDoe %in% match_hit_CpGs_Pchic$ID,]) %>%
unique() %>%
.[,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_neighbors <- dplyr::filter(match_hit_BP_promoter_pchic, ID %in% Neighbor_nodes$ID & ID %ni% match_hit_CpGs_Pchic$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)
```
Neighborhood of the CpGs signatures not in promoter
```{r}
Neighbor_not_prom_network <- rbind(pchic[pchic$IDbait %in% CpGs_not_promoter,],
pchic[pchic$IDoe %in% CpGs_not_promoter,]) %>%
unique() %>%
.[,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 <- dplyr::filter(match_hit_BP_promoter_pchic,
ID %in% Neighbor_not_prom_nodes$ID &
ID %ni% CpGs_not_promoter)
message("=== Number of nodes corresponding to promoter connected to non promoter Cpg sig ===")
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 <- setdiff(Promoter_neighbors_of_not_prom_genes,
Final.Tumor.RNAseq.sig)
length(Non_sig_genes_CpGs_neighbor)
```
Neighborhood of the CpGs sig in promoter of Genes from the signature
```{r}
Nodes_intersect <- dplyr::filter(match_hit_CpGs_Blueprint, Promoter == "P" & Gene_name %in% Final.Tumor.RNAseq.sig) %>%
.$ID
Neighbor_intersect_signature <- rbind(pchic[pchic$IDbait %in% Nodes_intersect,],
pchic[pchic$IDoe %in% Nodes_intersect,]) %>%
unique() %>%
dplyr::select(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 <- rbind(Neighbor_intersect_signature[,c(1:5)], Neighbor_intersect_signature[,c(6:10)]) %>%
unique()
Promoter_neighbor_intersect_signature <- dplyr::filter(match_hit_BP_promoter_pchic,
ID %in% Neighbor_intersect_signature_nodes$ID &
ID %ni% Nodes_intersect)
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 <- setdiff(Promoter_neighbor_intersect_signature, Final.Tumor.RNAseq.sig)
length(Non_sig_genes_CpGs_Genes_neighbor)
```
Neighborhood of the CpGs sig in promoter of Genes not in signature
```{r}
Nodes_exclude <- dplyr::filter(match_hit_CpGs_Blueprint, Promoter == "P" & Gene_name %ni% Final.Tumor.RNAseq.sig) %>%
.$ID
Nodes_Oe_CpG <- dplyr::filter(match_hit_CpGs_Blueprint, Promoter == "O") %>%
.$ID
Nodes_CpGs <- match_hit_CpGs_Blueprint$ID
Nodes_CpG_not_gene_sig <- dplyr::filter(match_hit_CpGs_Blueprint, Gene_name %ni% 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)]
message("=== Number of promoter in CpGs sig not Gene Sig connected at least with one CpGs sig ===")
Neighbor_potential_Promoter_Cpg_all <- dplyr::filter(pchic, IDbait %in% Nodes_exclude & IDoe %in% Nodes_CpGs) %>%
unique()
ID_potential_Promoter_Cpg_all <- unique(Neighbor_potential_Promoter_Cpg_all$IDbait)
message("Number of genes")
dplyr::filter(match_hit_CpGs_Blueprint, ID %in% ID_potential_Promoter_Cpg_all) %>%
.$Gene_name %>%
unique() %>%
length()
message("Number of nodes")
length(ID_potential_Promoter_Cpg_all)
message("=== Number of promoter in CpGs sig not Gene Sig connected at least with one CpGs sig not in gene sig ===")
Neighbor_potential_Promoter_Cpg <- dplyr::filter(pchic, IDbait %in% Nodes_exclude & IDoe %in% Nodes_CpG_not_gene_sig) %>%
unique()
ID_potential_Promoter_Cpg <- unique(Neighbor_potential_Promoter_Cpg$IDbait)
message("Number of genes")
dplyr::filter(match_hit_CpGs_Blueprint, ID %in% ID_potential_Promoter_Cpg) %>%
.$Gene_name %>%
unique() %>%
length()
message("Number of nodes")
length(ID_potential_Promoter_Cpg)
message("=== Number of promoter in CpGs sig not Gene Sig connected at least with one CpGs sig Oe ===")
Neighbor_potential_Promoter_Cpg_Oe <- dplyr::filter(pchic, IDbait %in% Nodes_exclude & IDoe %in% Nodes_Oe_CpG) %>%
unique()
message("Number of genes")
ID_potential_Promoter_Cpg_Oe <- unique(Neighbor_potential_Promoter_Cpg_Oe$IDbait)
dplyr::filter(match_hit_CpGs_Blueprint, ID %in% ID_potential_Promoter_Cpg_Oe) %>%
.$Gene_name %>%
unique() %>%
length()
message("Number of nodes")
length(ID_potential_Promoter_Cpg_Oe)
```
BPRNACanProMet3Dgenes
```{r}
CpGs_prom_Cpgs_interaction <- dplyr::filter(pchic, IDbait %in% CpGs_nodes_promoter & IDoe %in% Nodes_in_CpG)
BPRNACanProMet3Dgenes <- dplyr::filter(match_hit_CpGs_Blueprint, ID %in% CpGs_prom_Cpgs_interaction$IDbait) %>%
.$Gene_name
write.csv(BPRNACanProMet3Dgenes, "BPRNACanProMet3Dgenes.csv", row.names = FALSE)
```
Promoter that are both in Gene sig and neighbor of CpGs sig
```{r}
Promoter_neighbors_genes_sig <- intersect(Promoter_neighbors_genes, Final.Tumor.RNAseq.sig)
message("=== Number of promoters from BPRNA signature genes in neighborhood of CpGs sig ===")
Promoter_neighbors_genes_sig %>% unique() %>% length()
```
Promoter
```{r}
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)
```
## GO on CPGs related genes
```{r}
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)]
GO$GO.biological.process.complete <- str_extract(GO$GO.biological.process.complete, "GO:\\d+")
write.table(GO, "go_promoter_genes.txt", row.names = F, col.names = F, quote = F)
# Launch on REVIGO http://revigo.irb.hr
```
```{r}
sessionInfo()
```