-
Notifications
You must be signed in to change notification settings - Fork 10
/
ui.R
199 lines (162 loc) · 8.12 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
source(file.path('ui', 'documentation_tab.R')) # loads documentation_tab var
source(file.path('ui', 'report_tab.R')) # loads report_tab var
source(file.path('ui', 'import_tab.R')) # loads import_tab var
source(file.path('ui', 'settings_tab.R')) # loads settings
# list of menu items for switching tabs
# add static items for static tabs first
menu_items <- list()
# add menu item for each tab
for(i in 1:length(tabs)) {
# for tabName, replace spaces/whitespace with dashes '-'
menu_items[[i]] <- menuSubItem(tabs[i], tabName=paste0(gsub('\\s', '-', tabs[i]), '-', i))
}
# list of tab items for each tab
# add static items for static tabs first
tab_items <- list(
import_tab,
report_tab,
documentation_tab,
settings_tab
)
# add tab item for each tab
# each tab has a uiOutput (HTML output) that will be
# defined in server.R
for(i in 1:length(tabs)) {
# for tabName, replace spaces/whitespace with dashes '-'
tab_items[[i+length(tab_items)]] <- tabItem(tabName=paste0(gsub('\\s', '-', tabs[i]), '-', i),
fluidPage( uiOutput(tabs[i]) )
)
}
# set a lite regex in the css to override the default box-header colors
for(i in 1:length(tabs)) {
tab_name <- paste0(gsub('\\s', '-', tabs[i]), '-', i)
app_css <- paste0(app_css, ' .tab-pane[id*=\"', tab_name , '\"] .box-header {',
'background-color: ', config[['tab_colors']][i], '; color: white; }')
# also add a border to the menu item
app_css <- paste0(app_css, '.treeview ul.treeview-menu a[data-value*=\"', tab_name , '\"] {',
'border-left: 10px solid ', config[['tab_colors']][i], '; }')
# and make the color the background when the menuitem is active
app_css <- paste0(app_css, '.treeview-menu li.active a[data-value*=\"', tab_name , '\"] {',
'background-color: ', config[['tab_colors[i]']], '; color: white; }')
}
## resolve dependency collisions between shinydashboard and shinyWidgets
## we'll use these dependency handles to suppress warnings and then reinject them
# # get bootstrap dependency
#bsDep <- shiny::bootstrapLib()
#bsDep$name <- "bootstrap2"
library(htmltools)
bsDep <- findDependencies(
bootstrapLib()
)
bsDep[[1]]$name <- "bootstrap2"
# get pickerInput dependency
pkDep <- htmltools::findDependencies(shinyWidgets:::attachShinyWidgetsDep(tags$div(), widget = "picker"))
pkDep[[2]]$name <- "picker2"
global_filters <- list()
if (config[['do_ms_mode']] == 'max_quant'){
global_filters <- list(
shinyWidgets::sliderTextInput('pep_thresh',
label=tags$div(class='slider-label-header',
tags$span(class='slider-title', 'PEP Threshold:'),
# tooltip: https://getbootstrap.com/docs/3.3/javascript/#tooltips
tags$button(class='btn btn-secondary tooltip-btn', icon('question-sign', lib='glyphicon'),
`data-toggle`='tooltip', `data-placement`='right',
title='Filter identified peptides at an identification confidence threshold (Posterior error probability -- PEP). Peptides that have a PEP higher than this value will not be included in the module analyses or visualizations.'
)
),
grid = T, choices=c(1e-4, 1e-3, 1e-2, 1e-1, 1), selected=config[['pep_thresh']]),
# PIF filter slider
shinyWidgets::sliderTextInput('pif_thresh',
label=tags$div(class='slider-label-header',
tags$span(class='slider-title', 'PIF Threshold:'),
# tooltip: https://getbootstrap.com/docs/3.3/javascript/#tooltips
tags$button(class='btn btn-secondary tooltip-btn', icon('question-sign', lib='glyphicon'),
`data-toggle`='tooltip', `data-placement`='right',
title='Filter identified peptides at an isolation purity score threshold (Precursor Ion Fraction -- PIF). Peptides that have a PIF lower than this value will not be included in the module analyses or visualizations'
)
),
grid = T, choices=seq(0, 1, by=0.1), selected=config[['pif_thresh']])
)
} else if (config[['do_ms_mode']] == 'dia-nn'){
global_filters <- list(
shinyWidgets::sliderTextInput('pep_thresh',
label=tags$div(class='slider-label-header',
tags$span(class='slider-title', 'PEP Threshold:'),
# tooltip: https://getbootstrap.com/docs/3.3/javascript/#tooltips
tags$button(class='btn btn-secondary tooltip-btn', icon('question-sign', lib='glyphicon'),
`data-toggle`='tooltip', `data-placement`='right',
title='Filter identified peptides at an identification confidence threshold (Posterior error probability -- PEP). Peptides that have a PEP higher than this value will not be included in the module analyses or visualizations.'
)
),
grid = T, choices=c(1e-4, 1e-3, 1e-2, 1e-1, 1), selected=config[['pep_thresh']]),
shinyWidgets::pickerInput(
inputId = "modification",
choices = config[['modification_list']]$name,
label=tags$div(class='slider-label-header',
tags$span(class='slider-title', 'Modification:'),
# tooltip: https://getbootstrap.com/docs/3.3/javascript/#tooltips
tags$button(class='btn btn-secondary tooltip-btn', icon('question-sign', lib='glyphicon'),
`data-toggle`='tooltip', `data-placement`='right',
title='Filter dataset for certain modifications.'
)
),
)
)
}
shinyUI(
dashboardPage(skin=config[['mode_skin']],
dashboardHeader(title = "DO-MS Dashboard",
tags$li(class='dropdown', style='display:flex;flex-direction:row;align-items:center;height:50px',
tags$a(class='github-btn', style='padding:5px;border-radius:10px',
href='https://github.com/SlavovLab/DO-MS/', target='_blank',
tags$img(src='GitHub_Logo_White.png', height='30px')),
tags$span(class='version-string', paste0('Version: ', version)),
tags$span(class='version-string', paste0('Mode: ', config[['mode_name']])))
# tags$li(class='dropdown',
# tags$button(type='button', class='btn btn-default', `data-container`='body', `data-toggle`='popover',
# `data-placement`='bottom',
# `data-content`=checkboxGroupInput('Exp_Sets', '', choices=NULL, selected=NULL,
# choiceNames=NULL, choiceValues=NULL),
# `data-html`=TRUE,
# 'Popover on bottom')
# )
),
dashboardSidebar(
sidebarMenu(
# Sidebar Menu Options
menuItem("Import Data", tabName = "import", icon = icon("upload", lib="glyphicon", verify_fa = FALSE)),
menuItem("Dashboard", tabName = "dashboard",
icon = icon("signal", lib = "glyphicon", verify_fa = FALSE), startExpanded = TRUE,
menu_items
),
menuItem("Generate Report", tabName = "report", icon = icon("file", lib="glyphicon", verify_fa = FALSE)),
menuItem("Documentation", tabName = "documentation", icon = icon("book", lib="glyphicon", verify_fa = FALSE)),
menuItem("Plot Settings", tabName = "settings", icon = icon("cog", lib="glyphicon", verify_fa = FALSE))
),
tags$hr(),
tags$h4('Select Experiments to Display'),
shinyWidgets::pickerInput(
inputId = "Exp_Sets", choices = NULL, selected=NULL, multiple = TRUE,
options = list(`actions-box` = TRUE, size = 10, `selected-text-format` = 'count > 1')
),
tags$hr(),
# global filters for MQ mode
global_filters
# PEP filter slider
),
dashboardBody(
## resolve dependency collisions between shinydashboard and shinyWidgets
## https://github.com/dreamRs/shinyWidgets/issues/147
# Suppress dependencies
htmltools::suppressDependencies("selectPicker"),
htmltools::suppressDependencies("bootstrap"),
# reinject them
pkDep, bsDep,
tags$head(
tags$style(HTML(app_css)),
tags$script(HTML(app_js))
),
div(class='tab-content', tab_items)
)
)
)