-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.R
655 lines (583 loc) · 44.8 KB
/
ui.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
## LIBRARIES:-
library(shiny)
library(dplyr)
library(reshape2)
library(ggplot2)
library(RColorBrewer)
library(ecodist)
library(tidyr)
library(forcats)
library(vegan)
library(ape)
library(ade4)
library(gtools)
library(SRS)
library(vroom)
library(reactable)
library(shinycssloaders)
library(shinydashboard)
library(stringi)
library(shinyWidgets)
library(fresh)
library(htmltools)
library(tidytext)
library(ggh4x)
# library(msa); removed because no reason to exist right now
library(shinyjs)
library(patchwork)
library(viridis)
library(GUniFrac)
## Set working directory. This should be the directory where app.R is stored.
#setwd("C:/Users/alexu/OneDrive/UW/Grad Studies/R workspace/R Scripts//ALEXIOME/ALEXIOME/")
#gc()
#### Website text ####
# This section contains the website text, integrated into the individual panels on the website. I thought it easier to define them here,
# rather than having to edit them within the code.
# main page
Rversion = R.Version()$version.string
bloop_welcome = "
AOViz contains several R-based visualization scripts wrapped within an R Shiny UI, allowing users to quickly explore their short-read amplicon data.
Figures can be customized using a provided metadata file and exported as PDFs.
"
bloop_req = "AOViz requires an ASV/OTU table produced from sequence data processing pipelines (e.g., QIIME2) using the QIIME2/SILVA taxonomy formatting.
Any phylogenetic marker gene can be used (e.g., cpn60, amoA) so long as the taxonomy formatting is identical. All uploaded files must be in txt format. Your ASV/OTU table should be formatted as detailed in the example picture below:"
# asv_example
# meta_example
## This is some custom HTML settings for colour, background, textsize, and whatnot:
ui <- navbarPage(id = "navbarID",
setBackgroundColor(color = "#E7E7E7"),
# setBackgroundColor(color = "#E7E7E7"),
tags$style(HTML("
.navbar-default .navbar-brand {
color:white;
font-size:28px
}
.navbar-default .navbar-brand:hover {
color:white;
}
.navbar {
background-color:#3C8DBC;
}
.navbar-default .navbar-nav > li > a {
color:white;
font-size:22px;
black
}
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:focus,
.navbar-default .navbar-nav > .active > a:hover {
color:black;
background-color:white;
}
.navbar-default .navbar-nav > li > a:hover {
color:black;
background-color:white;
text-decoration
}
.well {
background:white;
}
body {
background-color:white;
}
#meta_table {
zoom: 0.80;
}
#main_table {
zoom: 0.80;
}
#contam_table {
zoom: 0.80;
}
#proc_main {
zoom: 0.80;
}
#proc_new_data {
zoom: 0.80;
}
#proc_main_alt {
zoom: 0.80;
}
#read_table_out {
zoom: 0.80;
}
#bar_table_out {
zoom: 0.80;
}
#bubble_table_out {
zoom: 0.80;
}
")),
title = "AOViz v2.4",
#title = img(src="ALEXIOME_logo.png", height = "100%", width = "100%"),
#### Main Page ####
tabPanel("WELCOME",
sidebarLayout(
sidebarPanel(Rversion,
p("Leave any comments or suggestions on", a("the git page", href = "https://github.com/AlexUmbach/AOViz")),
img(src="bloop_logo.svg", height = "100%", width = "100%"),
#h1("WOW!"),
#img(src="eric-head.gi", height = "100%", width = "100%"),
style = "height: 500px; position:relative; border-color:#000000",
width = 3
),
mainPanel(width = 9,
fluidRow(
box(h1("Welcome to AOViz!"),
p(bloop_welcome),
p(h1("What kind of data are required?")),
p(bloop_req),
width = 12,
#style = "background-color:#FFFFFF; border-color:#000000; border-style: solid; margin-left:0px; margin-right:30px; padding: 10px",
style = "background-color:#FFFFFF; border-color:#ffffff; border-style: solid; border-width: 1.5px; margin-left:0px; margin-right:30px; padding: 10px",
),
),
box(
p("This is how your ASV/OTU table should be formatted. The column",strong("Feature.ID"),"is required and must contain unique identifiers for each row."),
p("ASV/OTU tables can also be in a collapsed format, where the 'Feature.ID' column contains taxonomy. The",strong("Consensus.Lineage"),"and",strong("ReprSequence"),"headers must be as shown. The sample column names should not contain special characters (e.g., *, -, (), [], /). If you're encountering errors, try checking this first."),
img(src="ASV_example.png",height = "60%", width = "60%"),
width = 13,
style = "background-color:#FFFFFF; border-color:#ffffff; border-style: solid; border-width: 1.5px; margin-left:0px; margin-right:30px; padding: 10px",
),
br(),
box(
p("Your metadata file should appear as below. There is a single required feature of your metadata table: a column labelled",strong("SampleName."),
"The 'SampleName' column should include a list of sample names that are",strong("identical"), "to the samples in your ASV/OTU table. Any additional columns containing sample information (e.g., temperature, location, group) can be included and will be incorporated as options during analyses."),
img(src="meta_example.png",height = "50%", width = "50%"),
width = 13,
style = "background-color:#FFFFFF; border-color:#ffffff; border-style: solid; border-width: 1.5px; margin-left:0px; margin-right:30px; padding: 10px",
),
br(),
box(
p("If interested in analyzing taxonomically collapsed table (such as a genus-collapsed), you need only rename the taxonomy column to 'Feature.ID', as below:"),
img(src="collapsed_Example.png",height = "50%", width = "50%"),
width = 13,
style = "background-color:#FFFFFF; border-color:#ffffff; border-style: solid; border-width: 1.5px; margin-left:0px; margin-right:30px; padding: 10px",
),
box(
p(h1("Column name blacklist")),
p("AOViz requires priority when assigning column names. Because of this, you",strong("must not use"),"the following names in your metadata:"),
p("TaxaName"),
p("input"),
p("Feature ID (or variants"),
p("rowID (or variants)"),
p("Taxonomy (or variants)"),
width = 13,
style = "background-color:#FFFFFF; border-color:#ffffff; border-style: solid; border-width: 1.5px; margin-left:0px; margin-right:30px; padding: 10px",
)
)
)
),
#### Upload Data and review ####
tabPanel("Data upload",
sidebarLayout(
sidebarPanel(h5("Please upload your data"),
# actionButton("test_data", "Use test data"),
fileInput("main_file","Primary ASV table"),
checkboxInput("is_main_collapsed","Is this a collapsed table?",value = FALSE),
#radioButtons("main_filetype","Please select your filetype",c("tsv","csv","txt")),
fileInput("meta_file","Metadata table"),
#radioButtons("meta_filetype","Please select your filetype",c("tsv","csv","txt")),
fileInput("contam_file","ASV contaminant list"),
#radioButtons("contam_filetype","Please select your filetype",c("tsv","csv","txt"))
width = 3,
style = "overflow-y:scroll; max-height: 850px; position:relative; border-color:#000000"
),
mainPanel(width = 9,
fluidRow(
box(h3("Upload your data"),
p("This is where you can upload your ASV tables, metadata table, and",em("optional"),"contaminant list. Once you have uploaded your ASV table, indicate whether it is a true ASV table or a collapsed taxon table (e.g., genus-level). If you encounter errors, please check your tables to ensure proper column names and formatting."
),
width = 12,
),
style = "background-color:#FFFFFF; border-color:#ffffff; border-style: solid; border-width: 1.5px; margin-left:0px; margin-right:30px; padding: 10px",
width = 6,
),
textOutput("maintext"),
dataTableOutput("main_table"),
textOutput("metatext"),
dataTableOutput("meta_table"),
textOutput("contamtext"),
dataTableOutput("contam_table"),
style = "overflow-y:scroll; max-height: 850px; position:relative;"
)
)
),
#### Processed Data #####
tabPanel("Processed data",
sidebarLayout(
sidebarPanel(h4("Select preferences"),
radioButtons("remove_prefix","Do you want to remove prefixes?",c("Yes","No"),selected = "Yes", inline = TRUE),
radioButtons("truncate_taxa","Do you want to truncate taxa to the most resolved taxon?",c("Yes","No"), selected = "Yes",inline = TRUE),
radioButtons("contam_filter","Do you want to remove or analyze contaminants?", c("Remove","Analyze","No action"),selected = "No action",inline = TRUE),
checkboxInput("remove_low_reads","Do you want to remove low abundance reads?", value = FALSE),
conditionalPanel(
condition = "input.remove_low_reads == true",
numericInput("read_threshold","Set a threshold",value = 100),
),
width = 3,
style = "overflow-y:scroll; max-height: 900px; position:relative;border-color:#000000"
),
mainPanel(width = 9,
fluidRow(
box(h3("Processed data review"),
p("This page is where you can review your processed data to ensure that everything is looking as it should. The table is interactable and searchable and should allow you to cross reference samples and metadata with your original tables if you have any concerns
about whether the data has been processed properly."),
width = 12)),
br(),
textOutput("proc_new_text"),
dataTableOutput("proc_main_alt"),
textOutput("proc_maintext",),
dataTableOutput("proc_main"),
textOutput("proc_alttext"),
dataTableOutput("proc_new_data"),
style = "overflow-y:scroll; max-height: 800px; position:relative;"
)
)
),
#### Total read plot ####
tabPanel("Read plot", value = "readtab",
sidebarLayout(
sidebarPanel(h4("Select preferences"),
radioButtons("box_select","What kind of plot?",choices = c("Box","Bar"),selected = "Bar", inline = TRUE),
hr(style = "border-width: 3px; border-color:#A9A9A9"),
numericInput("read_yaxis_limit","Change the y-axis limit",value = 100000),
selectInput("read_sortby_axis","How do you want to group your data?",choices = NULL),
hr(style = "border-width: 3px; border-color:#A9A9A9"),
#selectInput("read_colour","How do you want to colour your data?",choices = "Updating"),
#selectInput("read_meta_group","Select specific metadata group",choices = "Updating"),
#textInput("read_meta_key","Provide a keyword"),
#textInput("read_xaxis","Provide an x-axis label",value = "Samples"),
#textInput("read_yaxis","Provide a y-axis label",value = "Total reads following DADA2"),
#textInput("read_legend_label","Provide a legend title"),
hr(style = "border-width: 3px; border-color:#A9A9A9"),
radioButtons("read_panel","Do you want panel borders?",c("Yes","No"),selected = "Yes", inline = TRUE),
sliderInput("read_panel_spacing","Modify panel spacing",min = 0,max = 20,step = 1,value = 0),
sliderInput("read_width","Change bar width",min=0, max=1, step = 0.1, value = 0.9),
# sliderInput("read_border_bold","Change border thickness",min=0, max=1, step = 0.1, value = 0.4),
# sliderInput("read_alpha","Change bar alpha",min=0, max=1, step = 0.1, value = 0.7),
#sliderInput("read_xaxis_space","Change x-axis spacing",min = 0, max = 0.5, step = 0.005, value = 0),
#sliderInput("read_yaxis_space","Change x-axis spacing",min = 0, max = 0.5, step = 0.005, value = 0),
width = 3,
style = "overflow-y:scroll; max-height: 850px; position:relative;border-color:#000000"
),
mainPanel("",
width = 9,
fluidRow(
box(h3("Sequence read plot"),
p("This is an ASV or sequence read plot. It summarizes your total read counts in your dataset, organized by sample name or chosen metadata category. The script uses base R functions to sum the columns for each sample in an ASV table and reports those totals as 'total reads'. Samples with read counts higher than the chosen y-axis limit will be removed from the dataset, so make sure you set an appropriate limit."),
width = 12)),
br(),
dataTableOutput("read_table_out") %>% withSpinner(type = 8, color.background = "white"),
fluidRow(
# box(
# numericInput("read_plotheight","Select height", value = 6),
# numericInput("read_plotwidth","Select width", value = 12),
# ),
box(
sliderInput("read_plot_out_w","Plot width",min = 0, max = 2000,step = 100,value = 600),
sliderInput("read_plot_out_h","Plot height",min = 0, max = 2000,step = 100,value = 400),
actionButton("read_start",label = "Start!"),
downloadButton("read_download","Save figure"),
downloadButton("read_table_download", "Download table"),
),
),
br(),
br(),
# plotOutput("read_plot"),
plotOutput("read_plot") %>% withSpinner(type = 1,color.background = "white",size = 3),
style = "overflow-y:scroll; max-height: 850px; position:relative;"
)
)
),
#### Taxa bar plot analysis ####
tabPanel("Taxonomy relative abundance",
sidebarLayout(
sidebarPanel(
numericInput("bar_cutoff","Select your cutoff",value = 10),
actionButton("bar_start",label = "Start!",width = 334),
hr(style = "border-width: 3px; border-color:#A9A9A9"),
# textInput("bar_plot_x",label = "Enter x-axis",value = "SampleName"),
# textInput("bar_plot_y",label = "Enter y-axis",value = "Percentage"),
selectInput("bar_sortby_xaxis", label = "How do you want to group your samples?",choice = "Updating"),
checkboxInput("bar_rename_check", "Do you want to relabel your samples with a SampleShort column?", FALSE),
selectInput("bar_taxon_level", label = "Colour by which level?", choice = c("Genus","Family","Order","Class","Phylum")),
textInput("taxon_subset","Filter for specific taxa (e.g., 'staph')",value = NA),
checkboxInput("bar_facet","Do you want a second facet?",value = FALSE),
conditionalPanel(
condition = "input.bar_facet == true",
selectInput("bar_second_facet","Choose the second ordering",choices = "Updating"),
),
#textInput("bar_plot_fill","Select bar plot fill",value = "TaxaName"),
#textInput("bar_xaxis","Provide a x-axis label","Samples"),
#textInput("bar_yaxis","Provide a y-axis label","Read proportions (%)"),
#textInput("bar_legend_label","Provide a legend title",""),
hr(style = "border-width: 3px; border-color:#A9A9A9"),
radioButtons("bar_panel_border","Do you want panel borders?",choices = c("Yes","No"),selected = "Yes", inline = TRUE),
sliderInput("bar_panel_spacing","Modify panel spacing",min = 0, max = 30, value = 0, step = 1),
# selectInput("bar_fill_col",label = "Select bar colour",choices = c("Set1","Set2","Set3","Paired"),selected = "Paired" ),
#sliderInput("bar_border_bold","Select border boldness",min = 0, max = 1, step = 0.1, value = 0.5),
#sliderInput("bar_width", "select bar width",min= 0,max= 1,step= 0.1,value= 1),
sliderInput("bar_alpha","Select your bar alpha",min= 0,max= 1,step= 0.1,value= 0.4),
#sliderInput("bar_leftright","Change your vertical border spacing",min = 0,max = 0.1,step = 0.005,value = 0.035),
#sliderInput("bar_topbottom","Change your horizontal border spacing",min = 0, max = 0.1, step = 0.005,value = 0.005),
width = 3,
style = "overflow-y:scroll; max-height: 850px; position:relative;border-color:#000000"
),
mainPanel(width = 9,
fluidRow(
box(h3("Taxonomy plot"),
p("This is a taxonomy bar plot. It represents the relative abundances of each taxon within and among samples. The 'cut-off' value represents the relative abundance required for the taxon to be represented by name within the plot. For example, if set to '20', only taxa that have relative abundances equal to or greater than 20%, in any sample, will be presented in the plot. All other taxa are lumped into the 'other' category."),
p("To create this barplot, the ASV table is first transformed into a proportion table and all taxa below the cut-off are removed. Each column is summed and substracted from 100, representing the total proportion of taxa not present at greater than the cut-off threshold (i.e., the 'other' category). These 'other' taxa are assigned the taxonomy identifer 'ZZOther' and then plotted."),
p("You may also filter your table for specific taxa at any taxonomy level (e.g., Staphylococcus, Pseudomonadota)."),
width = 12)),
dataTableOutput("bar_table_out") %>% withSpinner(type = 1,color.background = "white"),
fluidRow(
# box(
# numericInput("bar_plotheight","Select height",value = 6),
# numericInput("bar_plotwidth","Select width",value = 16),
# ),
box(
sliderInput("taxa_plot_out_w","Plot width",min = 0, max = 2000,step = 100,value = 600),
sliderInput("taxa_plot_out_h","Plot height",min = 0, max = 2000,step = 100,value = 400),
downloadButton("bar_download","Save figure"),
downloadButton("bar_table_download","Save table"),
width = 3
)
),
br(),
br(),
plotOutput("taxa_bar") %>% withSpinner(type = 1,color.background = "white",size = 3),
style = "overflow-y:scroll; max-height: 850px; position:relative;"
)
)
),
#### Bubble plot ####
tabPanel("Relative Abundance Bubble plot",
sidebarLayout(
sidebarPanel(
textInput("b1_ab_thresh","Relative abundace threshold (%)", value = 5),
actionButton("bubble_start",label = "Start!", width = 335),
hr(style = "border-width: 3px; border-color:#A9A9A9"),
radioButtons("b1_incl_percent","Do you want to include percent abundance numbers?",c("Yes","No"), selected = "Yes", inline = TRUE),
numericInput("b1_num_dec","Set the number of decimals (0 to 5)",value = 2,min = 0, max = 5),
hr(style = "border-width: 3px; border-color:#A9A9A9"),
selectInput("b1_sort_axis","How do you want to order your individual samples?",choices = sort("Updating")),
selectInput("b1_sort_param","How do you want to group samples (i.e., faceting)?", choices = "Updating"),
selectInput("b1_color_param","How do you want to colour your bubbles?", choices = "Updating"),
selectInput("b1_tax_sort","By what taxonomic level will the y-axis be sorted?",c("Phylum","Class","Order","Family","Genus","Species")),
checkboxInput("b1_rename_x_check","Do you want to rename your samples on the plot using a SampleShort column?", FALSE),
hr(style = "border-width: 3px; border-color:#A9A9A9"),
checkboxInput("b1_include_read","Do you want to include sample counts in a read plot?", FALSE),
checkboxInput("b1_include_taxa", "Do you want to include taxon read proportions?", FALSE),
checkboxInput("b1_fake_taxon","Do you want to show all samples regardless of present taxa?", value = FALSE),
checkboxInput("b1_factor_data","Do you want to factorize data?", value = FALSE),
hr(style = "border-width: 3px; border-color:#A9A9A9"),
#
# checkboxInput("b1_yaxis_facet", "Do you want to facet your y-axis by metadata?", FALSE),
# conditionalPanel(
# condition = "input.b1_yaxis_facet == true",
# selectInput("b1_yaxis_facet_meta","Choose the second ordering",choices = "Updating"),
checkboxInput("b1_second_facet", "Do you want a second facet?", FALSE),
conditionalPanel(
condition = "input.b1_second_facet == true",
selectInput("b1_second_facet_meta","Choose the second ordering",choices = "Updating"),
checkboxInput("b1_third_facet", "Do you want a third facet?", FALSE),
),
conditionalPanel(
condition = "input.b1_third_facet == true",
selectInput("b1_third_facet_meta","Choose the third ordering",choices = "Updating"),
),
# radioButtons("b1_confirm_sort","Do you want to sort the y-axis by taxonomic classification?",c("Yes"), selected = "Yes", inline = TRUE),
hr(style = "border-width: 3px"),
textInput("b1_tax_keyword","Select specific or multiple taxa (example: staph,coryn). Must be separated by a comma; do not include spaces"),
textInput("b1_tax_remove", "Remove specific or multiple taxa (example: staph,coryn). Must be separated by a comma; do not include spaces"),
selectInput("b1_meta_group","Select a metadata category for data filtering",choices = "Updating"),
textInput("b1_meta_keyword","Provide a specific keyword for the metadata filtering. For multiple, use a comma with no spaces (Example: canada,japan"),
hr(style = "border-width: 3px; border-color:#A9A9A9"),
radioButtons("b1_panel_border","Do you want panel borders?",choices = c("Yes","No"),selected = "No", inline = TRUE),
radioButtons("b1_facet_side_x","Where do you want the sample bar?",c("Top","Bottom"),selected = "Bottom",inline = TRUE),
radioButtons("b1_facet_side_y","Where do you want the taxon bar?",c("Left","Right"),selected = "Left",inline = TRUE),
sliderInput("b1_panel_spacing","Modify the facet spacing",min = 0, max = 20, value = 0),
# checkboxInput("b1_all_samples","Include all samples?",FALSE),
width = 3,
style = "overflow-y:scroll; max-height: 850px; position:relative;border-color:#000000"
),
mainPanel(width = 9,
fluidRow(
box(h3("Relative abundance bubble plot"),
p("The relative abundance bubble plot shows the distribution of taxa among samples and their relative proportions in the dataset. Bubble size and values represent the proportion of reads associated with a specific taxon within a given sample."),
p("To construct the bubble plot, an ASV table (or a collapsed table) is transformed into a proportion table by converting each read count into a proportion of total reads for a given sample. This table is then filtered using a defined relative abundance threshold, only keeping taxa if they are present at or above the threshold in any sample. Taxa are assigned uniqe identifiers, metadata is appended, and data is plotted as desired by the user."),
p("The table can be filtered or organized as desired. Faceting can be done based on any supplied metadata, and specific taxa or samples can be emphasized (all other samples removed) using the sidebar."),
p("A read plot can be appended to the plot showing the total read counts for each sample. A bar plot showing the proportion of taxa across all samples can also be added. In this case, read counts associated with each taxon are summed and then divided by the total read count of the entire dataset"),
width = 12)),
br(),
dataTableOutput("b1_table_out"),
fluidRow(box(
# (textInput("b1_bubble_width","Plot width",value = 10),
# textInput("b1_bubble_height", "Plot height",value = 8),
# width = 3,
# ),
# box(
sliderInput("b1_plot_out_w","Plot width",min = 0, max = 4000,step = 10,value = 600),
sliderInput("b1_plot_out_h","Plot height",min = 0, max = 4000,step = 10,value = 600),
downloadButton("b1_bubble_download","Save figure"),
downloadButton("b1_data_table","Save table"),
width = 3
)
),
br(),
br(),
plotOutput("bubble_out") %>% withSpinner(type = 1,color.background = "white"),
style = "overflow-y:scroll; max-height: 850px; position:relative;"
)
)
),
#### Bray curtis PCOA ####
tabPanel("Bray-Curtis PCoA Triplot",
sidebarLayout(
sidebarPanel(
# fileInput("bray_metadata","Upload metadata"),
numericInput("pcoa_srs_depth","Select your SRS depth.",min = 0, value = 1000),
actionButton("pcoa_start",label = "Start!",width = 335),
hr(style = "border-width: 3px"),
numericInput("pcoa_env_thresh", "Select your p-value threshold (0 - 1)", min = 0, max = 1, value = 0.5),
numericInput("pcoa_env_R_thresh", "Select your R-value threshold (0 - 1)", min = 0, max = 1, value = 0.5),
numericInput("pcoa_taxa_thresh", "Select your taxon abundance (0 - 100)", min = 0, max = 100, value = 5),
# actionButton("pcoa_start",label = "Start!",width = 335),
hr(style = "border-width: 3px"),
selectInput("pcoa_fill_col","Select your fill colour",choices = "Updating"),
sliderInput("pcoa_size_select", "Change your point size", value = 5,min = 0, max = 15),
checkboxInput("pcoa_gradient", "Do you want a colour gradient instead?", value = FALSE),
selectInput("pcoa_pallet_selection","Select a specific colour pallet", choices = c("viridis","magma","plasma","inferno","cividis","mako","rocket","turbo")),
hr(style = "border-width: 3px"),
checkboxInput("pcoa_sample_labels", "Do you want to label your samples?", value = FALSE),
checkboxInput("shape_choice","Do you want to add a shape variable?",value = FALSE),
# Conditional for shape selection
conditionalPanel(
condition = "input.shape_choice == true",
selectInput("pcoa_shape","Select your shape",choices = "Updating"),
),
#selectInput("pcoa_elips_col","Select your elipsis color",choices = "Updating"),
checkboxInput("pcoa_elips","Do you want to include statistically generated elipses?", value = FALSE),
# actionButton("pcoa_start",label = "Start!",width = 335),
# radioButtons("pcoa_elips","Do you want statistically generated elipses?", choices = c("Yes", "No"),inline = TRUE),
width = 3,
style = "overflow-y:scroll; max-height: 850px; position:relative;border-color:#000000"
),
mainPanel(width = 9,
fluidRow(
box(h3("Bray-Curtis PCoA triplot"),
p("A Bray-Curtis PCoA triplot displays sample dissimilarity along with associated influential taxa and environmental data. Samples that group together are more similar to eachother than samples further apart in ordination space. Thresholds for taxon relative abundance (proportion of reads) and p-values for significance of environmental variables can be selected in the left panel. Arrow length is proportional to the magnitude of the effect for a given environmental parameter."),
p("To generate this triplot, an ASV table is first 'rarefied' to a desired number of reads using scaling with ranked subsampling (SRS), using the", em("SRS")," R package. This normalized table is then converted to a proportion table, then into a Bray-Curtis dissimilarity matrix and PCoA matrix using the",em("vegan"),"and",em("ape")," packages. Environmental variables are fit to the PCoA coordinates using the",em("envfit")," command at 10,000 permutations, and taxa are additionally mapped using normalized weighted scores based on taxon abundance."),
p("All samples below the provided SRS depth will be removed prior to PCoA and envfit analyses and will not be plotted (so be careful)"),
width = 12)),
dataTableOutput("pcoa_table_out"),
fluidRow(
# box(
# textInput("pcoa_plot_width","Plot width",value = 12),
# textInput("pcoa_plot_height", "Plot height", value = 8),
# width = 3
# ),
box(
sliderInput("pcoa_plot_outw","Plot width",min = 0, max = 3000,step = 100,value = 1000),
sliderInput("pcoa_plot_outh","Plot height",min = 0, max = 3000,step = 100,value = 600),
# downloadButton("pcoa_merged_df","Download pcoa data"),
downloadButton("pcoa_envfit_table","Download triplot stats table"),
downloadButton("pcoa_envfit_filt_table", "Download triplot filtered stats table"),
downloadButton("pcoa_download","Save figure"),
width = 6
),
),
dataTableOutput("pcoa_stats_table"),
br(),
br(),
plotOutput("pcoa_plot_out") %>% withSpinner(type = 1,color.background = "white"),
style = "overflow-y:scroll; max-height: 850px; position:relative;"
)
)
),
#### UniFrac Plot ####
tabPanel("UniFrac PCoA Triplot",
sidebarLayout(
sidebarPanel(
# checkboxInput("uni_extra_meta","Do you want to use a different metadata file?"),
# conditionalPanel(
# condition = "input.uni_extra_meta == true",
# fileInput("uni_metadata","Upload the metadata table"),
# ),
fileInput("unifrac_tree","Please upload your rooted phylogenetic tree (in Newick format)"),
hr(style = "border-width: 3px"),
numericInput("uni_srs_depth", label = "Select your sampling depth.", value = 5000),
selectInput("uni_diss_select",label = "Select your type of UniFrac", choices = c("unweighted","weighted")),
actionButton("uni_pcoa_start","Start!", width = 335),
# fileInput("uni_meta_file","Metadata table"),
hr(style = "border-width: 3px"),
numericInput("uni_env_thresh", label = "Select your p-value threshold (0 to 1)",value = 0.5, min = 0, max = 1),
numericInput("uni_env_r_thresh", label = "Select your R-value threshold (0 to 1)", value = 0.5, min = 0, max = 1),
numericInput("uni_taxa_thresh",label = "Select your taxon abundance (0 - 100)", value = 5),
hr(style = "border-width: 3px"),
selectInput("uni_pcoa_fill_col",label = "Select your fill colour", choices = "Updating"),
sliderInput("uni_pcoa_size_select", "Change your point size", value = 5,min = 0, max = 15),
checkboxInput("uni_pcoa_gradient", "Do you want a colour gradient instead?", value = FALSE),
selectInput("uni_pcoa_pallet_selection","Select a specific colour pallet. To change, reselect the checkbox above.", choices = c("viridis","magma","plasma","inferno","cividis","mako","rocket","turbo")),
checkboxInput("uni_pcoa_sample_labels", "Do you want to label your samples?", value = FALSE),
checkboxInput("uni_shape_choice",label = "Do you want to differentiate by shape as well?", value = FALSE),
conditionalPanel(
condition = "input.uni_shape_choice == true",
selectInput("uni_pcoa_shape", label = "Select your shape", choice = "Updating")
),
checkboxInput("uni_pcoa_elips",label = "Do you want statistically generated elipses?", value = FALSE),
width = 3,
style = "overflow-y:scroll; max-height: 850px; position:relative; border-color:#000000"
),
mainPanel(width = 9,
fluidRow(
box(h3("UniFrac PCoA triplot"),
p("A UniFrac PCoA triplot displays sample dissimilarity along with associated influential taxa and environmental data. The UniFrac metric includes measures of taxon phylogenetic relatedness along with taxon presence/absence (unweighted) and presence/absence and abundance (weighted). This analysis requires an additional datafile: a rooted phylogenetic tree generated from the representative sequences in your dataset. This tree is generated in QIIME2 as part of the", em("core-metrics-phylogenetics")," workflow (export your rooted tree). Samples that group together are more similar to eachother than samples further apart in ordination space. Thresholds for taxon relative abundance (proportion of reads) and p-values for significance of environmental variables can be selected in the left panel. Arrow length is proportional to the magnitude of the effect for a given environmental parameter."),
p("To generate this triplot, an ASV table is first 'rarefied' to a desired number of reads using scaling with ranked subsampling (SRS), using the", em("SRS")," R package. This normalized table is then converted to a proportion table, then into a UniFrac dissimilarity using the proportion table and provided phylogenetic tree using the", em("GUniFrac"),"package. The resulting distance matrix is converted into a PCoA matrix using the",em("vegan"),"and",em("ape")," packages. Environmental variables are fit to the PCoA coordinates using the",em("envfit")," command at 10,000 permutations, and taxa are additionally mapped using normalized weighted scores based on taxon abundance."),
p("All samples below the provided SRS depth will be removed prior to PCoA and envfit analyses and will not be plotted (so be careful). Please be patient: it can take upwards of 30 seconds for the plot to appear."),
width = 12)),
fluidRow(
# box(
# textInput("pcoa_plot_width","Plot width",value = 12),
# textInput("pcoa_plot_height", "Plot height", value = 8),
# width = 3
# ),
box(
sliderInput("uni_pcoa_plot_outw","Plot width",min = 0, max = 3000,step = 100,value = 1000),
sliderInput("uni_pcoa_plot_outh","Plot height",min = 0, max = 3000,step = 100,value = 600),
downloadButton("uni_pcoa_download","Save figure"),
downloadButton("uni_stats_full","Download full stats table"),
downloadButton("uni_stats_filtered","Download filtered stats table"),
width = 6
)
),
dataTableOutput("unifrac_stats_table"),
br(),
br(),
plotOutput("uni_pcoa_plot_out") %>% withSpinner(type = 1,color.background = "white"),
style = "overflow-y:scroll; max-height: 850px; position:relative;"
)
)
),
#### Next Plot ####
# #### FAQ PAGE ####
tabPanel(title = "FAQ",
sidebarLayout(NULL,
mainPanel(h1("Frequently asked questions and common problems"),
uiOutput("helpme")
# fluidRow(
# box("SO YOU GOTS SOME QUESTIONS?",
# uiOutput("helppdf"),
# width = 12,
# height = 200,
# style = "background-color:#FFFFFF; border-color:#000000; border-style: solid; border-width: 1.5px; margin-left:0px; margin-right:30px; padding: 10px; height: 850px",
#
#
# )
# )
)
)
)
)