-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNoveltyTagmAnalysis.rmd
1241 lines (1000 loc) · 58.2 KB
/
NoveltyTagmAnalysis.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
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: "Novelty Tagm Analysis"
author: "Oliver M. Crook"
date: "17 November 2018"
output: html_document
---
```{r,}
source("../scripts/plot2D.R")
```
```{r,}
require(pRolocdata)
data(hirst2018)
newHirst <- hirst2018[, c(11:15, 26:30, 41:45)]
fData(newHirst)$markers[fData(newHirst)$markers == "Large Protein Complex"] <- "unknown"
load("hirstTagmNoveltyparams.rda")
setStockcol(paste0(getStockcol(), 90))
```
# check convergence
```{r,}
outliers <- mcmc_get_outliers(hirstTagmNoveltyparams[c(1,2,4,6)])
hirstdiag <- gelman.diag(outliers)
hirstTagmNoveltyparams_conv <- hirstTagmNoveltyparams[c(1,2,4,6)]
```
```{r,}
hirstTagmNoveltyRes <- tagmNoveltyProcess(object = newHirst, params = hirstTagmNoveltyparams_conv)
hirstTagmNoveltyparams_conv <- tagmMcmcProcess(hirstTagmNoveltyparams_conv)
newHirst <- tagmPredict(object = newHirst, params = hirstTagmNoveltyparams_conv)
save(hirstTagmNoveltyRes, file = "hirstTagmNoveltyRes.rda")
```
```{r,}
## attach information to MSnset
fData(newHirst)$tagm.phenotype <- hirstTagmNoveltyRes$mpCombined$cl[rownames(fData(newHirst))]
fData(newHirst)$tagm.newcluster.prob <- hirstTagmNoveltyRes$tagm.newcluster.prob[rownames(fData(newHirst))]
fData(newHirst)$tagm.newcluster.prob[is.na(fData(newHirst)$tagm.newcluster.prob)] <- 0
ptsze <- exp(fData(newHirst)$tagm.newcluster.prob) - 1
plot2D(newHirst, fcol = "tagm.phenotype", cex = ptsze)
addLegend(newHirst, fcol = "tagm.phenotype", ncol = 3, where = "topright", cex = 0.5)
```
```{r,}
## specify large margin on the right hand side using mar and use xpd = T to allow plotting
par(mar=c(5,4,4,13), xpd = T)
## add legend manually with legend, you will need to play with x and y coords in legend depending on your screen and rendering
ptsze <- fData(newHirst)$tagm.newcluster.prob
plot2D(newHirst, fcol = "tagm.phenotype", cex = ptsze, main = "PCA of control HeLA data with pointer scaled to discovery probability")
myleg <- levels(hirstTagmNoveltyRes$mpCombined$cl)
legend(7, 8, legend = myleg, col = getStockcol(), bty = "n",
pch = 19, cex = 0.7, pt.cex = 1)
```
```{r,}
toSubsethl <- (fData(newHirst)$tagm.newcluster.prob > 0.95) & fData(newHirst)$tagm.mcmc.outlier < 0.95
# Create annotation
annot <- data.frame(organelle = fData(newHirst)$tagm.phenotype[toSubsethl])
rownames(annot) <- rownames(fData(newHirst))[toSubsethl]
# Set up for heat map
ann_colors = list(
organelle = c(getStockcol()[1:nlevels(hirstTagmNoveltyRes$mpCombined$cl)])
)
names(ann_colors$organelle) <- levels(annot$organelle)
psmSub <- rownames(fData(newHirst))[toSubsethl]
# Create Heatmap of PSM to big too run subset to
pheatmap(hirstTagmNoveltyRes$psmCombined[psmSub,psmSub], useRaster = TRUE, annotation_row = annot, show_rownames = F, show_colnames = F, annotation_colors = ann_colors, treeheight_row = 0, treeheight_col = 0, main = "Heatmap of the posterior similarity matrix for the HeLa (Hirst et al.) data")
```
```{r,}
cc1Hirst <- enrichGO(gene = rownames(newHirst)[fData(newHirst)$tagm.phenotype == "Phenotype 1" &
fData(newHirst)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(newHirst))) # ribosome, cytosol
cc2Hirst <- enrichGO(gene = rownames(newHirst)[fData(newHirst)$tagm.phenotype == "Phenotype 2" &
fData(newHirst)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(newHirst))) #extracellular, cytosol
cc3Hirst <- enrichGO(gene = rownames(newHirst)[fData(newHirst)$tagm.phenotype == "Phenotype 3" &
fData(newHirst)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(newHirst))) # nothing
cc4Hirst <- enrichGO(gene = rownames(newHirst)[fData(newHirst)$tagm.phenotype == "Phenotype 4" & fData(newHirst)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(newHirst))) # nothing
cc5Hirst <- enrichGO(gene = rownames(newHirst)[fData(newHirst)$tagm.phenotype == "Phenotype 5" & fData(newHirst)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(newHirst))) #
cc6Hirst <- enrichGO(gene = rownames(newHirst)[fData(newHirst)$tagm.phenotype == "Phenotype 6" & fData(newHirst)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(newHirst)))
cc7Hirst <- enrichGO(gene = rownames(newHirst)[fData(newHirst)$tagm.phenotype == "Phenotype 7" & fData(newHirst)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(newHirst)))
cc8Hirst <- enrichGO(gene = rownames(newHirst)[fData(newHirst)$tagm.phenotype == "Phenotype 8" & fData(newHirst)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(newHirst)))
#bp2Hirst <- enrichGO(gene = rownames(hirst2018)[fData(hirst2018)$tagm.phenotype == "Phenotype 2"],
# OrgDb = "org.Hs.eg.db",
# keyType = "UNIPROT",
# ont = "BP",
# universe = rownames(fData(hirst2018)))
#bp6Hirst <- enrichGO(gene = rownames(hirst2018)[fData(hirst2018)$tagm.phenotype == "Phenotype 6"],
# OrgDb = "org.Hs.eg.db",
# keyType = "UNIPROT",
# ont = "BP",
# universe = rownames(fData(hirst2018)))
```
```{r,}
ccHirstres <- list(cc1Hirst, cc2Hirst, cc3Hirst, cc4Hirst,
cc5Hirst, cc6Hirst, cc7Hirst, cc8Hirst)
save(ccHirstres, file = "ccHirstres.rda")
```
Beltran MOCK 24 analysis
```{r,}
load("beltranMOCK24TagmNoveltyparams.rda")
data("beltran2016MOCK24")
```
# check convergence
```{r,}
outliers <- mcmc_get_outliers(beltranMOCK24TagmNoveltyparams)
MOCK24diag <- gelman.diag(outliers)
```
```{r,}
beltranMOCK24TagmNoveltyRes <- tagmNoveltyProcess(object = beltran2016MOCK24, params = beltranMOCK24TagmNoveltyparams)
beltranMOCK24TagmNoveltyparams <- tagmMcmcProcess(beltranMOCK24TagmNoveltyparams)
beltran2016MOCK24 <- tagmPredict(object = beltran2016MOCK24, params = beltranMOCK24TagmNoveltyparams)
save(beltranMOCK24TagmNoveltyRes, file = "beltranMOCK24TagmNoveltyRes.rda")
```
```{r,}
## attach information to MSnset
fData(beltran2016MOCK24)$tagm.phenotype <- beltranHCMV24TagmNoveltyRes$mpCombined$cl[rownames(fData(beltran2016MOCK24))]
fData(beltran2016MOCK24)$tagm.newcluster.prob <- beltranMOCK24TagmNoveltyRes$tagm.newcluster.prob[rownames(fData(beltran2016MOCK24))]
fData(beltran2016MOCK24)$tagm.newcluster.prob[is.na(fData(beltran2016MOCK24)$tagm.newcluster.prob)] <- 0
ptsze <- fData(beltran2016MOCK24)$tagm.newcluster.prob
plot2D(beltran2016MOCK24, fcol = "tagm.phenotype", cex = ptsze)
addLegend(beltran2016MOCK24, fcol = "tagm.phenotype", ncol = 2, where = "bottomleft", cex = 0.5)
```
```{r,}
## specify large margin on the right hand side using mar and use xpd = T to allow plotting
par(mar=c(5,4,4,13), xpd = T)
## add legend manually with legend, you will need to play with x and y coords in legend depending on your screen and rendering
ptsze <- fData(beltran2016MOCK24)$tagm.newcluster.prob
plot2D(beltran2016MOCK24, fcol = "tagm.phenotype", cex = ptsze, main = "PCA of MOCK fibroblast data with pointer scaled to discovery probability")
myleg <- levels(beltranMOCK24TagmNoveltyRes$mpCombined$cl)
legend(3, 2, legend = myleg, col = getStockcol(), bty = "n",
pch = 19, cex = 0.7, pt.cex = 1)
```
```{r,}
toSubsethl <- (fData(beltran2016MOCK24)$tagm.newcluster.prob > 0.95) & fData(beltran2016MOCK24)$tagm.mcmc.outlier < 0.95
# Create annotation
annot <- data.frame(organelle = fData(beltran2016MOCK24)$tagm.phenotype[toSubsethl])
rownames(annot) <- rownames(fData(beltran2016MOCK24))[toSubsethl]
# Set up for heat map
ann_colors = list(
organelle = c(getStockcol()[1:nlevels(beltranMOCK24TagmNoveltyRes$mpCombined$cl)])
)
names(ann_colors$organelle) <- levels(annot$organelle)
psmSub <- rownames(fData(beltran2016MOCK24))[toSubsethl]
# Create Heatmap of PSM to big too run subset to
pheatmap(beltranMOCK24TagmNoveltyRes$psmCombined[psmSub,psmSub], useRaster = TRUE, annotation_row = annot, show_rownames = F, show_colnames = F, annotation_colors = ann_colors, treeheight_row = 0, treeheight_col = 0, main = "Heatmap of the posterior similarity matrix for the MOCK fibroblast data")
```
```{r,}
cc1beltran <- enrichGO(gene = rownames(beltran2016MOCK24)[fData(beltran2016MOCK24)$tagm.phenotype == "Phenotype 1" & fData(beltran2016MOCK24)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(beltran2016MOCK24))) #ribosome, large ribosomal subunit
cc2beltran <- enrichGO(gene = rownames(beltran2016MOCK24)[fData(beltran2016MOCK24)$tagm.phenotype == "Phenotype 2" & fData(beltran2016MOCK24)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(beltran2016MOCK24))) # actin cytoskeleton
cc3beltran <- enrichGO(gene = rownames(beltran2016MOCK24)[fData(beltran2016MOCK24)$tagm.phenotype == "Phenotype 3" & fData(beltran2016MOCK24)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(beltran2016MOCK24))) # mitochondrial part/ peroxisome
cc4beltran <- enrichGO(gene = rownames(beltran2016MOCK24)[fData(beltran2016MOCK24)$tagm.phenotype == "Phenotype 4" & fData(beltran2016MOCK24)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(beltran2016MOCK24))) # nothing
cc5beltran <- enrichGO(gene = rownames(beltran2016MOCK24)[fData(beltran2016MOCK24)$tagm.phenotype == "Phenotype 5" & fData(beltran2016MOCK24)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(beltran2016MOCK24))) #ribsomal
cc6beltran <- enrichGO(gene = rownames(beltran2016MOCK24)[fData(beltran2016MOCK24)$tagm.phenotype == "Phenotype 6" & fData(beltran2016MOCK24)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(beltran2016MOCK24))) # large ribsomal subunit
cc9beltran <- enrichGO(gene = rownames(beltran2016MOCK24)[fData(beltran2016MOCK24)$tagm.phenotype == "Phenotype 9" & fData(beltran2016MOCK24)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(beltran2016MOCK24))) #nothing
```
Beltran HCMV 24 analysis
```{r,}
load("beltranHCMV24TagmNoveltyparams.rda")
data("beltran2016HCMV24")
```
```{r,}
beltranH24NoveltyRes <- tagmNoveltyProcess(object = beltran2016HCMV24, params = beltranHCMV24TagmNoveltyparams)
```
# check convergence
```{r,}
outliers <- mcmc_get_outliers(beltranHCMV24TagmNoveltyparams)
HCMV24diag <- gelman.diag(outliers)
```
```{r,}
beltranHCMV24TagmNoveltyRes <- tagmNoveltyProcess(object = beltran2016HCMV24, params = beltranHCMV24TagmNoveltyparams)
beltranHCMV24TagmNoveltyparams <- tagmMcmcProcess(beltranHCMV24TagmNoveltyparams)
beltran2016HCMV24 <- tagmPredict(object = beltran2016HCMV24, params = beltranHCMV24TagmNoveltyparams)
save(beltranHCMV24TagmNoveltyRes, file = "beltranHCMV24TagmNoveltyRes.rda")
```
```{r,}
## attach information to MSnset
fData(beltran2016HCMV24)$tagm.phenotype <- beltranHCMV24TagmNoveltyRes$mpCombined$cl[rownames(fData(beltran2016HCMV24))]
fData(beltran2016HCMV24)$tagm.newcluster.prob <- beltranHCMV24TagmNoveltyRes$tagm.newcluster.prob[rownames(fData(beltran2016HCMV24))]
fData(beltran2016HCMV24)$tagm.newcluster.prob[is.na(fData(beltran2016HCMV24)$tagm.newcluster.prob)] <- 0
ptsze <- fData(beltran2016HCMV24)$tagm.newcluster.prob
plot2D(beltran2016HCMV24, fcol = "tagm.phenotype", cex = ptsze)
addLegend(beltran2016HCMV24, fcol = "tagm.phenotype", ncol = 2, where = "bottomleft", cex = 0.5)
```
```{r,}
## specify large margin on the right hand side using mar and use xpd = T to allow plotting
par(mar=c(5,4,4,13), xpd = T)
## add legend manually with legend, you will need to play with x and y coords in legend depending on your screen and rendering
ptsze <- fData(beltran2016HCMV24)$tagm.newcluster.prob
plot2D(beltran2016HCMV24, fcol = "tagm.phenotype", cex = ptsze, main = "PCA of HCMV infected fibroblast data with pointer scaled to discovery probability")
myleg <- levels(beltranHCMV24TagmNoveltyRes$mpCombined$cl)
legend(3, 2, legend = myleg, col = getStockcol(), bty = "n",
pch = 19, cex = 0.7, pt.cex = 1)
```
```{r,}
toSubsethl <- (fData(beltran2016HCMV24)$tagm.newcluster.prob > 0.99) & fData(beltran2016HCMV24)$tagm.mcmc.outlier < 0.95
# Create annotation
annot <- data.frame(organelle = fData(beltran2016HCMV24)$tagm.phenotype[toSubsethl])
rownames(annot) <- rownames(fData(beltran2016HCMV24))[toSubsethl]
# Set up for heat map
ann_colors = list(
organelle = c(getStockcol()[1:nlevels(beltranHCMV24TagmNoveltyRes$mpCombined$cl)])
)
names(ann_colors$organelle) <- levels(annot$organelle)
psmSub <- rownames(fData(beltran2016HCMV24))[toSubsethl]
# Create Heatmap of PSM to big too run subset to
pheatmap(beltranHCMV24TagmNoveltyRes$psmCombined[psmSub,psmSub], useRaster = TRUE, annotation_row = annot, show_rownames = F, show_colnames = F, annotation_colors = ann_colors, treeheight_row = 0, treeheight_col = 0, main = "Heatmap of the posterior similarity matrix for the HCMV infected fibroblast data")
```
```{r,}
# Create annotation
annot <- data.frame(organelle = beltranH24NoveltyRes$mpCombined$cl)
# Set up for heat map
ann_colors = list(
organelle = c(getStockcol()[1:nlevels(beltranH24NoveltyRes$mpCombined$cl)])
)
names(ann_colors$organelle) <- levels(annot$organelle)
# Create Heatmap of PSM
pheatmap(beltranH24NoveltyRes$psmCombined, useRaster = TRUE, annotation_row = annot, show_rownames = F, show_colnames = F, annotation_colors = ann_colors,
treeheight_row = 0, treeheight_col = 0)
```
```{r,}
## attach information to MSnset
fData(beltran2016HCMV24)$tagm.phenotype <- beltranH24NoveltyRes$mpCombined$cl[rownames(fData(beltran2016HCMV24))]
fData(beltran2016HCMV24)$tagm.newcluster.prob <- beltranH24NoveltyRes$tagm.newcluster.prob[rownames(fData(beltran2016HCMV24))]
ptsze <- exp(fData(beltran2016HCMV24)$tagm.newcluster.prob) - 1
plot2D(beltran2016HCMV24, fcol = "tagm.phenotype", cex = ptsze, method = "t-SNE")
addLegend(beltran2016HCMV24, fcol = "tagm.phenotype", ncol = 2, where = "topleft", cex = 0.5)
```
```{r,}
cc1Hbeltran <- enrichGO(gene = rownames(beltran2016HCMV24)[fData(beltran2016HCMV24)$tagm.phenotype == "Phenotype 1" &
fData(beltran2016HCMV24)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(beltran2016HCMV24))) #nucleoplasm, small ribosmal subunit/ribsome
cc2Hbeltran <- enrichGO(gene = rownames(beltran2016HCMV24)[fData(beltran2016HCMV24)$tagm.phenotype == "Phenotype 2" & fData(beltran2016HCMV24)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "cc",
universe = rownames(fData(beltran2016HCMV24))) #
cc3Hbeltran <- enrichGO(gene = rownames(beltran2016HCMV24)[fData(beltran2016HCMV24)$tagm.phenotype == "Phenotype 3" & fData(beltran2016HCMV24)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(beltran2016HCMV24))) # mitochondrial part, mitchondriol enevelope
cc4Hbeltran <- enrichGO(gene = rownames(beltran2016HCMV24)[fData(beltran2016HCMV24)$tagm.phenotype == "Phenotype 4" & fData(beltran2016HCMV24)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(beltran2016HCMV24))) # nuclear envelope
cc5Hbeltran <- enrichGO(gene = rownames(beltran2016HCMV24)[fData(beltran2016HCMV24)$tagm.phenotype == "Phenotype 5" & fData(beltran2016HCMV24)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(beltran2016HCMV24))) # ribosome, large ribosomal subunit
cc6Hbeltran <- enrichGO(gene = rownames(beltran2016HCMV24)[fData(beltran2016HCMV24)$tagm.phenotype == "Phenotype 6" & fData(beltran2016HCMV24)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(beltran2016HCMV24))) # nothing
cc7Hbeltran <- enrichGO(gene = rownames(beltran2016HCMV24)[fData(beltran2016HCMV24)$tagm.phenotype == "Phenotype 7" & fData(beltran2016HCMV24)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(beltran2016HCMV24))) # nothing
cc8Hbeltran <- enrichGO(gene = rownames(beltran2016HCMV24)[fData(beltran2016HCMV24)$tagm.phenotype == "Phenotype 8" & fData(beltran2016HCMV24)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(beltran2016HCMV24))) # nothing
cc9Hbeltran <- enrichGO(gene = rownames(beltran2016HCMV24)[fData(beltran2016HCMV24)$tagm.phenotype == "Phenotype 9" & fData(beltran2016HCMV24)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(beltran2016HCMV24))) # nothing
```
```{r,}
ccHbeltran <- list(cc1Hbeltran, cc2Hbeltran, cc3Hbeltran, cc4Hbeltran,
cc5Hbeltran, cc6Hbeltran, cc7Hbeltran, cc8Hbeltran,
cc9Hbeltran)
save(ccHbeltran, file = "ccHbeltran.rda")
```
## Mouse hyperLOPIT analysis
Begin by loading data files and removeing annotations.
```{r,}
load("hlmouseTagmNoveltyParams.rda")
data("hyperLOPIT2015")
hlmouse <- hyperLOPIT2015
fData(hlmouse)$markers[fData(hlmouse)$markers %in% c("40S Ribosome","60S Ribosome",
"Nucleus - Chromatin", "Nucleus - Non-chromatin")] <- "unknown"
```
# Check convergence formally
```{r,}
outliers <- mcmc_get_outliers(hlmouseTagmNoveltyparams)
mouseDiag <- gelman.diag(outliers[c(2,4)])
```
```{r,}
hlmouseTagmNoveltyparams_conv <- hlmouseTagmNoveltyparams[c(2,4)]
hlmouseTagmNoveltyRes_conv <- tagmNoveltyProcess(object = hlmouse, params = hlmouseTagmNoveltyparams_conv)
hlmouseTagmNoveltyparams_conv <- tagmMcmcProcess(hlmouseTagmNoveltyparams_conv)
hlmouse <- tagmPredict(object = hlmouse, params = hlmouseTagmNoveltyparams_conv)
save(hlmouseTagmNoveltyRes_conv, file = "hlmouseTagmNoveltyRes_conv.rda")
```
```{r,}
#load("C:/Users/OllyC/Desktop/NoveltyTagm/hlmouseTagmNoveltyRes.rda")
```
```{r,}
## attach information to MSnset
fData(hlmouse)$tagm.phenotype <- hlmouseTagmNoveltyRes_conv$mpCombined$cl[rownames(fData(hlmouse))]
fData(hlmouse)$tagm.newcluster.prob <- hlmouseTagmNoveltyRes_conv$tagm.newcluster.prob[rownames(fData(hlmouse))]
fData(hlmouse)$tagm.newcluster.prob[is.na(fData(hlmouse)$tagm.newcluster.prob)] <- 0
ptsze <- fData(hlmouse)$tagm.newcluster.prob
plot2D(hlmouse, fcol = "tagm.phenotype", cex = ptsze)
addLegend(hlmouse, fcol = "tagm.phenotype", ncol = 2, where = "bottomleft", cex = 0.5)
```
```{r,}
## specify large margin on the right hand side using mar and use xpd = T to allow plotting
par(mar=c(5,4,4,13), xpd = T)
## add legend manually with legend, you will need to play with x and y coords in legend depending on your screen and rendering
ptsze <- fData(hlmouse)$tagm.newcluster.prob
plot2D(hlmouse, fcol = "tagm.phenotype", cex = ptsze, main = "PCA of hyperLOPIT mouse data with pointer scaled to discovery probability")
myleg <- levels(hlmouseTagmNoveltyRes$mpCombined$cl)
legend(6, 5, legend = myleg, col = getStockcol(), bty = "n",
pch = 19, cex = 0.7, pt.cex = 1)
```
```{r,}
toSubsethl <- (fData(hlmouse)$tagm.newcluster.prob > 0.99) & fData(hlmouse)$TAGM$tagm.mcmc.outlier < 0.95
# Create annotation
annot <- data.frame(organelle = fData(hlmouse)$tagm.phenotype[toSubsethl])
rownames(annot) <- rownames(fData(hlmouse))[toSubsethl]
# Set up for heat map
ann_colors = list(
organelle = c(getStockcol()[1:nlevels(hlmouseTagmNoveltyRes$mpCombined$cl)])
)
names(ann_colors$organelle) <- levels(annot$organelle)
psmSub <- rownames(fData(hlmouse))[toSubsethl]
# Create Heatmap of PSM to big too run subset to
pheatmap(hlmouseTagmNoveltyRes$psmCombined[psmSub,psmSub], useRaster = TRUE, annotation_row = annot, show_rownames = F, show_colnames = F, annotation_colors = ann_colors, treeheight_row = 0, treeheight_col = 0, main = "Heatmap of the posterior similarity matrix for the mouse data")
```
```{r,}
cc1hlmouse <- enrichGO(gene = rownames(hlmouse)[fData(hlmouse)$tagm.phenotype == "Phenotype 1" & fData(hlmouse)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Mm.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(hlmouse))) # centrosome
cc2hlmouse <- enrichGO(gene = rownames(hlmouse)[fData(hlmouse)$tagm.phenotype == "Phenotype 2" & fData(hlmouse)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Mm.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(hlmouse))) # chromosome and chromatin
cc3hlmouse <- enrichGO(gene = rownames(hlmouse)[fData(hlmouse)$tagm.phenotype == "Phenotype 3" & fData(hlmouse)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Mm.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(hlmouse))) # nucleolus
cc4hlmouse <- enrichGO(gene = rownames(hlmouse)[fData(hlmouse)$tagm.phenotype == "Phenotype 4" & fData(hlmouse)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Mm.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(hlmouse))) # ribosome
cc5hlmouse <- enrichGO(gene = rownames(hlmouse)[fData(hlmouse)$tagm.phenotype == "Phenotype 5" & fData(hlmouse)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Mm.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(hlmouse))) # cilium doesnt make any sense
cc6hlmouse <- enrichGO(gene = rownames(hlmouse)[fData(hlmouse)$tagm.phenotype == "Phenotype 6" & fData(hlmouse)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Mm.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(hlmouse))) #nothing
cc7hlmouse <- enrichGO(gene = rownames(hlmouse)[fData(hlmouse)$tagm.phenotype == "Phenotype 7" & fData(hlmouse)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Mm.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(hlmouse))) # plasma membrane part
cc8hlmouse <- enrichGO(gene = rownames(hlmouse)[fData(hlmouse)$tagm.phenotype == "Phenotype 8" & fData(hlmouse)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Mm.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(hlmouse))) # cytoskeletal
cc9hlmouse <- enrichGO(gene = rownames(hlmouse)[fData(hlmouse)$tagm.phenotype == "Phenotype 9" & fData(hlmouse)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Mm.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(hlmouse))) # nothing
```
```{r,}
data("yeast2018")
load("hlyeastTagmNoveltyparams.rda")
```
Check convergence formally
```{r,}
outliers <- mcmc_get_outliers(hlyeastTagmNoveltyparams)
yeastDiag <- gelman.diag(outliers[c(5,6)])
hlyeastTagmNoveltyparams_conv <- hlyeastTagmNoveltyparams[c(5,6)]
```
```{r,}
#hlyeastTagmNoveltyRes <- tagmNoveltyProcess(object = yeast2018, params = hlyeastTagmNoveltyparams_conv)
hlyeastTagmNoveltyparams_conv <- tagmMcmcProcess(hlyeastTagmNoveltyparams_conv)
yeast2018 <- tagmPredict(object = yeast2018, params = hlyeastTagmNoveltyparams_conv)
#save(hlyeastTagmNoveltyRes, file = "hlyeastTagmNoveltyRes.rda")
```
```{r,}
## attach information to MSnset
fData(yeast2018)$tagm.phenotype <- hlyeastTagmNoveltyRes$mpCombined$cl[rownames(fData(yeast2018))]
fData(yeast2018)$tagm.newcluster.prob <- hlyeastTagmNoveltyRes$tagm.newcluster.prob[rownames(fData(yeast2018))]
fData(yeast2018)$tagm.newcluster.prob[is.na(fData(yeast2018)$tagm.newcluster.prob)] <- 0
ptsze <- fData(yeast2018)$tagm.newcluster.prob
plot2D(yeast2018, fcol = "tagm.phenotype", cex = ptsze)
addLegend(yeast2018, fcol = "tagm.phenotype", ncol = 2, where = "bottomleft", cex = 0.5)
```
```{r,}
## specify large margin on the right hand side using mar and use xpd = T to allow plotting
par(mar=c(5,4,4,13), xpd = T)
## add legend manually with legend, you will need to play with x and y coords in legend depending on your screen and rendering
ptsze <- fData(yeast2018)$tagm.newcluster.prob
plot2D(yeast2018, fcol = "tagm.phenotype", cex = ptsze, main = "PCA of hyperLOPIT yeast data with pointer scaled to discovery probability")
myleg <- levels(hlyeastTagmNoveltyRes$mpCombined$cl)
legend(9, 7, legend = myleg, col = getStockcol(), bty = "n",
pch = 19, cex = 0.7, pt.cex = 1)
```
```{r,}
toSubsethl <- (fData(yeast2018)$tagm.newcluster.prob > 0.99) & fData(yeast2018)$tagm.mcmc.outlier < 0.95
# Create annotation
annot <- data.frame(organelle = fData(yeast2018)$tagm.phenotype[toSubsethl])
rownames(annot) <- rownames(fData(yeast2018))[toSubsethl]
# Set up for heat map
ann_colors = list(
organelle = c(getStockcol()[1:nlevels(hlyeastTagmNoveltyRes$mpCombined$cl)])
)
names(ann_colors$organelle) <- levels(annot$organelle)
psmSub <- rownames(fData(yeast2018))[toSubsethl]
# Create Heatmap of PSM to big too run subset to
pheatmap(hlyeastTagmNoveltyRes$psmCombined[psmSub,psmSub], useRaster = TRUE, annotation_row = annot, show_rownames = F, show_colnames = F, annotation_colors = ann_colors, treeheight_row = 0, treeheight_col = 0, main = "Heatmap of the posterior similarity matrix for the yeast data", col = myBlues, cellwidth = 1)
```
```{r,}
cc1hlyeast <- enrichGO(gene = rownames(yeast2018)[fData(yeast2018)$tagm.phenotype == "Phenotype 1" & fData(yeast2018)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Sc.sgd.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(yeast2018))) # lytic vacuole, cell periphery, vaculoas membrane, plasma membrane
cc2hlyeast <- enrichGO(gene = rownames(yeast2018)[fData(yeast2018)$tagm.phenotype == "Phenotype 2" & fData(yeast2018)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Sc.sgd.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(yeast2018))) #
cc3hlyeast <- enrichGO(gene = rownames(yeast2018)[fData(yeast2018)$tagm.phenotype == "Phenotype 3" & fData(yeast2018)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Sc.sgd.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(yeast2018))) # transferase complex
cc4hlyeast <- enrichGO(gene = rownames(yeast2018)[fData(yeast2018)$tagm.phenotype == "Phenotype 4" & fData(yeast2018)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Sc.sgd.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(yeast2018))) # cytoskeleton
cc5hlyeast <- enrichGO(gene = rownames(yeast2018)[fData(yeast2018)$tagm.phenotype == "Phenotype 5" & fData(yeast2018)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Sc.sgd.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(yeast2018))) #
cc6hlyeast <- enrichGO(gene = rownames(yeast2018)[fData(yeast2018)$tagm.phenotype == "Phenotype 6"& fData(yeast2018)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Sc.sgd.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(yeast2018))) #none
cc7hlyeast <- enrichGO(gene = rownames(yeast2018)[fData(yeast2018)$tagm.phenotype == "Phenotype 7" & fData(yeast2018)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Sc.sgd.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(yeast2018)))
cc8hlyeast <- enrichGO(gene = rownames(yeast2018)[fData(yeast2018)$tagm.phenotype == "Phenotype 8" & fData(yeast2018)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Sc.sgd.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(yeast2018))) # ER membrane / golgi assoicated vesicle
cc10hlyeast <- enrichGO(gene = rownames(yeast2018)[fData(yeast2018)$tagm.phenotype == "Phenotype 10" & fData(yeast2018)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Sc.sgd.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(yeast2018))) #
```
```{r,}
ccYeastres <- list(cc1hlyeast, cc2hlyeast, cc3hlyeast, cc4hlyeast,
cc5hlyeast, cc6hlyeast, cc7hlyeast, cc8hlyeast,
cc10hlyeast)
save(ccYeastres, file = "ccYeastres.rda")
```
## Itzhak 2016
```{r,}
load("itzhak2016TagmNoveltyparams.rda")
data("itzhak2016stcSILAC")
fData(itzhak2016stcSILAC)$markers[fData(itzhak2016stcSILAC)$markers %in% c("Large Protein Complex")] <- "unknown"
itzhak2016 <- filterNA(itzhak2016stcSILAC)
normalise(itzhak2016, method = "vsn")
```
```{r,}
outliers <- mcmc_get_outliers(itzhak2016TagmNoveltyparams)
itzhak2016Diag <- gelman.diag(outliers[c(1,2,6)])
```
```{r,}
itzhak2016TagmNoveltyparams_conv <- itzhak2016TagmNoveltyparams[c(1,2,6)]
#itzhak2016NoveltyRes <- tagmNoveltyProcess(object = itzhak2016, params = itzhak2016TagmNoveltyparams_conv)
itzhak2016TagmNoveltyparams_conv <- tagmMcmcProcess(itzhak2016TagmNoveltyparams_conv)
itzhak2016 <- tagmPredict(object = itzhak2016, params = itzhak2016TagmNoveltyparams_conv)
#save(itzhak2016NoveltyRes, file = "itzhak2016NovelyRes.rda")
```
```{r,}
fData(itzhak2016)$tagm.phenotype <- itzhak2016NoveltyRes$mpCombined$cl[rownames(fData(itzhak2016))]
fData(itzhak2016)$tagm.newcluster.prob <- itzhak2016NoveltyRes$tagm.newcluster.prob[rownames(fData(itzhak2016))]
fData(itzhak2016)$tagm.newcluster.prob[is.na(fData(itzhak2016)$tagm.newcluster.prob)] <- 0
ptsze <- fData(itzhak2016)$tagm.newcluster.prob
plot2D(itzhak2016, fcol = "tagm.phenotype", cex = ptsze)
addLegend(itzhak2016, fcol = "tagm.phenotype", ncol = 2, where = "bottomleft", cex = 0.5)
```
```{r,}
## specify large margin on the right hand side using mar and use xpd = T to allow plotting
par(mar=c(5,4,4,13), xpd = T)
## add legend manually with legend, you will need to play with x and y coords in legend depending on your screen and rendering
ptsze <- fData(itzhak2016)$tagm.newcluster.prob
plot2D(itzhak2016, fcol = "tagm.phenotype", cex = ptsze, main = "PCA of HeLa (itzhak 2016) data with pointer scaled to discovery probability")
myleg <- levels(itzhak2016NoveltyRes$mpCombined$cl)
legend(13, 10, legend = myleg, col = getStockcol(), bty = "n",
pch = 19, cex = 0.7, pt.cex = 1)
```
```{r,}
toSubsethl <- (fData(itzhak2016)$tagm.newcluster.prob > 0.99) & fData(itzhak2016)$tagm.mcmc.outlier < 0.95
# Create annotation
annot <- data.frame(organelle = fData(itzhak2016)$tagm.phenotype[toSubsethl])
rownames(annot) <- rownames(fData(itzhak2016))[toSubsethl]
# Set up for heat map
ann_colors = list(
organelle = c(getStockcol()[1:nlevels(itzhak2016NoveltyRes$mpCombined$cl)])
)
names(ann_colors$organelle) <- levels(annot$organelle)
psmSub <- rownames(fData(itzhak2016))[toSubsethl]
# Create Heatmap of PSM to big too run subset to
pheatmap(itzhak2016NoveltyRes$psmCombined[psmSub,psmSub], useRaster = TRUE, annotation_row = annot, show_rownames = F, show_colnames = F, annotation_colors = ann_colors, treeheight_row = 0, treeheight_col = 0, main = "Heatmap of the posterior similarity matrix for the HeLa (Itzhak) data", col = myBlues, cellwidth = 2)
```
```{r,}
## attach information to MSnset
fData(itzhak2016)$tagm.phenotype <- itzhak2016NoveltyRes$mpCombined$cl[rownames(fData(itzhak2016))]
fData(itzhak2016)$tagm.newcluster.prob <- itzhak2016NoveltyRes$tagm.newcluster.prob[rownames(fData(itzhak2016))]
ptsze <- fData(itzhak2016)$tagm.newcluster.prob
plot2D(itzhak2016, fcol = "tagm.phenotype", cex = ptsze)
addLegend(itzhak2016, fcol = "tagm.phenotype", ncol = 2, where = "bottomleft", cex = 0.5)
```
```{r,}
cc1itzhak2016 <- enrichGO(gene = rownames(itzhak2016)[fData(itzhak2016)$tagm.phenotype == "Phenotype 1" & fData(itzhak2016)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(itzhak2016))) # mitochondrial membrane
cc2itzhak2016 <- enrichGO(gene = rownames(itzhak2016)[fData(itzhak2016)$tagm.phenotype == "Phenotype 2" & fData(itzhak2016)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(itzhak2016))) # cytosolic part / nucleolus
cc3itzhak2016 <- enrichGO(gene = rownames(itzhak2016)[fData(itzhak2016)$tagm.phenotype == "Phenotype 3" & fData(itzhak2016)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(itzhak2016))) # chromsome/ chromatin
```
```{r,}
ccItzhak2016res <- list(cc1itzhak2016, cc2itzhak2016, cc3itzhak2016)
save(ccItzhak2016res, file = "ccItzhak2016res.rda")
```
# LOPIT DC U2OS
```{r,}
load("dcU2OSTagmNoveltyparams.rda")
data(lopitdcU2OS2018)
fData(lopitdcU2OS2018)$markers[fData(lopitdcU2OS2018)$markers %in% c("NUCLEUS/CHROMATIN","PROTEASOME",
"RIBOSOME")] <- "unknown"
```
# assess convergence
```{r,}
dcOutlier <- mcmc_get_outliers(dcU2OSTagmNoveltyparams)
gelman.diag(dcOutlier[c(1,3,5)])
```
```{r,}
dcU2OSTagmNoveltyparams_conv <- dcU2OSTagmNoveltyparams[c(1,3,5)]
```
```{r,}
lopitdcNoveltyRes_conv <- tagmNoveltyProcess(object = lopitdcU2OS2018, params = dcU2OSTagmNoveltyparams_conv)
dcU2OSTagmNoveltyparams_conv <- tagmMcmcProcess(params = dcU2OSTagmNoveltyparams_conv)
save(dcU2OSTagmNoveltyparams_conv, file = "dcU2OSTagmNoveltyparams_conv.rda")
lopitdcU2OS2018 <- tagmPredict(object = lopitdcU2OS2018, params = dcU2OSTagmNoveltyparams_conv)
save(lopitdcNoveltyRes_conv, file = "lopitdcNoveltyRes_conv.rda")
```
```{r,}
## attach information to MSnset
fData(lopitdcU2OS2018)$tagm.phenotype <- lopitdcNoveltyRes_conv$mpCombined$cl[rownames(fData(lopitdcU2OS2018))]
fData(lopitdcU2OS2018)$tagm.newcluster.prob <- lopitdcNoveltyRes_conv$tagm.newcluster.prob[rownames(fData(lopitdcU2OS2018))]
fData(lopitdcU2OS2018)$tagm.newcluster.prob[is.na(fData(lopitdcU2OS2018)$tagm.newcluster.prob)] <- 0
ptsze <- fData(lopitdcU2OS2018)$tagm.newcluster.prob
plot2D(lopitdcU2OS2018, fcol = "tagm.phenotype", cex = ptsze)
addLegend(lopitdcU2OS2018, fcol = "tagm.phenotype", ncol = 2, where = "bottomleft", cex = 0.5)
```
```{r,}
## specify large margin on the right hand side using mar and use xpd = T to allow plotting
par(mar=c(5,4,4,10), xpd = T)
## add legend manually with legend, you will need to play with x and y coords in legend depending on your screen and rendering
ptsze <- fData(lopitdcU2OS2018)$tagm.newcluster.prob
plot2D(lopitdcU2OS2018 , fcol = "tagm.phenotype", cex = ptsze, main = "PCA of LOPIT-DC U2OS data with pointer scaled to discovery probability")
myleg <- levels(lopitdcNoveltyRes_conv$mpCombined$cl)
legend(10, 8, legend = myleg, col = getStockcol(), bty = "n",
pch = 19, cex = 0.7, pt.cex = 1)
```
```{r,}
toSubsethl <- (fData(lopitdcU2OS2018)$tagm.newcluster.prob > 0.99) & fData(lopitdcU2OS2018)$tagm.mcmc.outlier < 0.00001
# Create annotation
annot <- data.frame(organelle = fData(lopitdcU2OS2018)$tagm.phenotype[toSubsethl])
rownames(annot) <- rownames(fData(lopitdcU2OS2018))[toSubsethl]
# Set up for heat map
ann_colors = list(
organelle = c(getStockcol()[1:nlevels(lopitdcNoveltyRes_conv$mpCombined$cl)])
)
names(ann_colors$organelle) <- levels(annot$organelle)
psmSub <- rownames(fData(lopitdcU2OS2018))[toSubsethl]
# Create Heatmap of PSM to big too run subset to
pheatmap(lopitdcNoveltyRes_conv$psmCombined[psmSub,psmSub], useRaster = TRUE, annotation_row = annot, show_rownames = F, show_colnames = F, annotation_colors = ann_colors, treeheight_row = 0, treeheight_col = 0, main = "Heatmap of the posterior similarity matrix for the U2OS LOPIT-DC data", col = myBlues)
```
```{r,}
cc1DC <- enrichGO(gene = rownames(lopitdcU2OS2018)[fData(lopitdcU2OS2018)$tagm.phenotype == "Phenotype 1" & fData(lopitdcU2OS2018)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(lopitdcU2OS2018))) # nothing
cc2DC <- enrichGO(gene = rownames(lopitdcU2OS2018)[fData(lopitdcU2OS2018)$tagm.phenotype == "Phenotype 2" & fData(lopitdcU2OS2018)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(lopitdcU2OS2018))) # actin cytoskeleton
cc3DC<- enrichGO(gene = rownames(lopitdcU2OS2018)[fData(lopitdcU2OS2018)$tagm.phenotype == "Phenotype 3" & fData(lopitdcU2OS2018)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(lopitdcU2OS2018))) # nucleolus, ribsomal subunit
cc4DC <- enrichGO(gene = rownames(lopitdcU2OS2018)[fData(lopitdcU2OS2018)$tagm.phenotype == "Phenotype 4" & fData(lopitdcU2OS2018)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(lopitdcU2OS2018))) # nucleolus
cc5DC <- enrichGO(gene = rownames(lopitdcU2OS2018)[fData(lopitdcU2OS2018)$tagm.phenotype == "Phenotype 5" & fData(lopitdcU2OS2018)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(lopitdcU2OS2018))) # proteasome
cc6DC <- enrichGO(gene = rownames(lopitdcU2OS2018)[fData(lopitdcU2OS2018)$tagm.phenotype == "Phenotype 6" & fData(lopitdcU2OS2018)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(lopitdcU2OS2018))) # extracellular matrix
cc7DC <- enrichGO(gene = rownames(lopitdcU2OS2018)[fData(lopitdcU2OS2018)$tagm.phenotype == "Phenotype 7" & fData(lopitdcU2OS2018)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(lopitdcU2OS2018))) # myosin complex
cc8DC <- enrichGO(gene = rownames(lopitdcU2OS2018)[fData(lopitdcU2OS2018)$tagm.phenotype == "Phenotype 8" & fData(lopitdcU2OS2018)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(lopitdcU2OS2018))) #endosome / early endosome
cc9DC <- enrichGO(gene = rownames(lopitdcU2OS2018)[fData(lopitdcU2OS2018)$tagm.phenotype == "Phenotype 9" & fData(lopitdcU2OS2018)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(lopitdcU2OS2018))) #chromsome,
cc10DC <- enrichGO(gene = rownames(lopitdcU2OS2018)[fData(lopitdcU2OS2018)$tagm.phenotype == "Phenotype 10" & fData(lopitdcU2OS2018)$tagm.newcluster.prob > 0.95],
OrgDb = "org.Hs.eg.db",
keyType = "UNIPROT",
ont = "CC",
universe = rownames(fData(lopitdcU2OS2018))) # mitchondrial membrane
```
```{r,}
goCCDCres <- list(cc1DC, cc2DC, cc3DC, cc4DC,
cc5DC, cc6DC, cc7DC, cc8DC,
cc9DC, cc10DC)
save(goCCDCres, file = "goCCDCres.rda")
```
```{r,}
hpa <- read.table("aal3321_Thul_SM_table_S11.csv", sep = ",", header = TRUE)
annotations <- table(hpa[hpa[,3] %in% substr(rownames(lopitdcU2OS2018)[fData(lopitdcU2OS2018)$tagm.phenotype == "Phenotype 1"], 1, 6), "U.2.OS.location"])
annotations[order(annotations, decreasing = T)[1:20]]
annotations <- table(hpa[hpa[,3] %in% substr(rownames(lopitdcU2OS2018)[fData(lopitdcU2OS2018)$tagm.phenotype == "Phenotype 2"], 1, 6), "U.2.OS.location"])
annotations[order(annotations, decreasing = T)[1:20]]
annotations <- table(hpa[hpa[,3] %in% substr(rownames(lopitdcU2OS2018)[fData(lopitdcU2OS2018)$tagm.phenotype == "Phenotype 3"], 1, 6), "U.2.OS.location"])
annotations[order(annotations, decreasing = T)[1:20]] #nucleus enriched
annotations <- table(hpa[hpa[,3] %in% substr(rownames(lopitdcU2OS2018)[fData(lopitdcU2OS2018)$tagm.phenotype == "Phenotype 4"], 1, 6), "U.2.OS.location"])
annotations[order(annotations, decreasing = T)[1:20]] #nucleus enriched
annotations <- table(hpa[hpa[,3] %in% substr(rownames(lopitdcU2OS2018)[fData(lopitdcU2OS2018)$tagm.phenotype == "Phenotype 5"], 1, 6), "U.2.OS.location"])
annotations[order(annotations, decreasing = T)[1:20]] #nucleaus enriched
annotations <- table(hpa[hpa[,3] %in% substr(rownames(lopitdcU2OS2018)[fData(lopitdcU2OS2018)$tagm.phenotype == "Phenotype 6"], 1, 6), "U.2.OS.location"])
annotations[order(annotations, decreasing = T)[1:20]]
annotations <- table(hpa[hpa[,3] %in% substr(rownames(lopitdcU2OS2018)[fData(lopitdcU2OS2018)$tagm.phenotype == "Phenotype 7"], 1, 6), "U.2.OS.location"])
annotations[order(annotations, decreasing = T)[1:20]] #nucleaus enriched
annotations <- table(hpa[hpa[,3] %in% substr(rownames(lopitdcU2OS2018)[fData(lopitdcU2OS2018)$tagm.phenotype == "Phenotype 8"], 1, 6), "U.2.OS.location"])
annotations[order(annotations, decreasing = T)[1:20]]
annotations <- table(hpa[hpa[,3] %in% substr(rownames(lopitdcU2OS2018)[fData(lopitdcU2OS2018)$tagm.phenotype == "Phenotype 9"], 1, 6), "U.2.OS.location"])
annotations[order(annotations, decreasing = T)[1:20]] #nucleaus enriched
annotations <- table(hpa[hpa[,3] %in% substr(rownames(lopitdcU2OS2018)[fData(lopitdcU2OS2018)$tagm.phenotype == "Phenotype 10"], 1, 6), "U.2.OS.location"])
annotations[order(annotations, decreasing = T)[1:20]]
```
## Itzhak 2017
```{r,}
data(itzhak2017)
fData(itzhak2017)$markers[fData(itzhak2017)$markers %in% c("Large Protein Complex")] <- "unknown"
itzhak2017 <- filterNA(itzhak2017[,c(1:18)])
load("itzhak2017TagmNoveltyparams.rda")
```
```{r,}
itzhak2017NoveltyRes <- tagmNoveltyProcess(object = itzhak2017[,c(1:18)], params = itzhak2017TagmNoveltyparams_thinned)
save(itzhak2017NoveltyRes, file = "itzhak2017NoveltyRes.rda")
```
## check convergece
```{r,}
outliers <- mcmc_get_outliers(itzhak2017TagmNoveltyparams)
itzhak2017diag <- gelman.diag(outliers[c(4,5)])
```
```{r,}
itzhak2017TagmNoveltyparams_conv <- itzhak2017TagmNoveltyparams[c(4,5)]
#itzhak2017NoveltyRes <- tagmNoveltyProcess(object = itzhak2017, params = itzhak2017TagmNoveltyparams_conv)
itzhak2017TagmNoveltyparams_conv <- tagmMcmcProcess(itzhak2017TagmNoveltyparams_conv)
itzhak2017 <- tagmPredict(itzhak2017, params = itzhak2017TagmNoveltyparams_conv)
#save(itzhak2017NoveltyRes, file = "itzhak2017NoveltyRes.rda")
```
```{r,}
## attach information to MSnset
fData(itzhak2017)$tagm.phenotype <- itzhak2017NoveltyRes$mpCombined$cl[rownames(fData(itzhak2017))]
fData(itzhak2017)$tagm.newcluster.prob <- itzhak2017NoveltyRes$tagm.newcluster.prob[rownames(fData(itzhak2017))]
fData(itzhak2017)$tagm.newcluster.prob[is.na(fData(itzhak2017)$tagm.newcluster.prob)] <- 0
ptsze <- fData(itzhak2017)$tagm.newcluster.prob
plot2D(itzhak2017, fcol = "tagm.phenotype", cex = ptsze)
addLegend(itzhak2017, fcol = "tagm.phenotype", ncol = 2, where = "bottomleft", cex = 0.5)
```
```{r,}
## specify large margin on the right hand side using mar and use xpd = T to allow plotting
par(mar=c(5,4,4,10), xpd = T)
## add legend manually with legend, you will need to play with x and y coords in legend depending on your screen and rendering
ptsze <- fData(itzhak2017)$tagm.newcluster.prob
plot2D(itzhak2017 , fcol = "tagm.phenotype", cex = ptsze, main = "PCA of mouse neuron data with pointer scaled to discovery probability")
myleg <- levels(itzhak2017NoveltyRes$mpCombined$cl)
legend(7, 8, legend = myleg, col = getStockcol(), bty = "n",
pch = 19, cex = 0.7, pt.cex = 1)
```
```{r,}
toSubsethl <- (fData(itzhak2017)$tagm.newcluster.prob > 0.99) & fData(itzhak2017)$tagm.mcmc.outlier < 0.01
# Create annotation