/
3 bubble charts.R
529 lines (405 loc) · 27.8 KB
/
3 bubble charts.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
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
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
library(tidyverse)
library(ggrepel)
# define histones PTMs indexes
ac_index <- c("Hac","H3ac","H4ac","H2/H4ac","H3/H4ac")
me_index <- c("me1","me2","me3") #me1 me2 me3, indicates highest position described for enzyme
####################################################################################################################
####################################################################################################################
#the enz.genelist object contains the enzymes metadata
#SGund enzymes: filter SGund enzymes from enz.genelist file and add the mean RPKM value at SGund
Enz_SGund <- enz.genelist[which(enz.genelist$Symbol %in% SGund_UP),]
Enz_SGund_RPKM <- rowMeans(RPKMs[rownames(RPKMs) %in% SGund_UP,1:3])
Enz_SGund$RPKM <- Enz_SGund_RPKM[match(Enz_SGund$Symbol,names(Enz_SGund_RPKM))]
#construct table for dotplot for each mark
Enz_SGund_Hac <- filter(Enz_SGund,Hac %in% ac_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme, Hac)) %>% mutate(HK=rep("Hac",sum(Enz_SGund$Hac%in%ac_index))) %>% rename("Hac"="HPTM")
Enz_SGund_H3K4me <- filter(Enz_SGund,H3K4me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme, H3K4me)) %>% mutate(HK=rep("H3K4me",sum(Enz_SGund$H3K4me%in%me_index))) %>% rename("H3K4me"="HPTM")
Enz_SGund_H3K36me <- filter(Enz_SGund,H3K36me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme, H3K36me)) %>% mutate(HK=rep("H3K36me",sum(Enz_SGund$H3K36me%in%me_index))) %>% rename("H3K36me"="HPTM")
Enz_SGund_H3K9me <- filter(Enz_SGund,H3K9me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K9me)) %>% mutate(HK=rep("H3K9me",sum(Enz_SGund$H3K9me%in%me_index))) %>% rename("H3K9me"="HPTM")
Enz_SGund_H3K27me <- filter(Enz_SGund,H3K27me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K27me)) %>% mutate(HK=rep("H3K27me",sum(Enz_SGund$H3K27me%in%me_index))) %>% rename("H3K27me"="HPTM")
Enz_SGund_H4K20me <- filter(Enz_SGund,H4K20me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H4K20me)) %>% mutate(HK=rep("H4K20me",sum(Enz_SGund$H4K20me%in%me_index))) %>% rename("H4K20me"="HPTM")
Enz_SGund_H3K79me <- filter(Enz_SGund,H3K79me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K79me)) %>% mutate(HK=rep("H3K79me",sum(Enz_SGund$H3K79me%in%me_index))) %>% rename("H3K79me"="HPTM")
Enz_SGund_H3K56me <- filter(Enz_SGund,H3K56me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K56me)) %>% mutate(HK=rep("H3K56me",sum(Enz_SGund$H3K56me%in%me_index))) %>% rename("H3K56me"="HPTM")
Enz_SGund_H2AZK7me <- filter(Enz_SGund,H2AZK7me=="me1") %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H2AZK7me)) %>% mutate(HK=rep("H2AZK7me",1)) %>% rename("H2AZK7me"="HPTM")
Enz_SGund_H4K12me <- filter(Enz_SGund,H4K12me=="me1") %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H4K12me)) %>% mutate(HK=rep("H4K12me",1)) %>% rename("H4K12me"="HPTM")
SGund <- rbind(Enz_SGund_Hac,Enz_SGund_H3K4me,
Enz_SGund_H3K36me, Enz_SGund_H3K9me,
Enz_SGund_H3K27me, Enz_SGund_H4K20me,
Enz_SGund_H3K79me,Enz_SGund_H3K56me,
Enz_SGund_H2AZK7me,Enz_SGund_H4K12me)
#create column with descending order to arrange graph
SGund$order <- rep(nrow(SGund):1)
#Factorize variables so they appear in the desired order
SGund$HK <- factor(SGund$HK,
levels = c("Hac","H3K4me","H3K36me","H3K79me","H3K9me","H3K27me","H3K56me","H4K20me","H2AZK7me","H4K12me"))
SGund$Enzyme <- factor(SGund$Enzyme, levels = c("Writer","Eraser"))
#create plot SGund
ggplot(SGund,
aes(x=HK,y=reorder(Symbol,order),
color=Enzyme))+
geom_point(aes(size=RPKM))+
scale_color_manual(name="Enzyme",
labels=c("Writer","Eraser"),
values = c("blue","red"))+
scale_size_continuous(name = "RPKM",
breaks = c(1,5,50,100,200),
limits = c(.05, 300),
labels = c("1","5","50","100","200"),
range=c(1,10))+
theme_gray()+
theme(text=element_text(size=16))+
theme(axis.text.x = element_text(angle=45,hjust=1,colour = "black"),
axis.text.y = element_text(colour = "black"))+
xlab("")+ylab("")+
geom_text_repel(aes(label=HPTM), size=3, nudge_x=0.5)
####################################################################################################################
####################################################################################################################
#SGdiff enzymes: filter SGdiff enzymes from enz.genelist file and add the mean RPKM value at SGdiff
Enz_SGdiff <- enz.genelist[which(enz.genelist$Symbol %in% SGdiff_UP),]
Enz_SGdiff_RPKM <- rowMeans(RPKMs[rownames(RPKMs) %in% SGdiff_UP,4:6])
Enz_SGdiff$RPKM <- Enz_SGdiff_RPKM[match(Enz_SGdiff$Symbol,names(Enz_SGdiff_RPKM))]
#construct table for dotplot for each mark
Enz_SGdiff_Hac <- filter(Enz_SGdiff,Hac %in% ac_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,Hac)) %>% mutate(HK=rep("Hac",sum(Enz_SGdiff$Hac%in%ac_index))) %>% rename("Hac"="HPTM")
Enz_SGdiff_H3K4me <- filter(Enz_SGdiff,H3K4me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme, H3K4me)) %>% mutate(HK=rep("H3K4me",sum(Enz_SGdiff$H3K4me%in%me_index))) %>% rename("H3K4me"="HPTM")
Enz_SGdiff_H3K36me <- filter(Enz_SGdiff,H3K36me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K36me)) %>% mutate(HK=rep("H3K36me",sum(Enz_SGdiff$H3K36me%in%me_index))) %>% rename("H3K36me"="HPTM")
Enz_SGdiff_H3K9me <- filter(Enz_SGdiff,H3K9me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K9me)) %>% mutate(HK=rep("H3K9me",sum(Enz_SGdiff$H3K9me%in%me_index))) %>% rename("H3K9me"="HPTM")
Enz_SGdiff_H3K27me <- filter(Enz_SGdiff,H3K27me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K27me)) %>% mutate(HK=rep("H3K27me",sum(Enz_SGdiff$H3K27me%in%me_index))) %>% rename("H3K27me"="HPTM")
Enz_SGdiff_H4K20me <- filter(Enz_SGdiff,H4K20me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H4K20me)) %>% mutate(HK=rep("H4K20me",sum(Enz_SGdiff$H4K20me%in%me_index))) %>% rename("H4K20me"="HPTM")
Enz_SGdiff_H3K79me <- filter(Enz_SGdiff,H3K79me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K79me)) %>% mutate(HK=rep("H3K79me",sum(Enz_SGdiff$H3K79me%in%me_index))) %>% rename("H3K79me"="HPTM")
Enz_SGdiff_H3K56me <- filter(Enz_SGdiff,H3K56me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K56me)) %>% mutate(HK=rep("H3K56me",sum(Enz_SGdiff$H3K56me%in%me_index))) %>% rename("H3K56me"="HPTM")
Enz_SGdiff_H2AZK7me <- filter(Enz_SGdiff,H2AZK7me=="me1") %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H2AZK7me)) %>% mutate(HK=rep("H2AZK7me",1)) %>% rename("H2AZK7me"="HPTM")
Enz_SGdiff_H4K12me <- filter(Enz_SGdiff,H4K12me=="me1") %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H4K12me)) %>% mutate(HK=rep("H4K12me",1)) %>% rename("H4K12me"="HPTM")
SGdiff <- rbind(Enz_SGdiff_Hac,Enz_SGdiff_H3K4me,
Enz_SGdiff_H3K36me, Enz_SGdiff_H3K9me,
Enz_SGdiff_H3K27me, Enz_SGdiff_H4K20me,
Enz_SGdiff_H3K79me, Enz_SGdiff_H3K56me,
Enz_SGdiff_H2AZK7me,Enz_SGdiff_H4K12me)
#create column with descending order to arrange graph
SGdiff$order <- rep(nrow(SGdiff):1)
#Factorize variables so they appear in the desired order
SGdiff$HK <- factor(SGdiff$HK,
levels = c("Hac","H3K4me","H3K36me","H3K79me","H3K9me","H3K27me","H3K56me","H4K20me","H2AZK7me","H4K12me"))
SGdiff$Enzyme <- factor(SGdiff$Enzyme, levels = c("Writer","Eraser"))
#create plot
ggplot(SGdiff,
aes(x=HK,y=reorder(Symbol,order),
color=Enzyme))+
geom_point(aes(size=RPKM))+
scale_color_manual(name="Enzyme",
labels=c("Writer","Eraser"),
values = c("blue","red"))+
scale_size_continuous(name = "RPKM",
breaks = c(1,5,50,100,200),
limits = c(.05, 300),
labels = c("1","5","50","100","200"),
range=c(1,10))+
theme_gray()+
theme(text=element_text(size=16))+
theme(axis.text.x = element_text(angle=45,hjust=1,colour = "black"),
axis.text.y = element_text(colour = "black"))+
xlab("")+ylab("")+
geom_text_repel(aes(label=HPTM), size=3, nudge_x=0.5)
####################################################################################################################
####################################################################################################################
#Prel enzymes: filter Prel enzymes from enz.genelist file and add the mean RPKM value at Prel
Enz_Prel <- enz.genelist[which(enz.genelist$Symbol %in% Prel_UP),]
Enz_Prel_RPKM <- rowMeans(RPKMs[rownames(RPKMs) %in% Prel_UP,7:9])
Enz_Prel$RPKM <- Enz_Prel_RPKM[match(Enz_Prel$Symbol,names(Enz_Prel_RPKM))]
#construct table for dotplot for each mark
Enz_Prel_Hac <- filter(Enz_Prel,Hac %in% ac_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,Hac)) %>% mutate(HK=rep("Hac",sum(Enz_Prel$Hac%in%ac_index))) %>% rename("Hac"="HPTM")
Enz_Prel_H3K4me <- filter(Enz_Prel,H3K4me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K4me)) %>% mutate(HK=rep("H3K4me",sum(Enz_Prel$H3K4me%in%me_index))) %>% rename("H3K4me"="HPTM")
Enz_Prel_H3K36me <- filter(Enz_Prel,H3K36me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K36me)) %>% mutate(HK=rep("H3K36me",sum(Enz_Prel$H3K36me%in%me_index))) %>% rename("H3K36me"="HPTM")
Enz_Prel_H3K9me <- filter(Enz_Prel,H3K9me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K9me)) %>% mutate(HK=rep("H3K9me",sum(Enz_Prel$H3K9me%in%me_index))) %>% rename("H3K9me"="HPTM")
Enz_Prel_H3K27me <- filter(Enz_Prel,H3K27me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K27me)) %>% mutate(HK=rep("H3K27me",sum(Enz_Prel$H3K27me%in%me_index))) %>% rename("H3K27me"="HPTM")
Enz_Prel_H4K20me <- filter(Enz_Prel,H4K20me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H4K20me)) %>% mutate(HK=rep("H4K20me",sum(Enz_Prel$H4K20me%in%me_index))) %>% rename("H4K20me"="HPTM")
Enz_Prel_H3K79me <- filter(Enz_Prel,H3K79me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K79me)) %>% mutate(HK=rep("H3K79me",sum(Enz_Prel$H3K79me%in%me_index))) %>% rename("H3K79me"="HPTM")
Enz_Prel_H3K56me <- filter(Enz_Prel,H3K56me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K56me)) %>% mutate(HK=rep("H3K56me",sum(Enz_Prel$H3K56me%in%me_index))) %>% rename("H3K56me"="HPTM")
Enz_Prel_H2AZK7me <- filter(Enz_Prel,H2AZK7me=="me1") %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H2AZK7me)) %>% mutate(HK=rep("H2AZK7me",1)) %>% rename("H2AZK7me"="HPTM")
Enz_Prel_H4K12me <- filter(Enz_Prel,H4K12me=="me1") %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H4K12me)) %>% mutate(HK=rep("H4K12me",1)) %>% rename("H4K12me"="HPTM")
Prel <- rbind(Enz_Prel_Hac,Enz_Prel_H3K4me,
Enz_Prel_H3K36me, Enz_Prel_H3K9me,
Enz_Prel_H3K27me, Enz_Prel_H4K20me,
Enz_Prel_H3K79me,Enz_Prel_H3K56me,
Enz_Prel_H2AZK7me,Enz_Prel_H4K12me)
#create column with descending order to arrange graph
Prel$order <- rep(nrow(Prel):1)
#Factorize variables so they appear in the desired order
Prel$HK <- factor(Prel$HK,
levels = c("Hac","H3K4me","H3K36me","H3K79me","H3K9me","H3K27me","H3K56me","H4K20me","H2AZK7me","H4K12me"))
Prel$Enzyme <- factor(Prel$Enzyme, levels = c("Writer","Eraser"))
#create plot
ggplot(Prel,
aes(x=HK,y=reorder(Symbol,order),
color=Enzyme))+
geom_point(aes(size=RPKM))+
scale_color_manual(name="Enzyme",
labels=c("Writer","Eraser"),
values = c("blue","red"))+
scale_size_continuous(name = "RPKM",
breaks = c(5,50,100,200,500),
limits = c(.05, 500),
labels = c("5","50","100","200","500"),
range=c(1,10))+
theme_gray()+
theme(text=element_text(size=16))+
theme(axis.text.x = element_text(angle=45,hjust=1,colour = "black"),
axis.text.y = element_text(colour = "black"))+
xlab("")+ylab("")+
geom_text_repel(aes(label=HPTM), size=3, nudge_x=0.5)
####################################################################################################################
####################################################################################################################
#LZ enzymes: filter LZ enzymes from enz.genelist file and add the mean RPKM value at LZ
Enz_LZ <- enz.genelist[which(enz.genelist$Symbol %in% LZ_UP),]
Enz_LZ_RPKM <- rowMeans(RPKMs[rownames(RPKMs) %in% LZ_UP,10:12])
Enz_LZ$RPKM <- Enz_LZ_RPKM[match(Enz_LZ$Symbol,names(Enz_LZ_RPKM))]
#construct table for dotplot for each mark
Enz_LZ_Hac <- filter(Enz_LZ,Hac %in% ac_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,Hac)) %>% mutate(HK=rep("Hac",sum(Enz_LZ$Hac%in%ac_index))) %>% rename("Hac"="HPTM")
Enz_LZ_H3K4me <- filter(Enz_LZ,H3K4me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K4me)) %>% mutate(HK=rep("H3K4me",sum(Enz_LZ$H3K4me%in%me_index))) %>% rename("H3K4me"="HPTM")
Enz_LZ_H3K36me <- filter(Enz_LZ,H3K36me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K36me)) %>% mutate(HK=rep("H3K36me",sum(Enz_LZ$H3K36me%in%me_index))) %>% rename("H3K36me"="HPTM")
Enz_LZ_H3K9me <- filter(Enz_LZ,H3K9me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K9me)) %>% mutate(HK=rep("H3K9me",sum(Enz_LZ$H3K9me%in%me_index))) %>% rename("H3K9me"="HPTM")
Enz_LZ_H3K27me <- filter(Enz_LZ,H3K27me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K27me)) %>% mutate(HK=rep("H3K27me",sum(Enz_LZ$H3K27me%in%me_index))) %>% rename("H3K27me"="HPTM")
Enz_LZ_H4K20me <- filter(Enz_LZ,H4K20me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H4K20me)) %>% mutate(HK=rep("H4K20me",sum(Enz_LZ$H4K20me%in%me_index))) %>% rename("H4K20me"="HPTM")
Enz_LZ_H3K79me <- filter(Enz_LZ,H3K79me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K79me)) %>% mutate(HK=rep("H3K79me",sum(Enz_LZ$H3K79me%in%me_index))) %>% rename("H3K79me"="HPTM")
Enz_LZ_H3K56me <- filter(Enz_LZ,H3K56me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K56me)) %>% mutate(HK=rep("H3K56me",sum(Enz_LZ$H3K56me%in%me_index))) %>% rename("H3K56me"="HPTM")
Enz_LZ_H2AZK7me <- filter(Enz_LZ,H2AZK7me=="me1") %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H2AZK7me)) %>% mutate(HK=rep("H2AZK7me",1)) %>% rename("H2AZK7me"="HPTM")
Enz_LZ_H4K12me <- filter(Enz_LZ,H4K12me=="me1") %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H4K12me)) %>% mutate(HK=rep("H4K12me",1)) %>% rename("H4K12me"="HPTM")
LZ <- rbind(Enz_LZ_Hac,Enz_LZ_H3K4me,
Enz_LZ_H3K36me, Enz_LZ_H3K9me,
Enz_LZ_H3K27me, Enz_LZ_H4K20me,
Enz_LZ_H3K79me,Enz_LZ_H3K56me,
Enz_LZ_H2AZK7me,Enz_LZ_H4K12me)
#create column with descending order to arrange graph
LZ$order <- rep(nrow(LZ):1)
#Factorize variables so they appear in the desired order
LZ$HK <- factor(LZ$HK,
levels = c("Hac","H3K4me","H3K36me","H3K79me","H3K9me","H3K27me","H3K56me","H4K20me","H2AZK7me","H4K12me"))
LZ$Enzyme <- factor(LZ$Enzyme, levels = c("Writer","Eraser"))
#create plot
ggplot(LZ,
aes(x=HK,y=reorder(Symbol,order),
color=Enzyme))+
geom_point(aes(size=RPKM))+
scale_color_manual(name="Enzyme",
labels=c("Writer","Eraser"),
values = c("blue","red"))+
scale_size_continuous(name = "RPKM",
breaks = c(5,50,100,200,500),
limits = c(.05, 500),
labels = c("5","50","100","200","500"),
range=c(1,10))+
theme_gray()+
theme(text=element_text(size=16))+
theme(axis.text.x = element_text(angle=45,hjust=1,colour = "black"),
axis.text.y = element_text(colour = "black"))+
xlab("")+ylab("")+
geom_text_repel(aes(label=HPTM), size=3, nudge_x=0.5)
####################################################################################################################
####################################################################################################################
#PD enzymes: filter PD enzymes from enz.genelist file and add the mean RPKM value at PD
Enz_PD <- enz.genelist[which(enz.genelist$Symbol %in% PD_UP),]
Enz_PD_RPKM <- rowMeans(RPKMs[rownames(RPKMs) %in% PD_UP,13:15])
Enz_PD$RPKM <- Enz_PD_RPKM[match(Enz_PD$Symbol,names(Enz_PD_RPKM))]
#construct table for dotplot for each mark
Enz_PD_Hac <- filter(Enz_PD,Hac %in% ac_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,Hac)) %>% mutate(HK=rep("Hac",sum(Enz_PD$Hac%in%ac_index))) %>% rename("Hac"="HPTM")
Enz_PD_H3K4me <- filter(Enz_PD,H3K4me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K4me)) %>% mutate(HK=rep("H3K4me",sum(Enz_PD$H3K4me%in%me_index))) %>% rename("H3K4me"="HPTM")
Enz_PD_H3K36me <- filter(Enz_PD,H3K36me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K36me)) %>% mutate(HK=rep("H3K36me",sum(Enz_PD$H3K36me%in%me_index))) %>% rename("H3K36me"="HPTM")
Enz_PD_H3K9me <- filter(Enz_PD,H3K9me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K9me)) %>% mutate(HK=rep("H3K9me",sum(Enz_PD$H3K9me%in%me_index))) %>% rename("H3K9me"="HPTM")
Enz_PD_H3K27me <- filter(Enz_PD,H3K27me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K27me)) %>% mutate(HK=rep("H3K27me",sum(Enz_PD$H3K27me%in%me_index))) %>% rename("H3K27me"="HPTM")
Enz_PD_H4K20me <- filter(Enz_PD,H4K20me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H4K20me)) %>% mutate(HK=rep("H4K20me",sum(Enz_PD$H4K20me%in%me_index))) %>% rename("H4K20me"="HPTM")
Enz_PD_H3K79me <- filter(Enz_PD,H3K79me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K79me)) %>% mutate(HK=rep("H3K79me",sum(Enz_PD$H3K79me%in%me_index))) %>% rename("H3K79me"="HPTM")
Enz_PD_H3K56me <- filter(Enz_PD,H3K56me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K56me)) %>% mutate(HK=rep("H3K56me",sum(Enz_PD$H3K56me%in%me_index))) %>% rename("H3K56me"="HPTM")
Enz_PD_H2AZK7me <- filter(Enz_PD,H2AZK7me=="me1") %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H2AZK7me)) %>% mutate(HK=rep("H2AZK7me",1)) %>% rename("H2AZK7me"="HPTM")
Enz_PD_H4K12me <- filter(Enz_PD,H4K12me=="me1") %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H4K12me)) %>% mutate(HK=rep("H4K12me",1)) %>% rename("H4K12me"="HPTM")
PD <- rbind(Enz_PD_Hac,Enz_PD_H3K4me,
Enz_PD_H3K36me, Enz_PD_H3K9me,
Enz_PD_H3K27me, Enz_PD_H4K20me,
Enz_PD_H3K79me,Enz_PD_H3K56me,
Enz_PD_H2AZK7me,Enz_PD_H4K12me)
#create column with descending order to arrange graph
PD$order <- rep(nrow(PD):1) #create column with descending order to arrange graph
#Factorize variables so they appear in the desired order
PD$HK <- factor(PD$HK,
levels = c("Hac","H3K4me","H3K36me","H3K79me","H3K9me","H3K27me","H3K56me","H4K20me","H2AZK7me","H4K12me"))
PD$Enzyme <- factor(PD$Enzyme, levels = c("Writer","Eraser"))
#create plot
ggplot(PD,
aes(x=HK,y=reorder(Symbol,order),
color=Enzyme))+
geom_point(aes(size=RPKM))+
scale_color_manual(name="Enzyme",
labels=c("Writer","Eraser"),
values = c("blue","red"))+
scale_size_continuous(name = "RPKM",
breaks = c(5,50,100,200,500),
limits = c(.05, 500),
labels = c("5","50","100","200","500"),
range=c(1,10))+
theme_gray()+
theme(text=element_text(size=16))+
theme(axis.text.x = element_text(angle=45,hjust=1,colour = "black"),
axis.text.y = element_text(colour = "black"))+
xlab("")+ylab("")+
geom_text_repel(aes(label=HPTM), size=3, nudge_x=0.5)
####################################################################################################################
####################################################################################################################
#RStid enzymes: filter RStid enzymes from enz.genelist file and add the mean RPKM value at RStid
Enz_RStid <- enz.genelist[which(enz.genelist$Symbol %in% RStid_UP),]
Enz_RStid_RPKM <- rowMeans(RPKMs[rownames(RPKMs) %in% RStid_UP,16:18])
Enz_RStid$RPKM <- Enz_RStid_RPKM[match(Enz_RStid$Symbol,names(Enz_RStid_RPKM))]
#construct table for dotplot for each mark
Enz_RStid_Hac <- filter(Enz_RStid,Hac %in% ac_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,Hac)) %>% mutate(HK=rep("Hac",sum(Enz_RStid$Hac%in%ac_index))) %>% rename("Hac"="HPTM")
Enz_RStid_H3K4me <- filter(Enz_RStid,H3K4me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K4me)) %>% mutate(HK=rep("H3K4me",sum(Enz_RStid$H3K4me%in%me_index))) %>% rename("H3K4me"="HPTM")
Enz_RStid_H3K36me <- filter(Enz_RStid,H3K36me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K36me)) %>% mutate(HK=rep("H3K36me",sum(Enz_RStid$H3K36me%in%me_index))) %>% rename("H3K36me"="HPTM")
Enz_RStid_H3K9me <- filter(Enz_RStid,H3K9me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K9me)) %>% mutate(HK=rep("H3K9me",sum(Enz_RStid$H3K9me%in%me_index))) %>% rename("H3K9me"="HPTM")
Enz_RStid_H3K27me <- filter(Enz_RStid,H3K27me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K27me)) %>% mutate(HK=rep("H3K27me",sum(Enz_RStid$H3K27me%in%me_index))) %>% rename("H3K27me"="HPTM")
Enz_RStid_H4K20me <- filter(Enz_RStid,H4K20me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H4K20me)) %>% mutate(HK=rep("H4K20me",sum(Enz_RStid$H4K20me%in%me_index))) %>% rename("H4K20me"="HPTM")
Enz_RStid_H3K79me <- filter(Enz_RStid,H3K79me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K79me)) %>% mutate(HK=rep("H3K79me",sum(Enz_RStid$H3K79me%in%me_index))) %>% rename("H3K79me"="HPTM")
Enz_RStid_H3K56me <- filter(Enz_RStid,H3K56me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K56me)) %>% mutate(HK=rep("H3K56me",sum(Enz_RStid$H3K56me%in%me_index))) %>% rename("H3K56me"="HPTM")
Enz_RStid_H2AZK7me <- filter(Enz_RStid,H2AZK7me=="me1") %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H2AZK7me)) %>% mutate(HK=rep("H2AZK7me",1)) %>% rename("H2AZK7me"="HPTM")
Enz_RStid_H4K12me <- filter(Enz_RStid,H4K12me=="me1") %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H4K12me)) %>% mutate(HK=rep("H4K12me",1)) %>% rename("H4K12me"="HPTM")
RStid <- rbind(Enz_RStid_Hac,Enz_RStid_H3K4me,
Enz_RStid_H3K36me, Enz_RStid_H3K9me,
Enz_RStid_H3K27me, Enz_RStid_H4K20me,
Enz_RStid_H3K79me,Enz_RStid_H3K56me,
Enz_RStid_H2AZK7me,Enz_RStid_H4K12me)
#create column with descending order to arrange graph
RStid$order <- rep(nrow(RStid):1)
#Factorize variables so they appear in the desired order
RStid$HK <- factor(RStid$HK,
levels = c("Hac","H3K4me","H3K36me","H3K79me","H3K9me","H3K27me","H3K56me","H4K20me","H2AZK7me","H4K12me"))
RStid$Enzyme <- factor(RStid$Enzyme, levels = c("Writer","Eraser"))
#create plot
ggplot(RStid,
aes(x=HK,y=reorder(Symbol,order),
color=Enzyme))+
geom_point(aes(size=RPKM))+
scale_color_manual(name="Enzyme",
labels=c("Writer","Eraser"),
values = c("blue","red"))+
scale_size_continuous(name = "RPKM",
breaks = c(5,50,100,200,400),
limits = c(.05, 400),
labels = c("5","50","100","200","400"),
range=c(1,10))+
theme_gray()+
theme(text=element_text(size=16))+
theme(axis.text.x = element_text(angle=45,hjust=1,colour = "black"),
axis.text.y = element_text(colour = "black"))+
xlab("")+ylab("")+
geom_text_repel(aes(label=HPTM), size=3, nudge_x=0.5)
####################################################################################################################
####################################################################################################################
#unnasigned enzymes: filter RStid enzymes from enz.genelist file and add the mean RPKM value at RStid
Enz_unnasigned <- enz.genelist[which(enz.genelist$Symbol %in% unassigned_enz),]
Enz_unnasigned_RPKM <- rowMeans(RPKMs[rownames(RPKMs) %in% unassigned_enz,1:15])
Enz_unnasigned$RPKM <- Enz_unnasigned_RPKM[match(Enz_unnasigned$Symbol,names(Enz_unnasigned_RPKM))]
#construct table for dotplot for each mark
Enz_unnasigned_Hac <- filter(Enz_unnasigned,Hac %in% ac_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,Hac)) %>% mutate(HK=rep("Hac",sum(Enz_unnasigned$Hac%in%ac_index))) %>% rename("Hac"="HPTM")
Enz_unnasigned_H3K4me <- filter(Enz_unnasigned,H3K4me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K4me)) %>% mutate(HK=rep("H3K4me",sum(Enz_unnasigned$H3K4me%in%me_index))) %>% rename("H3K4me"="HPTM")
Enz_unnasigned_H3K36me <- filter(Enz_unnasigned,H3K36me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K36me)) %>% mutate(HK=rep("H3K36me",sum(Enz_unnasigned$H3K36me%in%me_index))) %>% rename("H3K36me"="HPTM")
Enz_unnasigned_H3K9me <- filter(Enz_unnasigned,H3K9me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K9me)) %>% mutate(HK=rep("H3K9me",sum(Enz_unnasigned$H3K9me%in%me_index))) %>% rename("H3K9me"="HPTM")
Enz_unnasigned_H3K27me <- filter(Enz_unnasigned,H3K27me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K27me)) %>% mutate(HK=rep("H3K27me",sum(Enz_unnasigned$H3K27me%in%me_index))) %>% rename("H3K27me"="HPTM")
Enz_unnasigned_H4K20me <- filter(Enz_unnasigned,H4K20me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H4K20me)) %>% mutate(HK=rep("H4K20me",sum(Enz_unnasigned$H4K20me%in%me_index))) %>% rename("H4K20me"="HPTM")
Enz_unnasigned_H3K79me <- filter(Enz_unnasigned,H3K79me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K79me)) %>% mutate(HK=rep("H3K79me",sum(Enz_unnasigned$H3K79me%in%me_index))) %>% rename("H3K79me"="HPTM")
Enz_unnasigned_H3K56me <- filter(Enz_unnasigned,H3K56me %in% me_index) %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H3K56me)) %>% mutate(HK=rep("H3K56me",sum(Enz_unnasigned$H3K56me%in%me_index))) %>% rename("H3K56me"="HPTM")
Enz_unnasigned_H2AZK7me <- filter(Enz_unnasigned,H2AZK7me=="me1") %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H2AZK7me)) %>% mutate(HK=rep("H2AZK7me",1)) %>% rename("H2AZK7me"="HPTM")
Enz_unnasigned_H4K12me <- filter(Enz_unnasigned,H4K12me=="me1") %>%
dplyr::select(c(RPKM,Symbol,Enzyme,H4K12me)) %>% mutate(HK=rep("H4K12me",1)) %>% rename("H4K12me"="HPTM")
unnasigned <- rbind(Enz_unnasigned_Hac,Enz_unnasigned_H3K4me,
Enz_unnasigned_H3K36me, Enz_unnasigned_H3K9me,
Enz_unnasigned_H3K27me, Enz_unnasigned_H4K20me,
Enz_unnasigned_H3K79me,Enz_unnasigned_H3K56me,
Enz_unnasigned_H2AZK7me,Enz_unnasigned_H4K12me)
#create column with descending order to arrange graph
unnasigned$order <- rep(nrow(unnasigned):1)
#Factorize variables so they appear in the desired order
unnasigned$HK <- factor(unnasigned$HK,
levels = c("Hac","H3K4me","H3K36me","H3K79me","H3K9me","H3K27me","H3K56me","H4K20me","H2AZK7me","H4K12me"))
unnasigned$Enzyme <- factor(unnasigned$Enzyme, levels = c("Writer","Eraser"))
#create plot
ggplot(unnasigned,
aes(x=HK,y=reorder(Symbol,order),
color=Enzyme))+
geom_point(aes(size=RPKM))+
scale_color_manual(name="Enzyme",
labels=c("Writer","Eraser"),
values = c("blue","red"))+
scale_size_continuous(name = "RPKM",
breaks = c(1,10,50,100,200),
limits = c(.05, 400),
labels = c("1","10","50","100","200"),
range=c(1,10))+
theme_gray()+
theme(text=element_text(size=16))+
theme(axis.text.x = element_text(angle=45,hjust=1,colour = "black"),
axis.text.y = element_text(colour = "black"))+
xlab("")+ylab("")+
geom_text_repel(aes(label=HPTM), size=3, nudge_x=0.5)