-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp_server.R
76 lines (65 loc) · 2.41 KB
/
app_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
#' Shiny application server
#' @param input,output,session Internal parameters for `{shiny}`.
#' @noRd
app_server = function(input, output, session) {
# Load mutation selectize options on server-side
# (quicker loading on slower browsers)
# This is because there is a lot of options
# client-side processing is slow
shiny::updateSelectizeInput(session,
"mutations",
choices = get_unique_mutations(
system.file("app", "www", "data",
"sarscov2-audacity-westerncape2021.csv",
package = "tfpbrowser",
mustWork = TRUE)),
server = TRUE)
# Load treeview -----------------------------------------------------------
# create plotly output from saved ggplot2 outputs
output$treeview = ggiraph::renderGirafe({
filename = get_filename(input$widgetChoice)
g = readRDS(filename)
tooltip_css = paste0(
"background-color:black;",
"color:grey;",
"padding:14px;",
"border-radius:8px;",
"font-family:\"Courier New\",monospace;"
)
suppressWarnings(ggiraph::girafe(ggobj = g,
options = list(
ggiraph::opts_selection(
type = "single"),
ggiraph::opts_sizing(
width = 0.8),
ggiraph::opts_tooltip(
css = tooltip_css,
use_fill = FALSE)
)
))
})
# get selected cluster id based on widget choice
selected_cluster_id = shiny::reactive({
get_selected_cluster_id(widgetChoice = input$widgetChoice,
treeviewSelected = input$treeview_selected)
})
# output result of click
output$select_text = shiny::renderText({
paste("You have selected cluster ID:", selected_cluster_id())
})
# Tables Tab --------------------------------------------------------------
tablesServer(
"table1",
cluster_choice = selected_cluster_id
)
# Plots Tab ----------------------------------------------------------
plotsServer(
"plot1",
cluster_choice = selected_cluster_id
)
# RDS Tab ----------------------------------------------------------
rdsServer(
"rds1",
cluster_choice = selected_cluster_id
)
} # end server function