-
Notifications
You must be signed in to change notification settings - Fork 1
/
ui.R
458 lines (417 loc) · 14.5 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
#### CeNGEN-app 2018-2022
#### Report bugs at https://github.com/cengenproject/CengenApp/issues
cat("############# Loading libraries #################\n")
require(shiny)
library(shinyjs)
library(shinythemes)
library(DT)
library(tidyverse)
library(pheatmap)
library(ggridges)
library(cowplot)
library(shinybusy)
library(plotly)
library(svglite)
library(expss)
library(BiocManager)
library(edgeR)
library(qs)
library(Matrix)
library(limma)
cat("############## Setting options ##################\n")
options(repos = BiocManager::repositories())
options(shiny.maxRequestSize = 400 * 1024 ^ 2)
options(scipen = 0)
options(digits = 2)
cat("############ End initializations ################\n")
source("Functions.R")
utr <-
c(
"WBGene00023498",
"WBGene00023497",
"WBGene00004397",
"WBGene00006843",
"WBGene00004010",
"WBGene00006789",
"WBGene00001135",
"WBGene00001079",
"WBGene00001135",
"WBGene00006783",
"WBGene00000501",
"WBGene00006788",
"WBGene00001555",
"WBGene00206533",
"WBGene00011964",
"WBGene00018172",
"WBGene00016259",
"WBGene00023407"
)
msg <- filter(gene_list, gene_id %in% utr)$gene_name %>% paste(., collapse = ", ")
## UI ----
ui <- fluidPage(
tags$head(includeHTML(("google-analytics-script2.html"))),
theme = "Theme.min.css",
tags$head(tags$style(
HTML(".shiny-output-error-validation {color: red;}")
)),
# App title ----
titlePanel(
"Discovery and analysis of the C. elegans Neuronal Gene Expression Network -- CeNGEN"
),
tags$a(href="http://www.cengen.org/single-cell-rna-seq/", "CeNGENApp Help and Documentation"),
hr(),
add_busy_spinner(
spin = "double-bounce",
color = "orange",
timeout = 100,
position = c("top-right"),
onstart = TRUE,
margins = c(10, 10),
height = "50px",
width = "50px"
),
# Main panel showing plots ----
tabsetPanel(
type = "pills",
id = "tabs",
### Gene expression by cell type Panel ----
tabPanel(
"Gene expression by cell type",
fluidPage(
hr(),
h6(
"Find all genes expressed in a given cell type, or all cell types expressing a given gene (or group of genes)."
),
h6("Select one of four thresholds for expression:"),
h6("1 (least stringent) to 4 (most stringent) or select unfiltered data"),
h6("Choose All Cells Unfiltered to query the entire unfiltered dataset, including non-neuronal cells"),
hr(),
fluidRow(
column(1),
column(
4,
selectInput(
inputId = "Tcell_name",
label = "Select cell type",
choices = all_cell_types,
selected = "ADA"
),
selectInput(
inputId = "Tcell_cut",
label = "Select threshold",
choices = c(1:4, "Unfiltered", "All Cells Unfiltered"),
selected = 2
),
actionButton("TCell", "Expressed genes", icon = icon("hand-point-right"))
),
#column(width = 1, offset = 0, style='padding:5px;'),
column(
4,
textInput(
inputId = "Tgene_name",
label = "Type gene name",
value = "zig-4"
),
selectInput(
inputId = "Tgene_cut",
label = "Select threshold",
choices = c(1:4, "Unfiltered", "All Cells Unfiltered"),
selected = 2
),
actionButton("TGene", "Which cell types", icon = icon("hand-point-right"))
),
column(
2,
offset = 0,
style = 'padding:5px;',
textAreaInput(
inputId = "Tgene_name_batch",
label = "Query multiple genes for download",
value = "flp*\nWBGene00001447\nWBGene00001448,zig-4",
width = "500px",
height = "100px"
),
selectInput(
inputId = "Tgene_cut_batch",
label = "Select threshold",
choices = c(1:4, "Unfiltered", "All Cells Unfiltered" ),
selected = 2
),
downloadButton("TGeneBatch", "Download batch"),
span(textOutput("textb"), style =
"color:red")
)
),
br(),
h6( paste0("WARNING: Expression values for ",msg," are unreliable as they have been overexpressed to generate transgenic strains."), style="color:orange"),
fluidRow(
column(1),
column(
4,
br(),
span(textOutput("Error1"), style ="color:red"),
DT::dataTableOutput("Tcell_name_table"),
br(),
uiOutput("get_download_gene")
),
#column(width = 1, offset = 0, style='padding:5px;'),
column(
4,
br(),
DT::dataTableOutput("Tgene_name_table"),
br(),
#downloadButton('downloadCell', "Download table"),
uiOutput("get_download_cell"),
span(textOutput("text1"), style =
"color:red")
)
)
)
),
### Find markers based on percentage of expression Panel ----
tabPanel(
"Find markers based on percentage of expression",
fluidPage(
hr(),
h6(
"Find genes expressed in one group of cell types and not in another group based on the percentages of cells expressing the gene."
),
h6( paste0("WARNING: Expression values for ",msg," are unreliable as they have been overexpressed to generate transgenic strains."), style="color:orange"),
br(),
fluidRow(
#column(1),
column(
4,
textInput(
inputId = "String1",
label = "Group 1",
value = "AWC_ON,AWC_OFF"
),
textInput(
inputId = "Expressed",
label = "Minimum percentage of cells expressing the gene",
value = 65
),
actionButton("Filter", "Run query", icon = icon("hand-point-right"))
),
#column(width = 1, offset = 0, style='padding:5px;'),
column(
4,
textInput(
inputId = "String2",
label = "Group 2",
value = "SMD,SIB"
),
textInput(
inputId = "NonExpressed",
label = "Maximum percentage of cells expressing the gene",
value = 2
),
downloadButton('downloadQuery', "Download table")
)
),
fluidRow(
#column(1),
column(4,
br(), DT::dataTableOutput("YesExpressed")),
column(4,
br(),
DT::dataTableOutput("NoExpressed")),
column(4,
br(),
DT::dataTableOutput("Result")
#span(textOutput("text3"), style="color:red"))
)
)
)
),
### Enriched Genes by cell type Panel ----
tabPanel(
"Enriched Genes by cell type",
fluidPage(
hr(),
h6(
"Find genes differentially expressed in one cell type compared to all other cells in the dataset (neurons only or all cell types).
This is NOT a comprehensive list of genes detected in each cell type."
),
h6("Please see Gene Expression by Cell type for a comprehensive list of expression values of each gene in a given cell type."),
textOutput("TopMarkers cell plot"),
selectInput(
inputId = "dataset2",
label = "Choose dataset",
choices = c("All cell types", "Neurons only")
),
conditionalPanel(
"input.dataset2 == 'Neurons only'",
selectInput(
inputId = "Markers",
label = "Select cluster",
choices = all_neuron_types,
selected = "SIA"
),
textInput(
inputId = "top",
label = "Show top X genes",
value = "100"
),
h6( paste0("WARNING: Expression values for ",msg," are unreliable as they have been overexpressed to generate transgenic strains."), style="color:orange"),
DT::dataTableOutput("MarkTable"),
downloadButton('downloadMarkers', "Download table"),
h6("HEADER LEGEND:"),
h6(
"p-val and p_val_adj: nominal and adjusted P-values of the test, respectively."
),
h6(
"pct.1 and pct.2: The percentage of cells where the gene is detected in the first or second group"
),
h6(
"avg_logFC: Log of the expression fold change between group 1 and group 2."
)
),
conditionalPanel(
"input.dataset2 == 'All cell types'",
selectInput(
inputId = "Markers2",
label = "Select cluster",
choices = all_cell_types,
selected = "SIA"
),
textInput(
inputId = "top2",
label = "Show top X genes",
value = "100"
),
h6( paste0("WARNING: Expression values for ",msg," are unreliable as they have been overexpressed to generate transgenic strains."), style="color:orange"),
DT::dataTableOutput("MarkTable2"),
downloadButton('downloadMarkers2', "Download table"),
h6("HEADER LEGEND:"),
h6(
"p-val and p_val_adj: nominal and adjusted P-values of the test, respectively."
),
h6(
"pct.1 and pct.2: The percentage of cells where the gene is detected in the first or second group"
),
h6(
"avg_logFC: Log of the expression fold change between group 1 and group 2."
)
)
)
),
### Find Differential Expression between Cell Types Panel ----
tabPanel(
"Find Differential Expression between Cell Types",
fluidPage(
hr(),
h6("Find differentially expressed genes between two cell types or two groups of cell types."),
h6("The calculation can take a few minutes."),
h6( paste0("WARNING: Expression values for ",msg," are unreliable as they have been overexpressed to generate transgenic strains."), style="color:orange"),
hr(),
fluidRow(
column(
4,
selectInput(
inputId = "batch1",
label = "Select Group 1",
choices = all_cell_types,
selected = "AVL",
multiple = TRUE
),
selectInput(
inputId = "batch2",
label = "Select Group 2: Introduce cell types, NEURONS or ALL",
choices = c("ALL","NEURONS", all_cell_types),
selected = c("RME_DV","RME_LR"),
multiple = TRUE
),
actionButton("DEXButton", "Calculate DEX", icon = icon("hand-point-right"))
),
column(
3,
selectInput(
inputId = "test",
label = "Select statistical test",
choices = c("Wilcoxon on single cells", "Pseudobulk: Wilcoxon", "Pseudobulk: edgeR pairwise exact test")
),
textInput(
inputId = "topM2",
label = "Show top X genes",
value = "100"
)
)
),
br(),
htmlOutput("pseudobulk_metadata", container = h6),
br(),
span(textOutput("text_error_dex"), style =
"color:red"),
br(),
DT::dataTableOutput("MarkTable_Batch"),
downloadButton('downloadDEX', "Download table"),
htmlOutput("legend_de_columns", container = h6)
)
),
### Heatmaps of gene expression Panel ----
tabPanel(
"Heatmaps of gene expression",
fluidPage(
hr(),
h6(
"Display a heatmap showing relative expression and proportion of cells expressing a gene or group of genes across all neurons. This function uses data from threshold 2. Color shows relative scaled expression for each gene across neuron types, and is not comparable between genes."
),
h6( paste0("WARNING: Expression values for ",msg," are unreliable as they have been overexpressed to generate transgenic strains."), style="color:orange"),
textAreaInput(
inputId = "genelist",
label = "Introduce a list of genes",
value = "flp*\nWBGene00001447\nWBGene00001448,zig-4",
width = "500px",
height = "100px"
),
fluidRow(
column(width = 3,
selectInput(
inputId = "dataset_heatmap",
label = "Choose dataset: Neurons (threshold 2), All cells (unfiltered)",
choices = c("Neurons only", "All cell types")
)
),
column(width = 1, offset = -10,
checkboxInput(inputId = "reorder_rows",
label = "Reorder rows",
value = TRUE),
)
),
actionButton(
"PlotHeatmapFromList","Plot heatmap from list",
icon = icon("hand-point-right")
),
hr(),
fluidRow(
column(3,fileInput("file1", NULL,
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
"txt")
)),
#column(3,actionButton("resetFile", "Clear uploaded file")),
column(3, actionButton(
"PlotHeatmapFromFile",
"Plot heatmap from file",
icon = icon("hand-point-right")
))
),
h6(
"You can identify circles by clicking on them."
),
div(style="height:30px;width:800px;padding-left:10px;padding-right:10px;background-color:#ffffff;",fluidRow(verbatimTextOutput("vals", placeholder = TRUE))),
#uiOutput("dynamic"),
br(),
br(),
br(),
plotOutput("heatmap", width = "100%", height = "auto", hover = "plot_hover"),
hr(),
downloadLink("downloadheatmap", "Download plot", class = "btn btn-default"),
downloadLink("downloadheatmap_svg", "Download plot as SVG", class = "btn btn-default")
)
)
)
)