-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRWorkshop_MixOmics_MQ_PatBuerger.Rmd
693 lines (568 loc) · 22.7 KB
/
RWorkshop_MixOmics_MQ_PatBuerger.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
---
title: "MIXOMICS - R WORKSHOP - MACQUARIE UNIVERSITY"
author: "Pat Buerger ([email protected])"
date: '07-09-2023'
output:
pdf_document:
extra_dependencies: subfig
number_sections: yes
toc: yes
toc_depth: 3
highlight: zenburn
header-includes:
- \usepackage{fancyhdr}
- \usepackage{mathtools}
- \usepackage{hyperref}
- \setlength{\headheight}{33pt}
- \setlength{\footskip}{25pt}
- \pagestyle{fancy}
- \renewcommand{\headrulewidth}{0.5pt}
- \renewcommand{\footrulewidth}{0.5pt}
- \rhead{\thepage}
- \hypersetup{colorlinks = true, linkcolor=blue, urlcolor = blue}
- \fancypagestyle{plain}{\pagestyle{fancy}}
editor_options:
chunk_output_type: console
---
```{r global_options, include=FALSE}
library(knitr)
# global options to show by default the code, dump the figures into /Figures etc
# change as required
knitr::opts_chunk$set(dpi = 100,
echo=TRUE,
warning=FALSE, message=FALSE, eval = TRUE,
fig.show=TRUE, fig.width= 6,fig.height= 5,fig.align='center',
out.width = '60%', fig.path= 'Figures/')
```
<br>
###############################################################
###############################################################
# INTRODUCTION
###############################################################
<p>Abstract: </p>
MixOmics example: Case Study of DIABLO with Breast TCGA Dataset, using PCA, PLS-DA (supervised), sparse PLS-DA (supervised + data reduction), and multiblock sparse PLS-DA (DIABLO).
<p> **Modified code from MixOmics R package** </p>
Source for R-code: https://mixomicsteam.github.io/mixOmics-Vignette/
## Load Packages
```{r packages, message=FALSE}
#install.packages('markdown')
#install.packages('mixOmics')
#install.packages('tidyverse')
library(mixOmics)
library(tidyverse)
```
\
## Load Data
```{r}
# Load data
data(breast.TCGA)
# Extract training data and name each data frame
# Store as list
X <- list(mRNA = breast.TCGA$data.train$mrna,
miRNA = breast.TCGA$data.train$mirna,
protein = breast.TCGA$data.train$protein)
# Outcome
Y <- breast.TCGA$data.train$subtype
summary(Y)
```
<!-- New page -->
\pagebreak
###############################################################
###############################################################
# Principal Component Analysis (PCA)
###############################################################
```{r}
# Check data first with PCA to detect outliers and general structure of data.
# 1 Run the method
MyResult.pca_miRNA <- pca(X$miRNA)
MyResult.pca_mRNA <- pca(X$mRNA)
MyResult.pca_protein <- pca(X$protein)
```
```{r}
## 2.1 Plot the samples
## miRNA
# PLOT WITH ADDITIONAL SYMBOLS
plotIndiv(MyResult.pca_miRNA, ind.names = FALSE,
group = Y,
pch = as.factor(Y),
legend = TRUE, title = 'miRNA: PCA comp 1 - 2',
legend.title = 'miRNA', legend.title.pch = 'miRNA')
```
<p style="text-align: center;">**FIGURE: miRNA PCA:** comp 1 - 2</p>
<br>
<br>
```{r}
## 2.2 Plot the samples
## mRNA
# PLOT WITH ADDITIONAL SYMBOLS
plotIndiv(MyResult.pca_mRNA, ind.names = FALSE,
group = Y,
pch = as.factor(Y),
legend = TRUE, title = 'mRNA: PCA comp 1 - 2',
legend.title = 'mRNA', legend.title.pch = 'mRNA')
```
<p style="text-align: center;">**FIGURE: mRNA PCA:** comp 1 - 2</p>
<br>
<br>
```{r}
## 2.3 Plot the samples
## protein
# PLOT WITH ADDITIONAL SYMBOLS
plotIndiv(MyResult.pca_protein, ind.names = FALSE,
group = Y,
pch = as.factor(Y),
legend = TRUE, title = 'protein: PCA comp 1 - 2',
legend.title = 'protein', legend.title.pch = 'protein')
```
<p style="text-align: center;">**FIGURE: protein PCA:** comp 1 - 2</p>
<br>
<br>
#### PCA: Conclusion
Data looks all right. No outliers detected. Seems to be some grouping of samples present. <br>
-> Problem: There is some source of variation in the data that we can not explain with our strain groupings. <br>
-> We need to have some sort of supervised analysis to resolve this. <br>
<br>
###############################################################
###############################################################
# Partial Least Squares – Discriminant Analysis (PLS-DA)
###############################################################
```{r}
##### PLS-DA, sPLS-DA ####
# 1 Run the method
MyResult.plsda_miRNA <- plsda(X$miRNA, Y)
MyResult.plsda_mRNA <- plsda(X$mRNA, Y)
MyResult.plsda_protein <- plsda(X$protein, Y)
```
```{r}
# sPLS-DA NEEDS TO BE TUNED AND NUMBERS OF COMPONENTS OPTIMISED. SKIPPED HERE DUE TO TIME CONSTRAINTS. SEE LINK BELOW FOR FURTHER INFORMATION:
#https://mixomicsteam.github.io/mixOmics-Vignette/id_05.html
# 2.1 Plot the samples
plotIndiv(MyResult.plsda_miRNA, ind.names = FALSE,
group = Y,
pch = as.factor(Y),
legend = TRUE, title = 'miRNA: PLS-DA comp 1 - 2',
legend.title = 'miRNA', legend.title.pch = 'miRNA')
```
<p style="text-align: center;">**FIGURE: miRNA PLS-DA:** comp 1 - 2, supervised analysis using the full data.</p>
<br>
<br>
```{r}
# sPLS-DA NEEDS TO BE TUNED AND NUMBERS OF COMPONENTS OPTIMISED. SKIPPED HERE DUE TO TIME CONSTRAINTS. SEE LINK BELOW FOR FURTHER INFORMATION:
#https://mixomicsteam.github.io/mixOmics-Vignette/id_05.html
# 2.2 Plot the samples
plotIndiv(MyResult.plsda_mRNA, ind.names = FALSE,
group = Y,
pch = as.factor(Y),
legend = TRUE, title = 'mRNA: PLS-DA comp 1 - 2',
legend.title = 'mRNA', legend.title.pch = 'mRNA')
```
<p style="text-align: center;">**FIGURE: mRNA PLS-DA:** comp 1 - 2, supervised analysis using the full data.</p>
<br>
<br>
```{r}
# sPLS-DA NEEDS TO BE TUNED AND NUMBERS OF COMPONENTS OPTIMISED. SKIPPED HERE DUE TO TIME CONSTRAINTS. SEE LINK BELOW FOR FURTHER INFORMATION:
#https://mixomicsteam.github.io/mixOmics-Vignette/id_05.html
# 2.3 Plot the samples
plotIndiv(MyResult.plsda_protein, ind.names = FALSE,
group = Y,
pch = as.factor(Y),
legend = TRUE, title = 'protein: PLS-DA comp 1 - 2',
legend.title = 'protein', legend.title.pch = 'protein')
```
<p style="text-align: center;">**FIGURE: protein PLS-DA:** comp 1 - 2, supervised analysis using the full data.</p>
<br>
<br>
```{r}
# 3.1 Plot the variables
plotVar(MyResult.plsda_miRNA)
```
<p style="text-align: center;">**FIGURE: miRNA: PLS-DA:** contributing variables to PLS-DA comp 1 - 2, supervised analysis using the full data.</p>
<br>
<br>
```{r}
# 3.2 Plot the variables
plotVar(MyResult.plsda_mRNA)
```
<p style="text-align: center;">**FIGURE: mRNA: PLS-DA:** contributing variables to PLS-DA comp 1 - 2, supervised analysis using the full data.</p>
<br>
<br>
```{r}
# 3.3 Plot the variables
plotVar(MyResult.plsda_protein)
```
<p style="text-align: center;">**FIGURE: Protein: PLS-DA:** contributing variables to PLS-DA comp 1 - 2, supervised analysis using the full data.</p>
<br>
<br>
#### PLS-DA: Conclusion
Lots of variable and some noise in the data. Data reduction might be beneficial using a sparse PLS-DA in order to separate groups and get a clear picture of the data and important variables.
<br>
<br>
<br>
<!-- New page -->
\pagebreak
###############################################################
###############################################################
# sparse Partial Least Squares – Discriminant Analysis (sPLS-DA)
###############################################################
```{r}
# DATA REDUCTION APPROACH.
#########
# miRNA
#########
# sPLS-DA NEEDS TO BE TUNED AND NUMBERS OF COMPONENTS OPTIMISED. SKIPPED HERE DUE TO TIME CONSTRAINTS. SEE LINK BELOW FOR FURTHER INFORMATION:
#https://mixomicsteam.github.io/mixOmics-Vignette/id_05.html
#### sPLS-DA, using reduced data, TOP 15 variables
MyResult.splsda.miRNA <- splsda(X$miRNA, Y, keepX = c(15,15)) # 1 Run the method
plotIndiv(MyResult.splsda.miRNA) # 2 Plot the samples
```
<p style="text-align: center;">**FIGURE: miRNA sparse PLS-DA:** comp 1 - 2, supervised analysis using the only the most influential variables, here TOP 15.</p>
<br>
<br>
```{r}
plotVar(MyResult.splsda.miRNA) # 3 Plot the variables
```
<p style="text-align: center;">**FIGURE: miRNA contributing variables to sparse PLS-DA:** comp 1 - 2, supervised analysis using the only the most influential variables, here TOP 15.</p>
<br>
<br>
```{r}
selectVar(MyResult.splsda.miRNA, comp = 1)$value # Selected variables on comp 1
plotLoadings(MyResult.splsda.miRNA, comp = 1, method = 'mean', contrib = 'max')
```
<p style="text-align: center;">**FIGURE: miRNA contributing variables to sparse PLS-DA:** comp 1.</p>
<br>
<br>
```{r}
selectVar(MyResult.splsda.miRNA, comp = 2)$value # Selected variables on comp 1
plotLoadings(MyResult.splsda.miRNA, comp = 2, method = 'mean', contrib = 'max')
```
<p style="text-align: center;">**FIGURE: miRNA contributing variables to sparse PLS-DA:** comp 2.</p>
<br>
<br>
```{r}
# DATA REDUCTION APPROACH.
#########
# mRNA
#########
# sPLS-DA NEEDS TO BE TUNED AND NUMBERS OF COMPONENTS OPTIMISED. SKIPPED HERE DUE TO TIME CONSTRAINTS. SEE LINK BELOW FOR FURTHER INFORMATION:
#https://mixomicsteam.github.io/mixOmics-Vignette/id_05.html
#### sPLS-DA, using reduced data, TOP 15 variables
MyResult.splsda.mRNA <- splsda(X$mRNA, Y, keepX = c(15,15)) # 1 Run the method
plotIndiv(MyResult.splsda.mRNA) # 2 Plot the samples
```
<p style="text-align: center;">**FIGURE: mRNA sparse PLS-DA:** comp 1 - 2, supervised analysis using the only the most influential variables, here TOP 15.</p>
<br>
<br>
```{r}
plotVar(MyResult.splsda.mRNA) # 3 Plot the variables
```
<p style="text-align: center;">**FIGURE: mRNA contributing variables to sparse PLS-DA:** comp 1 - 2, supervised analysis using the only the most influential variables, here TOP 15.</p>
<br>
<br>
```{r}
selectVar(MyResult.splsda.mRNA, comp = 1)$value # Selected variables on comp 1
plotLoadings(MyResult.splsda.mRNA, comp = 1, method = 'mean', contrib = 'max')
```
<p style="text-align: center;">**FIGURE: mRNA contributing variables to sparse PLS-DA:** comp 1.</p>
<br>
<br>
```{r}
selectVar(MyResult.splsda.mRNA, comp = 2)$value # Selected variables on comp 1
plotLoadings(MyResult.splsda.mRNA, comp = 2, method = 'mean', contrib = 'max')
```
<p style="text-align: center;">**FIGURE: mRNA contributing variables to sparse PLS-DA:** comp 2.</p>
<br>
<br>
```{r}
# DATA REDUCTION APPROACH.
#########
# Protein
#########
# sPLS-DA NEEDS TO BE TUNED AND NUMBERS OF COMPONENTS OPTIMISED. SKIPPED HERE DUE TO TIME CONSTRAINTS. SEE LINK BELOW FOR FURTHER INFORMATION:
#https://mixomicsteam.github.io/mixOmics-Vignette/id_05.html
#### sPLS-DA, using reduced data, TOP 15 variables
MyResult.splsda.protein <- splsda(X$protein, Y, keepX = c(15,15)) # 1 Run the method
plotIndiv(MyResult.splsda.protein) # 2 Plot the samples
```
<p style="text-align: center;">**FIGURE: Protein sparse PLS-DA:** comp 1 - 2, supervised analysis using the only the most influential variables, here TOP 15.</p>
<br>
<br>
```{r}
plotVar(MyResult.splsda.protein) # 3 Plot the variables
```
<p style="text-align: center;">**FIGURE: Protein contributing variables to sparse PLS-DA:** comp 1 - 2, supervised analysis using the only the most influential variables, here TOP 15.</p>
<br>
<br>
```{r}
selectVar(MyResult.splsda.protein, comp = 1)$value # Selected variables on comp 1
plotLoadings(MyResult.splsda.protein, comp = 1, method = 'mean', contrib = 'max')
```
<p style="text-align: center;">**FIGURE: Protein contributing variables to sparse PLS-DA:** comp 1.</p>
<br>
<br>
```{r}
selectVar(MyResult.splsda.protein, comp = 2)$value # Selected variables on comp 1
plotLoadings(MyResult.splsda.protein, comp = 2, method = 'mean', contrib = 'max')
```
<p style="text-align: center;">**FIGURE: Protein contributing variables to sparse PLS-DA:** comp 2.</p>
<br>
<br>
#### sPLS-DA: Conclusion
Data reduction seems beneficial using a sparse PLS-DA in order to separate groups and get a clear picture of the data and important variables. Lets try the integrated data analysis using all three data sets.
<br>
<br>
<br>
<!-- New page -->
\pagebreak
###############################################################
###############################################################
# Multiblock PLS-DA (DIABLO)
###############################################################
## Parameter choice
### Design matrix
```{r}
# HERE WE LOOK AT DESIGN MATRIX WITH 0.1.
# A full design with weights = 1 will favour the latter, but at the expense of classification accuracy, whereas a design with small weights will lead to a highly predictive signature.
# FOR A FULLY WEIGHTED DESIGN: use "matrix(1, ncol...", WHICH IS FOCUSSING ON EXTRACTING THE MOST CORRELATION BETWEEN DATA SETS
design <- matrix(0.1, ncol = length(X), nrow = length(X),
dimnames = list(names(X), names(X)))
diag(design) <- 0
design
## ---- results='hold'---------------------------------
# How much correlation between data sets?
pls.res1 <- pls(X$mRNA, X$protein, ncomp = 1)
cor(pls.res1$variates$X, pls.res1$variates$Y)
pls.res2 <- pls(X$mRNA, X$miRNA, ncomp = 1)
cor(pls.res2$variates$X, pls.res2$variates$Y)
pls.res3 <- pls(X$protein, X$miRNA, ncomp = 1)
cor(pls.res3$variates$X, pls.res3$variates$Y)
# Decent amount of correlation between data sets. The data sets taken in a pairwise manner are highly correlated, indicating that a design with weights could be chosen.
```
### Number of components
```{r}
## ----diablo-perf, message=FALSE, fig.cap='(ref:diablo-perf)'----
diablo.tcga <- block.plsda(X, Y, ncomp = 5, design = design)
set.seed(123) # For reproducibility, remove for your analyses
perf.diablo.tcga = perf(diablo.tcga, validation = 'Mfold', folds = 5, nrepeat = 5)
# The validation of the folds parameter was too high and had to be reduced.
# Plot of the error rates based on weighted vote
plot(perf.diablo.tcga)
```
<p style="text-align: center;">**FIGURE: Multi block PLS-DA, error rates:** based on weighted vote. Choosing the number of components. Error rate is minimum using how many dimensions? </p>
<br>
<br>
```{r}
## ----------------------------------------------------
perf.diablo.tcga$choice.ncomp$WeightedVote
## ----------------------------------------------------
ncomp <- perf.diablo.tcga$choice.ncomp$WeightedVote["Overall.BER", "centroids.dist"]
```
### Number of variables to select
```{r}
## ---- echo = FALSE, eval = TRUE, warning=FALSE-------
# chunk takes about 2 min to run
set.seed(123) # for reproducibility
test.keepX <- list(mRNA = c(5:9, seq(10, 25, 5)),
miRNA = c(5:9, seq(10, 20, 2)),
proteomics = c(seq(5, 25, 5)))
tune.diablo.tcga <- tune.block.splsda(X, Y, ncomp = 2,
test.keepX = test.keepX, design = design,
validation = 'Mfold', folds = 2, nrepeat = 1,
# use two CPUs for faster computation
BPPARAM = BiocParallel::SnowParam(workers = 2),
dist = "centroids.dist")
## ----------------------------------------------------
list.keepX <- tune.diablo.tcga$choice.keepX
list.keepX
```
## Final model
```{r}
## ---- message = TRUE---------------------------------
diablo.tcga <- block.splsda(X, Y, ncomp = ncomp,
keepX = list.keepX, design = design)
#diablo.tcga # Lists the different functions of interest related to that object
## ----------------------------------------------------
diablo.tcga$design
## ---- eval = FALSE-----------------------------------
## # mRNA variables selected on component 1
## selectVar(diablo.tcga, block = 'mRNA', comp = 1)
```
## Sample plots
### plotDiablo
```{r}
## variables selected on component 1
selectVar(diablo.tcga, block = 'miRNA', comp = 1)$miRNA$name
selectVar(diablo.tcga, block = 'mRNA', comp = 1)$mRNA$name
selectVar(diablo.tcga, block = 'protein', comp = 1)$protein$name
## ----plot-diablo, message=FALSE, fig.cap='(ref:plot-diablo)'----
plotDiablo(diablo.tcga, ncomp = 1)
```
<p style="text-align: center;">**FIGURE: Multi block PLS-DA, diagnostic plot:** component 1, 95% confidence intervals are plotted. Numbers indicate correlation coefficients between the first components from each data set.</p>
<br>
<br>
```{r}
## variables selected on component 1
selectVar(diablo.tcga, block = 'miRNA', comp = 2)$miRNA$name
selectVar(diablo.tcga, block = 'mRNA', comp = 2)$mRNA$name
selectVar(diablo.tcga, block = 'protein', comp = 2)$protein$name
## ----plot-diablo, message=FALSE, fig.cap='(ref:plot-diablo)'----
plotDiablo(diablo.tcga, ncomp = 2)
```
<p style="text-align: center;">**FIGURE: Multi block PLS-DA, diagnostic plot:** component 2, 95% confidence intervals are plotted. Numbers indicate correlation coefficients between the first components from each data set.</p>
<br>
<br>
```{r}
## ----diablo-plotindiv, message=FALSE, fig.cap='(ref:diablo-plotindiv)'----
plotIndiv(diablo.tcga, ind.names = FALSE, legend = TRUE,
title = 'TCGA, DIABLO comp 1 - 2')
```
<p style="text-align: center;">**FIGURE: Multi block PLS-DA, individual omes:** Check that extracted data sets can discriminate between samples: True.</p>
<br>
<br>
```{r}
plotIndiv(diablo.tcga, ind.names = FALSE, legend = TRUE, ellipse = TRUE, title = 'TCGA, DIABLO comp 1 - 2', block = 'average')
```
<p style="text-align: center;">**FIGURE: Multi block PLS-DA:** Main plot that includes all three data sets - with symbols.</p>
<br>
<br>
```{r}
plotIndiv(diablo.tcga, ind.names = TRUE, legend = TRUE,
title = 'TCGA, DIABLO comp 1 - 2', block = 'average')
```
<p style="text-align: center;">**FIGURE: Multi block PLS-DA:** Main plot that includes all three data sets - with individual sample names.</p>
<br>
<br>
### plotArrow
```{r}
## ----diablo-plotarrow, message=FALSE, fig.cap='(ref:diablo-plotarrow)'----
plotArrow(diablo.tcga, ind.names = FALSE, legend = TRUE,
title = 'TCGA, DIABLO comp 1 - 2')
```
<p style="text-align: center;">**FIGURE: arrow plot for Multi block PLS-DA:** Shows agreement between the three data sets. Some samples have a bit of variability between data sets.</p>
<br>
<br>
### plotVar
```{r}
## ----diablo-plotvar, message=FALSE, fig.cap='(ref:diablo-plotvar)'----
plotVar(diablo.tcga, var.names = FALSE, style = 'graphics', legend = TRUE,
pch = c(16, 17, 15), cex = c(2,2,2),
col = c('darkorchid', 'brown1', 'lightgreen'),
title = 'TCGA, DIABLO comp 1 - 2')
```
<p style="text-align: center;">**FIGURE: circle plot for Multi block PLS-DA:** Shows correlation between variables.</p>
<br>
<br>
```{r}
## ----diablo-plotvar, message=FALSE, fig.cap='(ref:diablo-plotvar)'-----------
plotVar(diablo.tcga, var.names = TRUE, style = 'graphics', legend = TRUE, pch = c(16, 17, 15), cex = c(1,1,1),
col = c('darkorchid', 'brown1', 'lightgreen'),
title = 'TCGA, DIABLO comp 1 - 2')
```
<p style="text-align: center;">**FIGURE: circle plot for Multi block PLS-DA:** Shows correlation between variables - and names, which are overlapping unfortunately.</p>
<br>
<br>
### circosPlot
```{r}
## ----diablo-circos, message=FALSE, fig.cap='(ref:diablo-circos)'----
circosPlot(diablo.tcga, cutoff = 0.7, line = TRUE,
color.cor = c("chocolate3","grey20"), size.labels = 1.5)
```
<p style="text-align: center;">**FIGURE: circos plot for Multi block PLS-DA:** Plot represents the correlations between variables of different types, represented on the side quadrants..</p>
<br>
<br>
### cimDiablo
```{r, eval=FALSE}
## ----diablo-cim, message=FALSE, fig.width=10, fig.height=8, fig.cap='(ref:diablo-cim)'----
# FIGURE CAN BE OUT OF BONDS, MARGINS NEED TO BE ADJUSTED..
cimDiablo(diablo.tcga, color.blocks = c('darkorchid', 'brown1', 'lightgreen'),
comp = 1, margin=c(8,20), legend.position = "right")
```
```{r}
# USE THIS CODE INSTEAD TO EXPORT HEATMAP
time<-format(Sys.time(),"%d-%m-%Y")
Title <- paste("Clustered Image Map for Multi block PLS-DA")
FileName <- paste(Title,time,".jpg")
jpeg(file=FileName, width = 2280, height = 1280, res = 210)
#
cimDiablo(diablo.tcga, color.blocks = c('darkorchid', 'brown1', 'lightgreen'), comp = 1, margin=c(8,20), legend.position = "right")
#
dev.off()
```
<p style="text-align: center;">**FIGURE: Clustered Image Map (CIM) for Multi block PLS-DA:** Shows correlation between variables - and names.</p>
<br>
<br>
### plotLoadings
```{r}
## ----diablo-loading, message=FALSE, fig.cap='(ref:diablo-loading)'----
plotLoadings(diablo.tcga, comp = 1, contrib = 'max', method = 'median')
```
<p style="text-align: center;">**FIGURE: SYMBIONT contributing variables to sparse PLS-DA:** comp 1.</p>
<br>
<br>
```{r}
## ----diablo-loading, message=FALSE, fig.cap='(ref:diablo-loading)'----
plotLoadings(diablo.tcga, comp = 2, contrib = 'max', method = 'median')
```
<p style="text-align: center;">**FIGURE: SYMBIONT contributing variables to sparse PLS-DA:** comp 2.</p>
<br>
<br>
```{r}
## variables selected for block LIPIDS on component 1 & 2
selectVar(diablo.tcga, block = 'miRNA', comp = 1)$miRNA$value
selectVar(diablo.tcga, block = 'miRNA', comp = 2)$miRNA$value
## variables selected for block METABOLITES on component 1 & 2
selectVar(diablo.tcga, block = 'mRNA', comp = 1)$metabolites$value
selectVar(diablo.tcga, block = 'mRNA', comp = 2)$metabolites$value
## variables selected for block PROTEOME on component 1 & 2
selectVar(diablo.tcga, block = 'protein', comp = 1)$protein$value
selectVar(diablo.tcga, block = 'protein', comp = 2)$protein$value
```
```{r}
## --------------------------------
# Performance with Majority vote
perf.diablo.tcga$MajorityVote.error.rate
## --------------------------------
# Performance with Weighted vote
perf.diablo.tcga$WeightedVote.error.rate
```
<br>
<br>
## Model performance and prediction
```{r}
# NOT COVERED HERE
```
# WORKING WITH OWN DATA
```{r OwnData, eval=FALSE}
#getwd()
#setwd("PATH/TO/FOLDER")
# REQUIRED FORMAT:
# -> Your samples in rows, with unique IDs
# -> Your data in columns, with short and unique names
# Load from csv file
data_1 <- read.csv("PATH/TO/FOLDER/file1.csv", row.names = 1, header = TRUE, sep = '\t')
data_2 <- read.csv("PATH/TO/FOLDER/file1.csv", row.names = 1, header = TRUE, sep = '\t')
data_3 <- read.csv("PATH/TO/FOLDER/file1.csv", row.names = 1, header = TRUE, sep = '\t')
# Reformat data to matrix
data_1 <- as.matrix(data_1)
data_2 <- as.matrix(data_2)
data_3 <- as.matrix(data_3)
# Generate list of the data sets
X <- list(data_1 = data_1,
data_2 = data_2,
data_3 = data_3)
summary(X)
# Load Outcome file
data_meta <- read.csv("PATH/TO/FOLDER/MetaData.csv", header = TRUE, sep = '\t')
# Reformat Outcome file
Y_factor <- data_meta$YourFactor %>% as.factor()
summary(Y)
Y_scale <- data_meta$YourScale %>% as.numeric()
summary(Y_scale)
```
<br>
<br>
<!-- New page -->
\pagebreak
# SESSION INFO
```{r}
sessionInfo()
```