-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui.R
More file actions
304 lines (295 loc) · 10.6 KB
/
ui.R
File metadata and controls
304 lines (295 loc) · 10.6 KB
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
# ui.R — E-Breathomics Dashboard layout
page_navbar(
title = tags$span(
tags$img(
src = "logo.png", height = "30px",
style = "margin-right:10px;", onerror = "this.style.display='none'"
),
"E-Breathomics"
),
theme = e_theme,
id = "main_nav",
header = tags$head(
tags$style(HTML("
/* Login card centring */
.login-panel { max-width:420px; margin:10vh auto; }
.card { background:#112240; border:1px solid #2EC4B6; }
.card-header { background:#2EC4B6; color:#0b172a; font-weight:600; }
/* plotly background */
.js-plotly-plot .plotly .main-svg { background:transparent !important; }
/* Compact value boxes */
.bslib-value-box .value-box-value { font-size: 1.2rem !important; }
.bslib-value-box .value-box-title { font-size: 0.85rem !important; }
.bslib-value-box .value-box-showcase .fa { font-size: 2rem !important; }
"))
),
# ── Login tab (shown first) ────────────────────────────────────────────────
nav_panel(
title = "Login",
icon = icon("lock"),
value = "login_tab",
div(
class = "login-panel",
div(
class = "card",
div(class = "card-header", "Secure Gateway"),
div(
class = "card-body",
radioButtons("login_role", "I am a:",
choices = c("Patient", "Clinician"),
selected = "Patient", inline = TRUE),
conditionalPanel(
condition = "input.login_role == 'Patient'",
selectInput("user_id_field", "Research ID",
choices = c("Select your ID" = "", valid_patient_ids))
),
conditionalPanel(
condition = "input.login_role == 'Clinician'",
passwordInput("clinician_password", "Clinician Code")
),
actionButton("login_button", "Enter Dashboard",
class = "btn-primary w-100 mt-2")
)
)
)
),
# ── Overview tab ───────────────────────────────────────────────────────────
nav_panel(
title = "Overview",
icon = icon("chart-pie"),
value = "overview_tab",
conditionalPanel(
condition = "output.is_clinician == true",
div(
class = "mb-3",
selectInput("clinician_filter_id", "Filter by Research ID",
choices = c("All" = "All", valid_patient_ids),
width = "300px")
)
),
layout_columns(
col_widths = c(4, 4, 4),
value_box("Patient ID", uiOutput("ov_id_card"), showcase = icon("id-card"),
theme = "primary"),
value_box("Diagnosis", uiOutput("ov_diag_card"), showcase = icon("stethoscope"),
theme = "secondary"),
value_box("Treatment", textOutput("ov_treat"), showcase = icon("pills"),
theme = "info")
),
# Patient view: Top taxa (left) + GE pie chart (right)
conditionalPanel(
condition = "output.is_clinician != true",
layout_columns(
col_widths = c(7, 5),
card(
card_header(icon("bacteria"), " Top Taxa Carrying Genetic Elements"),
uiOutput("ov_top_taxa_list")
),
card(
card_header("Genetic Elements Detected"),
plotlyOutput("ov_ge_pie", height = "320px")
)
)
),
# Clinician view: original tables
conditionalPanel(
condition = "output.is_clinician == true",
layout_columns(
col_widths = c(6, 6),
card(
card_header("Patient Details"),
DTOutput("ov_table")
),
card(
card_header("Samples Available"),
DTOutput("ov_samples_clin")
)
)
)
),
# ── Alpha Diversity tab ────────────────────────────────────────────────────
nav_panel(
title = "Alpha Diversity",
icon = icon("chart-bar"),
value = "alpha_tab",
layout_sidebar(
sidebar = sidebar(
title = "Options",
selectInput("alpha_index", "Diversity Index",
choices = c("Richness", "Shannon")),
conditionalPanel(
condition = "output.is_clinician == true",
selectInput("alpha_group", "Group by",
choices = c("Sample type" = "type",
"Diagnosis" = "Immunodeficiency_diagnosis"))
),
width = 250
),
layout_columns(
col_widths = c(6, 6),
card(
card_header("Boxplot Comparison"),
plotlyOutput("alpha_boxplot", height = "500px")
),
card(
card_header("Per-Sample Diversity"),
plotlyOutput("alpha_sample_plot", height = "500px")
)
)
)
),
# ── Beta Diversity (PCoA) tab ──────────────────────────────────────────────
nav_panel(
title = "Beta Diversity",
icon = icon("project-diagram"),
value = "beta_tab",
layout_sidebar(
sidebar = sidebar(
title = "Options",
selectInput("beta_colour", "Colour by",
choices = c("Sample type" = "type",
"Diagnosis" = "Immunodeficiency_diagnosis")),
width = 250
),
card(
card_header("PCoA — Bray-Curtis Dissimilarity"),
plotlyOutput("beta_pcoa", height = "600px")
),
card(
card_header("PERMANOVA Results"),
verbatimTextOutput("beta_permanova")
)
)
),
# ── Taxonomic Profiles tab ─────────────────────────────────────────────────
nav_panel(
title = "Taxonomy",
icon = icon("bacteria"),
value = "taxonomy_tab",
layout_sidebar(
sidebar = sidebar(
title = "Options",
conditionalPanel(
condition = "output.is_clinician == true",
selectInput("tax_diagnosis", "Diagnosis",
choices = c("All", "CVID", "XLA", "HG", "SID"),
selected = "CVID")
),
selectInput("tax_type", "Sample Type",
choices = c("All", "Exhale", "Sputum")),
sliderInput("tax_top_n", "Top N genera", min = 10, max = 50,
value = 30, step = 5),
width = 250
),
card(
card_header(
class = "d-flex justify-content-between align-items-center",
"Relative Abundance — Stacked Bar Chart",
actionButton("expand_tax_bar", label = NULL, icon = icon("expand"),
class = "btn btn-sm btn-outline-light")
),
plotlyOutput("tax_bar", height = "600px")
),
layout_columns(
col_widths = c(6, 6),
card(
card_header("Genus Total Counts"),
plotlyOutput("tax_counts", height = "500px")
),
card(
card_header("Genus Prevalence"),
plotlyOutput("tax_prevalence", height = "500px")
)
)
)
),
# ── Pathogenomics Heatmap tab ──────────────────────────────────────────────
nav_panel(
title = "Pathogenomics",
icon = icon("disease"),
value = "patho_tab",
layout_sidebar(
sidebar = sidebar(
title = "Options",
selectInput("patho_db", "Database",
choices = c("All", "ARGs (CARD)" = "card",
"Virulence (VFDB)" = "vfdb",
"MGEs (PlasmidFinder)" = "plasmidfinder")),
sliderInput("patho_min_tpm", "Min TPM threshold",
min = 0, max = 500, value = 10, step = 10),
width = 250
),
card(
card_header(
class = "d-flex justify-content-between align-items-center",
"Gene Presence / Abundance Heatmap",
actionButton("expand_patho_heatmap", label = NULL, icon = icon("expand"),
class = "btn btn-sm btn-outline-light")
),
plotOutput("patho_heatmap", height = "700px")
),
layout_columns(
col_widths = c(6, 6),
card(
card_header("Alpha Diversity of Genetic Elements"),
plotlyOutput("patho_alpha", height = "400px")
),
card(
card_header("Gene Summary Table"),
DTOutput("patho_table")
)
)
)
),
# ── Summary Report tab ──────────────────────────────────────────────────────
nav_panel(
title = "Summary Report",
icon = icon("file-medical"),
value = "summary_tab",
layout_sidebar(
sidebar = sidebar(
title = "Options",
sliderInput("summary_top_n", "Top N species", min = 3, max = 20,
value = 5, step = 1),
conditionalPanel(
condition = "output.is_clinician == true",
selectInput("summary_filter_id", "Research ID",
choices = c("All" = "All", valid_patient_ids)),
hr(),
downloadButton("download_clinician_pdf", "Download Clinical Report",
class = "btn-primary w-100",
icon = icon("file-pdf"))
),
conditionalPanel(
condition = "output.is_clinician != true",
hr(),
downloadButton("download_patient_pdf", "Download Your Report",
class = "btn-primary w-100",
icon = icon("file-pdf"))
),
width = 250
),
card(
card_header("Top Species & Drug Resistance Profile"),
DTOutput("summary_species_table")
),
layout_columns(
col_widths = c(6, 6),
card(
card_header("Species Abundance"),
plotlyOutput("summary_species_bar", height = "450px")
),
card(
card_header("Drug Resistance Classes"),
plotlyOutput("summary_drug_bar", height = "450px")
)
)
)
),
# ── Nav spacer + footer ────────────────────────────────────────────────────
nav_spacer(),
nav_item(
tags$span(style = "color:#2EC4B6; font-size:0.8em;",
"E-Breathomics v0.1")
)
)