-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.R
executable file
·289 lines (250 loc) · 10.8 KB
/
server.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
# server.R
print("didcomehere4")
# Define a server for the Shiny app
shinyServer(function(input, output, session) { # TODO: read on what 'session' means here.
# for observer functions
observe({
# liquid RNA-seq plots
updateSelectizeInput(session,
inputId = "rna_genes",
choices = sort(rownames(rnamat_sub)), server = TRUE,
selected = c("BCL2", "TP53", "FLT3", "MYC", "JAK2")
)
updateSelectizeInput(session,
inputId = "bar_gene",
choices = sort(rownames(rnamat_sub)), server = TRUE,
selected = c("BCL2")
)
# solid RNA-seq plots
updateSelectizeInput(session,
inputId = "rna_genes_solid",
choices = sort(rownames(rnamat_sub)), server = TRUE,
selected = c("BCL2", "TP53", "KRAS", "MYC", "PTEN", "PIK3CA")
)
updateSelectizeInput(session,
inputId = "bar_gene_solid",
choices = sort(rownames(rnamat_sub)), server = TRUE,
selected = c("TP53")
)
# Shiny 'links' between tab panels
if (input$Request_link != 0) updateTabsetPanel(session, inputId = "mainNavBar", selected = "Line Request/Pricing")
if (input$Methods_link != 0) updateTabsetPanel(session, inputId = "mainNavBar", selected = "Methods")
# Line Request link button for solid tab
if (input$Request_link_solid != 0) updateTabsetPanel(session, inputId = "mainNavBar", selected = "Line Request/Pricing")
})
# Liquid tumors, defined in server/liquid_tumors/
server_liquid_tumors_database_explorer(input, output, session)
server_liquid_tumors_pdx_gene_expression(input, output, session)
server_liquid_tumors_pdx_mutations(input, output, session)
server_liquid_tumors_pdx_viral_transcript_detection(input, output, session)
server_liquid_tumors_pdx_gene_fusion_predictions(input, output, session)
server_liquid_tumors_contingency_table(input, output, session)
server_liquid_tumors_line_report(input, output, session)
server_liquid_tumors_glossary(input, output, session)
server_liquid_tumors_methods(input, output, session)
# Solid Tumors, defined in server/solid_tumors
server_solid_tumors_database_explorer(input, output, session)
server_solid_tumors_pdx_gene_expression(input, output, session)
server_solid_tumors_glossary(input, output, session)
# 'More' menu, defined in server/more/
server_more_line_request_pricing(input, output, session)
server_more_ilab_billing_platform(input, output, session)
######### -- observing dropdownMenu objects -- ########
# TODO, if possible: convert all of this into a Shiny module that is 1) purely dependent on column metadata, and 2) not hardcoded separately per button.
# Note I tried doing `2. selecting all` by loop, but it failed. Keep looking for solution.
## 1. sorting a2z
# liquid
observeEvent(input[["a2z_liquid_administrative"]], {
updateCheckboxGroupInput(
session = session, inputId = "check2_liquid_administrative",
choices = sort(meta3[(meta3$`Column Groupings` == "administrative"), ]$`PRoXe Column Header`),
selected = input$check2_liquid_administrative
)
})
observeEvent(input[["a2z_liquid_tumor"]], {
updateCheckboxGroupInput(
session = session, inputId = "check2_liquid_tumor",
choices = sort(meta3[(meta3$`Column Groupings` == "tumor"), ]$`PRoXe Column Header`),
selected = input$check2_liquid_tumor
)
})
observeEvent(input[["a2z_liquid_patient"]], {
updateCheckboxGroupInput(
session = session, inputId = "check2_liquid_patient",
choices = sort(meta3[(meta3$`Column Groupings` == "patient"), ]$`PRoXe Column Header`),
selected = input$check2_liquid_patient
)
})
observeEvent(input[["a2z_liquid_pdx"]], {
updateCheckboxGroupInput(
session = session, inputId = "check2_liquid_pdx",
choices = sort(meta3[(meta3$`Column Groupings` == "pdx"), ]$`PRoXe Column Header`),
selected = input$check2_liquid_pdx
)
})
# solid
observeEvent(input[["a2z_solid_administrative"]], {
updateCheckboxGroupInput(
session = session, inputId = "check2_solid_administrative",
choices = sort(solid_meta2[(solid_meta2$`Column Groupings` == "administrative"), ]$`PRoXe Column Header`),
selected = input$check2_solid_administrative
)
})
observeEvent(input[["a2z_solid_tumor"]], {
updateCheckboxGroupInput(
session = session, inputId = "check2_solid_tumor",
choices = sort(solid_meta2[(solid_meta2$`Column Groupings` == "tumor"), ]$`PRoXe Column Header`),
selected = input$check2_solid_tumor
)
})
observeEvent(input[["a2z_solid_pdx"]], {
updateCheckboxGroupInput(
session = session, inputId = "check2_solid_pdx",
choices = sort(solid_meta2[(solid_meta2$`Column Groupings` == "pdx"), ]$`PRoXe Column Header`),
selected = input$check2_solid_pdx
)
})
# NOTE: there is currently no _patient version for solid because we do not yet have patient data.
# Remove if(F) below manually when we get 'patient' data. (see solid_meta2$`Column Groupings`)
if (F) {
observeEvent(input[["a2z_solid_patient"]], {
updateCheckboxGroupInput(
session = session, inputId = "check2_solid_patient",
choices = sort(solid_meta2[(solid_meta2$`Column Groupings` == "patient"), ]$`PRoXe Column Header`),
selected = input$check2_solid_patient
)
})
}
## 2. selecting all
# TODO: functionalize call of observeEvent()s below via for loop or other mechanism
if (F) { # Note this does not work. Determine why. # Test: does it work ok to access input as list like this?
for (colgrp in levels(as.factor(meta3$`Column Groupings`))) {
observeEvent(input[[paste0("all_", colgrp)]], {
if (all(meta3[meta3$`Column Groupings` == colgrp, ]$`PRoXe Column Header` %in% input[[paste0("check2_", colgrp)]])) {
updateCheckboxGroupInput(
session = session, inputId = input[[paste0("check2_", colgrp)]], selected = ""
)
} else {
updateCheckboxGroupInput(
session = session, inputId = input[[paste0("check2_", colgrp)]], selected = names(df[1:(obInvisRet_ind - 1)])
)
}
})
}
} # end of if(F)
# if(F){ # purpose -- commenting out this section below for testing.
# liquid
observeEvent(input$all_liquid_administrative, {
if (all(meta3[meta3$`Column Groupings` == "administrative", ]$`PRoXe Column Header` %in% input$check2_liquid_administrative)) {
updateCheckboxGroupInput(
session = session, inputId = "check2_liquid_administrative", selected = ""
)
} else {
updateCheckboxGroupInput(
session = session, inputId = "check2_liquid_administrative", selected = names(df[1:(obInvisRet_ind - 1)])
)
}
})
observeEvent(input$all_liquid_tumor, {
if (all(meta3[meta3$`Column Groupings` == "tumor", ]$`PRoXe Column Header` %in% input$check2_liquid_tumor)) {
updateCheckboxGroupInput(
session = session, inputId = "check2_liquid_tumor", selected = ""
)
} else {
updateCheckboxGroupInput(
session = session, inputId = "check2_liquid_tumor", selected = names(df[1:(obInvisRet_ind - 1)])
)
}
})
observeEvent(input$all_liquid_patient, {
if (all(meta3[meta3$`Column Groupings` == "patient", ]$`PRoXe Column Header` %in% input$check2_liquid_patient)) {
updateCheckboxGroupInput(
session = session, inputId = "check2_liquid_patient", selected = ""
)
} else {
updateCheckboxGroupInput(
session = session, inputId = "check2_liquid_patient", selected = names(df[1:(obInvisRet_ind - 1)])
)
}
})
observeEvent(input$all_liquid_pdx, {
if (all(meta3[meta3$`Column Groupings` == "pdx", ]$`PRoXe Column Header` %in% input$check2_liquid_pdx)) {
updateCheckboxGroupInput(
session = session, inputId = "check2_liquid_pdx", selected = ""
)
} else {
updateCheckboxGroupInput(
session = session, inputId = "check2_liquid_pdx", selected = names(df[1:(obInvisRet_ind - 1)])
)
}
})
# solid
observeEvent(input$all_solid_pdx, {
if (all(solid_meta2[solid_meta2$`Column Groupings` == "pdx", ]$`PRoXe Column Header` %in% input$check2_solid_pdx)) {
updateCheckboxGroupInput(
session = session, inputId = "check2_solid_pdx", selected = ""
)
} else {
updateCheckboxGroupInput(
session = session, inputId = "check2_solid_pdx", selected = names(solid[1:(obInvisRet_ind_solid - 1)])
)
}
})
observeEvent(input$all_solid_administrative, {
if (all(solid_meta2[solid_meta2$`Column Groupings` == "administrative", ]$`PRoXe Column Header` %in% input$check2_solid_administrative)) {
updateCheckboxGroupInput(
session = session, inputId = "check2_solid_administrative", selected = ""
)
} else {
updateCheckboxGroupInput(
session = session, inputId = "check2_solid_administrative", selected = names(solid[1:(obInvisRet_ind_solid - 1)])
)
}
})
observeEvent(input$all_solid_tumor, {
if (all(solid_meta2[solid_meta2$`Column Groupings` == "tumor", ]$`PRoXe Column Header` %in% input$check2_solid_tumor)) {
updateCheckboxGroupInput(
session = session, inputId = "check2_solid_tumor", selected = ""
)
} else {
updateCheckboxGroupInput(
session = session, inputId = "check2_solid_tumor", selected = names(solid[1:(obInvisRet_ind_solid - 1)])
)
}
})
# } # end of if(F)
# Frequently asked questions
output$FAQ <- renderUI({
# TODO: later functionalize this
filename <- dir(path = "www", pattern = "_PROXE_FAQ.pdf", full.names = T)
if (length(filename) < 1) warning("Where is the FAQ pdf?")
if (length(filename) > 1) {
warning("> 1 FAQ PDFs in www folder. Taking last saved.")
tmp <- sapply(filename, function(i) file.info(i)$mtime)
newest_file <- sort(tmp, decreasing = T)[1]
filename <- names(newest_file)
}
filename <- gsub("www/", "", filename)
tags$iframe(
src = filename,
width = "100%",
height = "800px"
)
})
# popup
shinyalert(
title = "Hi there!",
text = "Effective May 1, 2020, PRoXe development has migrated to a PRoXe instance of cBioPortal. This legacy Shiny app will remain accessible until May 1, 2025 but will not receive further updates. <br><br>To view current PRoXe data, <a target=\"_blank\" href=\"https://docs.google.com/forms/d/e/1FAIpQLSe0ccf_xoGZJyqM2xwj-_0oxraxK87ZrkAeWaDOx-usRECXdA/viewform\">register for a cBioPortal account here</a>. Note that a Gmail account is required. <br><br>Please <a href=\"mailto:proxe.feedback@gmail.com?Subject=cBioPortal transition\">reach out</a> with any questions.<br><br>Sincerely, the PRoXe Team",
closeOnEsc = TRUE,
closeOnClickOutside = FALSE,
html = TRUE,
type = "success",
showConfirmButton = TRUE,
showCancelButton = FALSE,
confirmButtonText = "OK",
confirmButtonCol = "#AEDEF4",
timer = 0,
imageUrl = "",
animation = TRUE
)
})