-
Notifications
You must be signed in to change notification settings - Fork 0
/
QC_report_DIANN_app.r
699 lines (640 loc) · 23.4 KB
/
QC_report_DIANN_app.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
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
## Dashboard QC report for DIANN search results
## Alison Felipe Alencar Chaves
## For detailed explanation, check out the GitHub repository: https://github.com/41ison/QC4DIANN
# Check whether you have the required packages installed, if not install them
if (!requireNamespace("devtools", quietly = TRUE)) {
install.packages("devtools")
}
if (!requireNamespace("BiocManager", quietly = TRUE)) {
install.packages("BiocManager")
}
if (!requireNamespace("shiny", quietly = TRUE)) {
install.packages("shiny")
}
if (!requireNamespace("shinydashboard", quietly = TRUE)) {
install.packages("shinydashboard")
}
if (!requireNamespace("diann", quietly = TRUE)) {
devtools::install_github("https://github.com/vdemichev/diann-rpackage")
}
if (!requireNamespace("tidyverse", quietly = TRUE)) {
install.packages("tidyverse")
}
if (!requireNamespace("ggpointdensity", quietly = TRUE)) {
install.packages("ggpointdensity")
}
if (!requireNamespace("limma", quietly = TRUE)) {
BiocManager::install("limma")
}
if (!requireNamespace("vegan", quietly = TRUE)) {
install.packages("vegan")
}
if (!requireNamespace("lsa", quietly = TRUE)) {
install.packages("lsa")
}
if (!requireNamespace("plotly", quietly = TRUE)) {
install.packages("plotly")
}
if (!requireNamespace("viridis", quietly = TRUE)) {
install.packages("viridis")
}
if (!requireNamespace("ggfortify", quietly = TRUE)) {
install.packages("ggfortify")
}
# Set the environment variable to enable zstd support.
Sys.setenv(LIBARROW_MINIMAL = "false", ARROW_WITH_ZSTD = "ON")
if (!requireNamespace("arrow", quietly = TRUE)) {
install.packages("arrow")
}
# Load required libraries
library(shiny)
library(shinydashboard)
library(diann)
library(arrow)
library(tidyverse)
library(ggpointdensity)
library(limma)
library(vegan)
library(lsa)
library(plotly)
library(viridis)
library(ggfortify)
# Increase the maximum file size to 1 GB
options(shiny.maxRequestSize = 1000 * 1024^2)
# set the general theme for the plots
theme_set(theme_bw())
theme_update(
text = element_text(color = "black"),
axis.text = element_text(color = "black"),
axis.title = element_text(color = "black", face = "bold"),
strip.text = element_text(face = "bold"),
legend.title = element_text(face = "bold", hjust = 0.5),
legend.title.position = "top"
)
# Define UI for application that reads a parquet file and generates a QC report dashboard
ui <- dashboardPage(
dashboardHeader(
title = "QC Reporting dashboard for DIANN search results", titleWidth = "400",
dropdownMenu(
type = "messages",
messageItem(
from = "Support",
message = "[email protected]",
icon = icon("envelope")
)
)
),
dashboardSidebar(
sidebarMenu(
menuItem("QuantUMS filters", tabName = "filters", icon = icon("filter")),
fileInput(inputId = "report", label = "Choose Parquet File", accept = ".parquet"),
sliderInput("PG.MaxLFQ.Quality", "PG MaxLFQ Quality score", min = 0, max = 1, value = 0.75, step = 0.05),
sliderInput("Empirical.Quality", "Empirical Quality score", min = 0, max = 1, value = 0, step = 0.05),
menuItem("Interactive viewer", tabName = "protein", icon = icon("equalizer", lib = "glyphicon")),
selectInput("xcol", "X Sample", choices = NULL),
selectInput("ycol", "Y Sample", choices = NULL),
downloadButton("download", "Download filtered matrix", class = "butt"),
tags$head(tags$style(".butt{background:grey;} .butt{color: #337ab7;}"))
)
),
dashboardBody(
tabItems(
tabItem(tabName = "filters",
fluidRow(
infoBoxOutput("info_box1", width = 12),
box(title = "Reconstruction of XIC", status = "primary", solidHeader = TRUE, plotOutput("plot1"), collapsible = TRUE),
box(title = "Density of ions", status = "primary", solidHeader = TRUE, plotOutput("plot2"), collapsible = TRUE),
box(title = "Retention time error", status = "primary", solidHeader = TRUE, plotOutput("plot3"), collapsible = TRUE),
box(title = "Charge state distribution", status = "primary", solidHeader = TRUE, plotOutput("plot4"), collapsible = TRUE),
box(title = "Peptide length", status = "primary", solidHeader = TRUE, plotOutput("plot5"), collapsible = TRUE),
box(title = "Peptides per sample", status = "primary", solidHeader = TRUE, plotOutput("plot6"), collapsible = TRUE),
box(title = "Proteins per sample", status = "primary", solidHeader = TRUE, plotOutput("plot7"), collapsible = TRUE),
box(title = "Sparsity profile", status = "primary", solidHeader = TRUE, plotOutput("plot8"), collapsible = TRUE),
box(title = "Missing vs median abundance", status = "primary", solidHeader = TRUE, plotOutput("plot9"), collapsible = TRUE),
box(title = "Abundance before and after MAD normalization", status = "primary", solidHeader = TRUE, plotOutput("plot10"), collapsible = TRUE),
box(title = "Missed cleavage sites", status = "primary", solidHeader = TRUE, plotOutput("plot11"), collapsible = TRUE),
box(title = "MS1 Profile Correlation", status = "primary", solidHeader = TRUE, plotOutput("plot12"), collapsible = TRUE),
box(title = "QuantUMS scores distribution", status = "primary", solidHeader = TRUE, plotOutput("plot13"), collapsible = TRUE),
box(title = "Gene quantity distribution", status = "primary", solidHeader = TRUE, plotOutput("plot14"), collapsible = TRUE)
)
),
tabItem(tabName = "protein",
fluidRow(
box(title = "Sample correlation - Non-normalized log2(Intensity)", status = "primary", height = 600, solidHeader = TRUE, plotlyOutput("Corr"), collapsible = FALSE),
tabBox(
title = "Similarity metrics", side = "right", height = 600,
tabPanel("Cosine similarity", plotOutput("cosine_similarity")),
tabPanel("Euclidean distance", plotOutput("euclidean_distance")),
tabPanel("Jaccard similarity", plotOutput("jaccard_similarity"))
),
box(title = "QuantUMS score distribution", status = "primary", height = 600, solidHeader = TRUE, plotlyOutput("QuantUMS_dist"), collapsible = FALSE),
box(title = "Principal Component Analysis", status = "primary", height = 600, solidHeader = TRUE, plotlyOutput("PCA"), collapsible = FALSE)
)
)
)
)
)
# Define server logic required to read the parquet file and generate the QC report
server <- function(input, output, session) {
# Reactive expression to read and pre-process the uploaded parquet file
data <- reactive({
req(input$report)
diann_report <- arrow::read_parquet(input$report$datapath) %>%
dplyr::filter(Lib.PG.Q.Value <= 0.01 & Lib.Q.Value <= 0.01 & PG.Q.Value <= 0.01) %>%
dplyr::mutate(File.Name = Run,
peptide_length = nchar(Stripped.Sequence)) %>%
dplyr::filter(.$PG.MaxLFQ.Quality >= input$PG.MaxLFQ.Quality & .$Empirical.Quality >= input$Empirical.Quality)
})
# Reactive expression to filter number of proteins based on the input filters
proteins <- reactive({
req(input$report)
diann_report <- arrow::read_parquet(input$report$datapath) %>%
dplyr::filter(Lib.PG.Q.Value <= 0.01 & Lib.Q.Value <= 0.01 & PG.Q.Value <= 0.01) %>%
dplyr::mutate(File.Name = Run) %>%
dplyr::filter(.$PG.MaxLFQ.Quality >= input$PG.MaxLFQ.Quality & .$Empirical.Quality >= input$Empirical.Quality) %>%
dplyr::group_by(Run) %>%
dplyr::summarise(
n_proteins = n_distinct(Protein.Ids)
)
})
# Reactive expression to filter number of peptides based on the input filters
peptides_per_run <- reactive({
req(input$report)
diann_report <- arrow::read_parquet(input$report$datapath) %>%
dplyr::filter(Lib.PG.Q.Value <= 0.01 & Lib.Q.Value <= 0.01 & PG.Q.Value <= 0.01) %>%
dplyr::mutate(File.Name = Run) %>%
dplyr::filter(.$PG.MaxLFQ.Quality >= input$PG.MaxLFQ.Quality & .$Empirical.Quality >= input$Empirical.Quality) %>%
dplyr::group_by(Run) %>%
dplyr::summarise(
n_peptides = n_distinct(Stripped.Sequence)
)
})
# Reactive expression to filter matrix of protein abundance based on the input filters
unique_genes <- reactive({
req(data())
diann::diann_matrix(data(),
id.header = "Protein.Ids",
quantity.header = "Genes.MaxLFQ.Unique",
proteotypic.only = FALSE,
pg.q = .01
)
})
# Observe the uploaded file and update selectInput choices
observe({
req(unique_genes())
colnames <- colnames(unique_genes())
updateSelectInput(session, "xcol", choices = colnames)
updateSelectInput(session, "ycol", choices = colnames)
})
# Reactive expression to combine the raw and MAD normalized data
combined_data <- reactive({
req(unique_genes())
unique_genes() %>%
log2() %>%
as.data.frame() %>%
gather(key = "Sample", value = "Intensity") %>%
dplyr::mutate(norm = "Raw matrix") %>%
bind_rows(
unique_genes() %>%
log2() %>%
limma::normalizeBetweenArrays(method = "scale") %>%
as.data.frame() %>%
gather(key = "Sample", value = "Intensity") %>%
dplyr::mutate(norm = "MAD normalised")
) %>%
dplyr::mutate(norm = factor(norm, levels = c("Raw matrix", "MAD normalised")))
})
QuantUMS_scores <- reactive({
req(input$report)
diann_report <- arrow::read_parquet(input$report$datapath) %>%
dplyr::filter(Lib.PG.Q.Value <= 0.01 & Lib.Q.Value <= 0.01 & PG.Q.Value <= 0.01) %>%
dplyr::mutate(File.Name = Run) %>%
dplyr::select(Run, Precursor.Id, PG.MaxLFQ.Quality, Empirical.Quality, Quantity.Quality) %>%
pivot_longer(-c(Run, Precursor.Id),
names_to = "Filter",
values_to = "Score")
})
gene_quantity <- reactive({
req(data())
data() %>%
dplyr::select(Run, PG.MaxLFQ, Genes.MaxLFQ, Genes.MaxLFQ.Unique) %>%
pivot_longer(-Run,
names_to = "protein_metrics",
values_to = "quantity")
})
missing_vs_mean <- reactive({
unique_genes() %>%
log2() %>%
as.data.frame() %>%
gather(key = "Sample", value = "Intensity") %>%
dplyr::mutate(missing = is.na(Intensity)) %>%
dplyr::group_by(Sample) %>%
dplyr::summarise(
missing = mean(missing) * 100,
median_intensity = median(Intensity, na.rm = TRUE)
) %>%
dplyr::mutate(norm = "Non normalised") %>%
bind_rows(
unique_genes() %>%
log2() %>%
limma::normalizeBetweenArrays(method = "scale") %>%
as.data.frame() %>%
gather(key = "Sample", value = "Intensity") %>%
dplyr::mutate(missing = is.na(Intensity)) %>%
dplyr::group_by(Sample) %>%
dplyr::summarise(
missing = mean(missing) * 100,
median_intensity = median(Intensity, na.rm = TRUE)
) %>%
dplyr::mutate(norm = "MAD normalised")
) %>%
dplyr::mutate(norm = factor(norm, levels = c("Non normalised", "MAD normalised")))
})
output$info_box1 <- renderInfoBox({
infoBox(title = "The filters Lib.PG.Q.Value ≤ 0.01, Lib.Q.Value ≤ 0.01 and PG.Q.Value ≤ 0.01 are active.",
paste("PG MaxLFQ Quality score ≥ ", input$PG.MaxLFQ.Quality),
paste("Empirical Quality score ≥ ", input$Empirical.Quality),
icon = icon("filter"),
color = "black"
)
})
MS_corr <- reactive({
req(input$report)
MS_correlation <- arrow::read_parquet(input$report$datapath) %>%
dplyr::filter(Lib.PG.Q.Value <= 0.01 & Lib.Q.Value <= 0.01 & PG.Q.Value <= 0.01) %>%
dplyr::mutate(File.Name = Run)
})
PCA_label <- reactive({
unique_genes() %>%
log2() %>%
na.omit() %>%
t() %>%
as.data.frame() %>%
rownames_to_column(var = "Sample")
})
pca_data <- reactive({
unique_genes() %>%
log2() %>%
na.omit() %>%
t() %>%
prcomp(., scale. = TRUE) %>%
autoplot(data = PCA_label(), colour = "Sample", label = TRUE)
})
# download the filtered matrix
output$download <- downloadHandler(
filename = function() {
paste0(input$report, ".tsv")
},
content = function(file) {
readr::write_tsv(as.data.frame(unique_genes()) %>% rownames_to_column("protein_id"), file)
}
)
# calculate the cosine similarity in the matrix and plot the heatmap
output$cosine_similarity <- renderPlot({
unique_genes() %>%
log2() %>%
na.omit() %>%
lsa::cosine() %>%
as.data.frame() %>%
rownames_to_column(var = "Sample") %>%
pivot_longer(-Sample, names_to = "Match", values_to = "value") %>%
dplyr::mutate(Similarity = "Cosine similarity") %>%
ggplot() +
geom_tile(aes(x = Sample, y = Match, fill = value)) +
viridis::scale_fill_viridis(option = "E") +
theme(text = element_text(size = 15),
axis.text.x = element_text(angle = 90,
hjust = 1, vjust = 0.5),
axis.text.y = element_text(angle = 0,
hjust = 1, vjust = 0.5),
legend.position = "bottom",
legend.key.width = unit(2.5, "cm")) +
labs(x = NULL,
y = NULL,
fill = "Cosine similarity")
})
# calculate the euclidean distance in the matrix and plot the heatmap
output$euclidean_distance <- renderPlot({
unique_genes() %>%
log2() %>%
t() %>%
dist(method = "euclidean") %>%
as.matrix() %>%
as.data.frame() %>%
rownames_to_column(var = "Sample") %>%
pivot_longer(-Sample, names_to = "Match", values_to = "value") %>%
dplyr::mutate(Similarity = "Euclidean distance") %>%
ggplot() +
geom_tile(aes(x = Sample, y = Match, fill = value)) +
viridis::scale_fill_viridis(option = "E") +
theme(text = element_text(size = 15),
axis.text.x = element_text(angle = 90,
hjust = 1, vjust = 0.5),
axis.text.y = element_text(angle = 0,
hjust = 1, vjust = 0.5),
legend.position = "bottom",
legend.key.width = unit(2.5, "cm")) +
labs(x = NULL,
y = NULL,
fill = "Euclidean distance")
})
# calculate the Jaccard similarity in the matrix and plot the heatmap
output$jaccard_similarity <- renderPlot({
unique_genes() %>%
log2() %>%
t() %>%
vegan::vegdist(method = "jaccard", na.rm = TRUE) %>%
as.matrix() %>%
as.data.frame(as.table(.)) %>%
dplyr::mutate(Sample = colnames(.)) %>%
pivot_longer(-Sample, names_to = "Match", values_to = "value") %>%
dplyr::mutate(Similarity = "Jaccard similarity") %>%
ggplot() +
geom_tile(aes(x = Sample, y = Match, fill = value)) +
viridis::scale_fill_viridis(option = "E") +
theme(text = element_text(size = 15),
axis.text.x = element_text(angle = 90,
hjust = 1, vjust = 0.5),
axis.text.y = element_text(angle = 0,
hjust = 1, vjust = 0.5),
legend.position = "bottom",
legend.key.width = unit(2.5, "cm")) +
labs(x = NULL,
y = NULL,
fill = "Jaccard similarity")
})
# Render plots
output$plot1 <- renderPlot({
data() %>%
as.data.frame() %>%
ggplot(aes(x = RT, y = Precursor.Quantity)) +
geom_line(color = "darkblue", alpha = 0.7, show.legend = FALSE) +
labs(
x = "Retention time (min)",
y = "Precursor quantity",
color = NULL
) +
facet_wrap(~Run, scales = "free_y")
})
output$plot2 <- renderPlot({
data() %>%
as.data.frame() %>%
ggplot(aes(x = RT, y = Precursor.Mz)) +
ggpointdensity::geom_pointdensity(size = 0.25) +
viridis::scale_color_viridis(option = "plasma") +
labs(
x = "Retention time (min)",
y = " Scan range (m/z)",
color = NULL
) +
theme(legend.position = "bottom",
legend.key.width = unit(1.5, "cm")) +
facet_wrap(~Run)
})
output$plot3 <- renderPlot({
data() %>%
as.data.frame() %>%
ggplot(aes(x = Precursor.Mz,
y = RT - Predicted.RT)) +
ggpointdensity::geom_pointdensity(size = 0.25) +
viridis::scale_color_viridis(option = "plasma") +
geom_hline(yintercept = c(1,0,-1), linetype = "dashed", color = "black") +
labs(
x = "Precursor m/z",
y = "RT - Predicted RT (min)",
color = NULL
) +
theme(legend.key.width = unit(2, "cm"),
legend.position = "bottom") +
facet_wrap(~Run)
})
output$plot4 <- renderPlot({
data() %>%
as.data.frame() %>%
ggplot(aes(x = Precursor.Charge)) +
geom_density(alpha = 0.7,
stat = "density", fill = "darkblue",
show.legend = FALSE) +
labs(
x = "Precursor charge",
y = "Density",
fill = NULL
) +
facet_wrap(~Run)
})
output$plot5 <- renderPlot({
data() %>%
ggplot(aes(x = peptide_length)) +
geom_histogram(alpha = 0.7,
stat = "bin",
binwidth = 1,
show.legend = FALSE,
fill = "tomato") +
labs(
x = "Peptide length (a.a.)",
y = "Count",
fill = NULL
) +
facet_wrap(~Run, scales = "free")
})
output$plot6 <- renderPlot({
peptides_per_run() %>%
as.data.frame() %>%
ggplot(aes(y = Run, x = n_peptides)) +
geom_bar(stat = "identity", position = "dodge", alpha = 0.7,
fill = "darkblue", show.legend = FALSE) +
geom_text(aes(label = n_peptides),
color = "white", size = 5,
hjust = 1, nudge_x = -0.5
) +
labs(y = NULL,
x = "Number of peptides",
fill = NULL) +
theme(
axis.text.x = element_text(angle = 90,
vjust = 0.5,
hjust = 1)
)
})
output$plot7 <- renderPlot({
proteins() %>%
as.data.frame() %>%
ggplot(aes(y = Run, x = n_proteins)) +
geom_bar(stat = "identity", position = "dodge", alpha = 0.7,
fill = "darkblue", show.legend = FALSE) +
geom_text(aes(label = n_proteins),
color = "white", size = 5,
hjust = 1, nudge_x = -0.5
) +
labs(y = NULL,
x = "Number of proteins",
fill = NULL) +
theme(
axis.text.x = element_text(angle = 90,
vjust = 0.5,
hjust = 1)
)
})
output$plot8 <- renderPlot({
unique_genes() %>%
as.data.frame() %>%
gather(key = "Sample", value = "Intensity") %>%
dplyr::mutate(missing = is.na(Intensity)) %>%
dplyr::group_by(Sample) %>%
dplyr::summarise(
missing = mean(missing) * 100
) %>%
ggplot(aes(x = Sample, y = missing)) +
geom_col(fill = "darkblue", alpha = 0.7, show.legend = FALSE) +
geom_text(aes(label = round(missing, 2)),
vjust = -0.25, size = 3) +
labs(x = NULL,
y = "Proportion of missing values per sample (%)",
fill = NULL) +
theme(
axis.text.x = element_text(angle = 90,
hjust = 1, vjust = 0.5)
)
})
output$plot9 <- renderPlot({
missing_vs_mean() %>%
ggplot(aes(x = missing, y = median_intensity)) +
geom_point(alpha = 0.7, size = 3) +
geom_smooth(method = "lm", se = FALSE,
color = "darkblue") +
labs(x = "Proportion of missing values (%)",
y = "Mean log2(abundance)",
color = NULL) +
facet_wrap(~norm)
})
output$plot10 <- renderPlot({
combined_data() %>%
as.data.frame() %>%
ggplot(aes(
x = Sample,
y = Intensity,
fill = norm
)) +
scale_fill_manual(values = c("Raw matrix" = "tomato",
"MAD normalised" = "darkblue")) +
geom_boxplot(alpha = 0.7) +
theme(
axis.text.x = element_text(angle = 90,
hjust = 1, vjust = 0.5),
legend.position = "none"
) +
labs(x = NULL,
y = "log2(Intensity)",
fill = NULL) +
facet_wrap(~norm)
})
output$plot11 <- renderPlot({
data() %>%
as.data.frame() %>%
dplyr::mutate(specificity = case_when(
str_detect(Stripped.Sequence, "K$|R$") ~ "Trypsin C-termini",
str_detect(Stripped.Sequence, "E$|D$") ~ "GluC C-termini",
TRUE ~ "Missed C-termini")
) %>%
group_by(Run, specificity) %>%
dplyr::summarise(
peptides = n()
) %>%
ggplot(aes(y = Run, x = peptides,
fill = specificity)) +
geom_col(alpha = 0.7,
position = "stack") +
scale_fill_manual(values = c("Trypsin C-termini" = "tomato",
"GluC C-termini" = "darkblue",
"Missed C-termini" = "darkgreen")) +
labs(
y = NULL,
x = "Count",
fill = "Specificity"
) +
theme(legend.position = "top",
axis.text.x = element_text(hjust = 0.5, vjust = 1))
})
output$plot12 <- renderPlot({
MS_corr() %>%
as.data.frame() %>%
dplyr::mutate(EQScore_cutoff = case_when(
.$Empirical.Quality >= input$Empirical.Quality ~ "Above threshold",
TRUE ~ "Below threshold")
) %>%
ggplot(aes(x = Ms1.Profile.Corr, fill = EQScore_cutoff)) +
geom_density(alpha = 0.7) +
scale_fill_manual(values = c("tomato", "darkblue")) +
labs(x = "MS1 Profile Correlation",
y = "Density",
fill = "Correlation between MS1 and MS2 chromatograms") +
theme(legend.position = "top",
axis.text.x = element_text(angle = 90)) +
facet_wrap(~Run)
})
output$plot13 <- renderPlot({
QuantUMS_scores() %>%
as.data.frame() %>%
ggplot() +
geom_density(aes(x = Score, fill = Filter), alpha = 0.7) +
scale_fill_manual(values = c("PG.MaxLFQ.Quality" = "tomato",
"Empirical.Quality" = "darkblue",
"Quantity.Quality" = "darkgreen")) +
labs(x = "Score",
y = "Density",
fill = NULL) +
theme(legend.position = "bottom",
axis.text.x = element_text(angle = 90)) +
facet_wrap(~Run)
})
output$plot14 <- renderPlot({
gene_quantity() %>%
as.data.frame() %>%
ggplot() +
geom_density(aes(x = log2(quantity), fill = protein_metrics), alpha = 0.7) +
scale_fill_manual(values = c("Genes.MaxLFQ" = "tomato",
"Genes.MaxLFQ.Unique" = "darkblue",
"PG.MaxLFQ" = "darkgreen")) +
labs(x = "Protein Quantity",
y = "Density",
fill = NULL) +
theme(legend.position = "bottom",
axis.text.x = element_text(angle = 90)) +
facet_wrap(~Run)
})
output$QuantUMS_dist <- renderPlotly({
data() %>%
plot_ly(x = ~PG.MaxLFQ.Quality,
y = ~Quantity.Quality,
z = ~Empirical.Quality,
color = ~Run,
alpha = 0.6,
colors = viridis::viridis(256),
type = "scatter3d",
mode = "markers") %>%
layout(scene = list(
xaxis = list(title = "PG MaxLFQ Quality"),
yaxis = list(title = "Quantity Quality"),
zaxis = list(title = "Empirical Quality")
)) %>%
subplot()
})
# plot the sample correlation using the columns from the selectInput
output$Corr <- renderPlotly({
unique_genes() %>%
log2() %>%
as.data.frame() %>%
ggplot(aes(x = !!sym(input$xcol), y = !!sym(input$ycol))) +
geom_point(alpha = 0.7, show.legend = FALSE) +
geom_smooth(method = "lm", se = FALSE,
color = "darkblue") +
labs(x = paste0("Log2(", input$xcol, ")"),
y = paste0("Log2(", input$ycol, ")"))
})
# plot the PCA
output$PCA <- renderPlotly({
pca_data()
})
}
# Run the application
shinyApp(ui = ui, server = server)