International Rice Research Institute commited on
Commit
975d741
Β·
verified Β·
1 Parent(s): 331a80a

Update app.R

Browse files
Files changed (1) hide show
  1. app.R +184 -141
app.R CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  library(shiny)
2
  library(shinyjs)
3
  library(tidyverse)
@@ -8,9 +12,7 @@ library(emmeans)
8
  library(plotly)
9
  library(shinyWidgets)
10
  library(ggplot2)
11
- library(colourpicker) # Added for colourInput
12
-
13
- # UI with updated styling, now including Descriptive Statistics and color options
14
  ui <- fluidPage(
15
  useShinyjs(),
16
  tags$head(
@@ -36,6 +38,8 @@ ui <- fluidPage(
36
  background: var(--background);
37
  color: var(--dark);
38
  overflow-x: hidden;
 
 
39
  }
40
 
41
  .container-fluid {
@@ -44,6 +48,12 @@ ui <- fluidPage(
44
  margin: 0 auto;
45
  }
46
 
 
 
 
 
 
 
47
  .section {
48
  margin-bottom: 30px;
49
  background: var(--card-bg);
@@ -53,14 +63,6 @@ ui <- fluidPage(
53
  border: 1px solid rgba(30, 58, 138, 0.2);
54
  }
55
 
56
- h1, h2, h3 {
57
- color: var(--primary);
58
- border-bottom: 2px solid var(--secondary);
59
- padding-bottom: 10px;
60
- margin-bottom: 20px;
61
- font-weight: 700;
62
- }
63
-
64
  .chart-container {
65
  position: relative;
66
  margin-bottom: 20px;
@@ -118,9 +120,7 @@ ui <- fluidPage(
118
  background: var(--card-bg);
119
  color: var(--dark);
120
  padding: 2rem;
121
- height: 100vh;
122
- position: fixed;
123
- width: 280px;
124
  box-shadow: 5px 0 15px rgba(0,0,0,0.1);
125
  border-right: 1px solid var(--primary);
126
  }
@@ -164,11 +164,10 @@ ui <- fluidPage(
164
  }
165
 
166
  .main-content {
167
- margin-left: 280px;
168
  padding: 20px;
169
  width: calc(100% - 280px);
170
- min-height: 100vh;
171
- background: var(--background);
172
  }
173
 
174
  .loader {
@@ -273,163 +272,208 @@ ui <- fluidPage(
273
  margin-bottom: 10px;
274
  color: var(--primary);
275
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
276
  "))
277
  ),
278
  div(
279
  class = "app-wrapper",
 
280
  div(
281
- class = "sidebar",
282
  div(
283
- class = "sidebar-header",
284
- h3("πŸ“Š Phenotypic Data Analysis", style = "margin: 0; font-weight: 600; color: white;")
285
  ),
286
- selectInput("lme4_selected_trait", "Select Trait for Detailed Analysis", choices = c()),
287
- checkboxInput("lme4_include_interaction", "Include Environment:Genotype Interaction", value = FALSE),
288
-
289
- # Color customization options
290
  div(
291
  class = "color-picker-container",
292
- div(class = "color-picker-title", "🎨 Plot Colors"),
293
- colourpicker::colourInput("color_primary", "Primary Color", value = "#1E3A8A"),
294
- colourpicker::colourInput("color_secondary", "Secondary Color", value = "#6B8E23"),
295
- colourpicker::colourInput("color_accent", "Accent Color", value = "#4169E1"),
296
- colourpicker::colourInput("color_highlight", "Highlight Color", value = "#FF8C00"),
297
- actionButton("apply_colors", "Apply Colors", class = "btn-primary", style = "width: 100%;")
298
- ),
299
-
300
- div(
301
- class = "sidebar-content",
302
  div(
303
- class = "nav flex-column", id = "lme4-v-pills-tab", role = "tablist",
304
- tags$a(class = "nav-link active", `data-toggle` = "pill", href = "#lme4-upload", role = "tab",
305
- icon("file-upload", class = "fas"), "πŸ“€ Upload Data"),
306
- tags$a(class = "nav-link", `data-toggle` = "pill", href = "#lme4-descriptives", role = "tab",
307
- icon("chart-line", class = "fas"), "πŸ“Š Descriptive Statistics"),
308
- tags$a(class = "nav-link", `data-toggle` = "pill", href = "#lme4-blues", role = "tab",
309
- icon("chart-bar", class = "fas"), "πŸ“ˆ Predicted Means"),
310
- tags$a(class = "nav-link", `data-toggle` = "pill", href = "#lme4-correlations", role = "tab",
311
- icon("link", class = "fas"), "πŸ”— Trait Correlations")
312
  ),
313
- hr(style = "border-color: rgba(255,255,255,0.1);"),
314
- div(
315
- style = "padding: 15px; color: var(--light); font-size: 12px; text-align: center;",
316
- p("LME4 Analysis Dashboard v1.1"),
317
- p("Β© 2023 Statistical Genetics Lab")
318
- )
319
  )
320
  ),
 
321
  div(
322
- class = "main-content",
 
323
  div(
324
- class = "tab-content",
325
  div(
326
- class = "tab-pane fade show active", id = "lme4-upload", role = "tabpanel",
 
 
 
 
 
 
327
  div(
328
- class = "section",
329
- h2("πŸ“€ Upload Your Data"),
330
- div(
331
- class = "upload-container",
332
- div(class = "upload-icon", icon("cloud-upload-alt", class = "fas")),
333
- h3("πŸ“ Drag and drop your Excel file here", style = "color: var(--primary);"),
334
- p("or", style = "margin: 10px 0;"),
335
- fileInput("lme4_file", NULL, accept = c(".xlsx", ".xls"),
336
- buttonLabel = "Browse Files", placeholder = "No file selected"),
337
- p("πŸ“ Supported formats: .xlsx, .xls", style = "color: var(--light); font-size: 14px;"),
338
- div(id = "lme4_loader", class = "loader hidden")
339
- ),
340
- verbatimTextOutput("lme4_data_preview"),
341
- verbatimTextOutput("lme4_debug_log"),
342
- div(
343
- id = "lme4_data_stats", class = "hidden",
344
- h3("πŸ“Š Data Overview"),
345
- fluidRow(
346
- column(3, div(class = "status-card card-1",
347
- icon("columns", class = "fas"),
348
- h4(textOutput("lme4_n_vars"), style = "font-weight: 600;"),
349
- p("Variables")
350
- )),
351
- column(3, div(class = "status-card card-2",
352
- icon("list", class = "fas"),
353
- h4(textOutput("lme4_n_obs"), style = "font-weight: 600;"),
354
- p("Observations")
355
- )),
356
- column(3, div(class = "status-card card-3",
357
- icon("dna", class = "fas"),
358
- h4(textOutput("lme4_n_geno"), style = "font-weight: 600;"),
359
- p("Genotypes")
360
- )),
361
- column(3, div(class = "status-card card-4",
362
- icon("globe", class = "fas"),
363
- h4(textOutput("lme4_n_env"), style = "font-weight: 600;"),
364
- p("Environments")
365
- ))
366
- )
367
- )
368
  )
369
- ),
 
 
 
 
370
  div(
371
- class = "tab-pane fade", id = "lme4-descriptives", role = "tabpanel",
372
  div(
373
- class = "section",
374
- h2("πŸ“Š Descriptive Statistics"),
375
  div(
376
- id = "lme4_descriptives_content",
377
- div(class = "table-container", DTOutput("lme4_descriptives_table")),
378
- div(class = "chart-container", plotlyOutput("lme4_descriptives_plot", height = "500px")),
 
 
 
 
 
 
 
 
 
 
 
379
  div(
380
- class = "insights",
381
- h4("πŸ’‘ Interpretation"),
382
- p("Descriptive statistics provide an overview of central tendency, variability, and range for each trait. Coefficient of Variation (CV) indicates relative variability; lower CV suggests more consistent data across observations.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
383
  )
384
- ),
385
- div(
386
- id = "lme4_descriptives_placeholder", class = "text-center",
387
- icon("chart-line", class = "fas", style = "font-size: 72px; color: var(--light); margin: 30px 0;"),
388
- h4("πŸ“€ Upload data to see descriptive statistics", style = "color: var(--light);")
389
  )
390
- )
391
- ),
392
- div(
393
- class = "tab-pane fade", id = "lme4-blues", role = "tabpanel",
394
  div(
395
- class = "section",
396
- h2("πŸ“ˆ Predicted Means (BLUEs)"),
397
  div(
398
- id = "lme4_blues_content",
399
- div(class = "chart-container", plotlyOutput("lme4_blues_plot", height = "500px")),
400
- div(class = "table-container", DTOutput("lme4_blues_table")),
401
  div(
402
- class = "insights",
403
- h4("πŸ’‘ Interpretation"),
404
- p("The GΓ—E interaction plot shows genotype performance across environments. Stable genotypes have consistent values, while environment-specific genotypes vary. Use for selecting broadly adapted or specific genotypes.")
 
 
 
 
 
 
 
 
 
 
405
  )
406
- ),
407
- div(
408
- id = "lme4_blues_placeholder", class = "text-center",
409
- icon("chart-bar", class = "fas", style = "font-size: 72px; color: var(--light; margin: 30px 0;"),
410
- h4("πŸ“€ Upload data to see predicted means", style = "color: var(--light);")
411
  )
412
- )
413
- ),
414
- div(
415
- class = "tab-pane fade", id = "lme4-correlations", role = "tabpanel",
416
  div(
417
- class = "section",
418
- h2("πŸ”— Trait Correlations"),
419
  div(
420
- id = "lme4_correlations_content",
421
- div(class = "chart-container", plotlyOutput("lme4_correlation_plot", height = "600px")),
422
- div(class = "table-container", DTOutput("lme4_cor_table")),
 
 
 
 
 
 
 
 
 
423
  div(
424
- class = "insights",
425
- h4("πŸ’‘ Interpretation"),
426
- p("Correlations reveal trait synergies or trade-offs. Positive correlations (near 1) suggest traits improve together; negative correlations (near -1) indicate trade-offs.")
427
  )
428
- ),
 
 
 
429
  div(
430
- id = "lme4_correlations_placeholder", class = "text-center",
431
- icon("link", class = "fas", style = "font-size: 72px; color: var(--light); margin: 30px 0;"),
432
- h4("πŸ“€ Upload data to see trait correlations", style = "color: var(--light);")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
433
  )
434
  )
435
  )
@@ -437,7 +481,6 @@ ui <- fluidPage(
437
  )
438
  )
439
  )
440
-
441
  # Server function
442
  server <- function(input, output, session) {
443
  # LME4 Analysis Reactive Values
 
1
+ # UI with updated styling, including separate Color Selection Dashboard
2
+ # UI with updated styling to enable scrolling
3
+
4
+
5
  library(shiny)
6
  library(shinyjs)
7
  library(tidyverse)
 
12
  library(plotly)
13
  library(shinyWidgets)
14
  library(ggplot2)
15
+ library(colourpicker)
 
 
16
  ui <- fluidPage(
17
  useShinyjs(),
18
  tags$head(
 
38
  background: var(--background);
39
  color: var(--dark);
40
  overflow-x: hidden;
41
+ overflow-y: auto; /* Enable vertical scrolling */
42
+ margin: 0;
43
  }
44
 
45
  .container-fluid {
 
48
  margin: 0 auto;
49
  }
50
 
51
+ .app-wrapper {
52
+ display: flex;
53
+ flex-direction: column;
54
+ min-height: 100vh; /* Ensure wrapper takes at least full viewport height */
55
+ }
56
+
57
  .section {
58
  margin-bottom: 30px;
59
  background: var(--card-bg);
 
63
  border: 1px solid rgba(30, 58, 138, 0.2);
64
  }
65
 
 
 
 
 
 
 
 
 
66
  .chart-container {
67
  position: relative;
68
  margin-bottom: 20px;
 
120
  background: var(--card-bg);
121
  color: var(--dark);
122
  padding: 2rem;
123
+ width: 280px; /* Fixed width for sidebar */
 
 
124
  box-shadow: 5px 0 15px rgba(0,0,0,0.1);
125
  border-right: 1px solid var(--primary);
126
  }
 
164
  }
165
 
166
  .main-content {
167
+ flex: 1; /* Allow main content to take remaining space */
168
  padding: 20px;
169
  width: calc(100% - 280px);
170
+ margin-left: 280px; /* Offset for sidebar */
 
171
  }
172
 
173
  .loader {
 
272
  margin-bottom: 10px;
273
  color: var(--primary);
274
  }
275
+
276
+ .color-dashboard {
277
+ background: var(--card-bg);
278
+ padding: 2rem;
279
+ margin-bottom: 20px;
280
+ border-radius: 15px;
281
+ box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
282
+ border: 1px solid rgba(30, 58, 138, 0.2);
283
+ width: 100%;
284
+ }
285
+
286
+ .color-dashboard-header {
287
+ padding: 15px;
288
+ background: linear-gradient(135deg, var(--primary), var(--info));
289
+ text-align: center;
290
+ border-radius: 10px;
291
+ margin-bottom: 20px;
292
+ color: white;
293
+ }
294
+
295
+ .color-picker-row {
296
+ display: flex;
297
+ flex-wrap: wrap;
298
+ gap: 15px;
299
+ justify-content: space-between;
300
+ }
301
+
302
+ .color-picker-item {
303
+ flex: 1;
304
+ min-width: 150px;
305
+ }
306
  "))
307
  ),
308
  div(
309
  class = "app-wrapper",
310
+ # Color Selection Dashboard
311
  div(
312
+ class = "color-dashboard",
313
  div(
314
+ class = "color-dashboard-header",
315
+ h3("🎨 Plot Color Customization", style = "margin: 0; font-weight: 600; color: white;")
316
  ),
 
 
 
 
317
  div(
318
  class = "color-picker-container",
319
+ div(class = "color-picker-title", "Select Plot Colors"),
 
 
 
 
 
 
 
 
 
320
  div(
321
+ class = "color-picker-row",
322
+ div(class = "color-picker-item", colourpicker::colourInput("color_primary", "Primary Color", value = "#1E3A8A")),
323
+ div(class = "color-picker-item", colourpicker::colourInput("color_secondary", "Secondary Color", value = "#6B8E23")),
324
+ div(class = "color-picker-item", colourpicker::colourInput("color_accent", "Accent Color", value = "#4169E1")),
325
+ div(class = "color-picker-item", colourpicker::colourInput("color_highlight", "Highlight Color", value = "#FF8C00"))
 
 
 
 
326
  ),
327
+ actionButton("apply_colors", "Apply Colors", class = "btn-primary", style = "width: 100%; margin-top: 15px;")
 
 
 
 
 
328
  )
329
  ),
330
+ # Main layout with sidebar and content
331
  div(
332
+ style = "display: flex; flex-direction: row;",
333
+ # Sidebar
334
  div(
335
+ class = "sidebar",
336
  div(
337
+ class = "sidebar-header",
338
+ h3("πŸ“Š Phenotypic Data Analysis", style = "margin: 0; font-weight: 600; color: white;")
339
+ ),
340
+ selectInput("lme4_selected_trait", "Select Trait for Detailed Analysis", choices = c()),
341
+ checkboxInput("lme4_include_interaction", "Include Environment:Genotype Interaction", value = FALSE),
342
+ div(
343
+ class = "sidebar-content",
344
  div(
345
+ class = "nav flex-column", id = "lme4-v-pills-tab", role = "tablist",
346
+ tags$a(class = "nav-link active", `data-toggle` = "pill", href = "#lme4-upload", role = "tab",
347
+ icon("file-upload", class = "fas"), "πŸ“€ Upload Data"),
348
+ tags$a(class = "nav-link", `data-toggle` = "pill", href = "#lme4-descriptives", role = "tab",
349
+ icon("chart-line", class = "fas"), "πŸ“Š Descriptive Statistics"),
350
+ tags$a(class = "nav-link", `data-toggle` = "pill", href = "#lme4-blues", role = "tab",
351
+ icon("chart-bar", class = "fas"), "πŸ“ˆ Predicted Means"),
352
+ tags$a(class = "nav-link", `data-toggle` = "pill", href = "#lme4-correlations", role = "tab",
353
+ icon("link", class = "fas"), "πŸ”— Trait Correlations")
354
+ ),
355
+ hr(style = "border-color: rgba(255,255,255,0.1);"),
356
+ div(
357
+ style = "padding: 15px; color: var(--light); font-size: 12px; text-align: center;",
358
+ p("LME4 Analysis Dashboard v1.1"),
359
+ p("Β© 2023 Statistical Genetics Lab")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
360
  )
361
+ )
362
+ ),
363
+ # Main content
364
+ div(
365
+ class = "main-content",
366
  div(
367
+ class = "tab-content",
368
  div(
369
+ class = "tab-pane fade show active", id = "lme4-upload", role = "tabpanel",
 
370
  div(
371
+ class = "section",
372
+ h2("πŸ“€ Upload Your Data"),
373
+ div(
374
+ class = "upload-container",
375
+ div(class = "upload-icon", icon("cloud-upload-alt", class = "fas")),
376
+ h3("πŸ“ Drag and drop your Excel file here", style = "color: var(--primary);"),
377
+ p("or", style = "margin: 10px 0;"),
378
+ fileInput("lme4_file", NULL, accept = c(".xlsx", ".xls"),
379
+ buttonLabel = "Browse Files", placeholder = "No file selected"),
380
+ p("πŸ“ Supported formats: .xlsx, .xls", style = "color: var(--light); font-size: 14px;"),
381
+ div(id = "lme4_loader", class = "loader hidden")
382
+ ),
383
+ verbatimTextOutput("lme4_data_preview"),
384
+ verbatimTextOutput("lme4_debug_log"),
385
  div(
386
+ id = "lme4_data_stats", class = "hidden",
387
+ h3("πŸ“Š Data Overview"),
388
+ fluidRow(
389
+ column(3, div(class = "status-card card-1",
390
+ icon("columns", class = "fas"),
391
+ h4(textOutput("lme4_n_vars"), style = "font-weight: 600;"),
392
+ p("Variables")
393
+ )),
394
+ column(3, div(class = "status-card card-2",
395
+ icon("list", class = "fas"),
396
+ h4(textOutput("lme4_n_obs"), style = "font-weight: 600;"),
397
+ p("Observations")
398
+ )),
399
+ column(3, div(class = "status-card card-3",
400
+ icon("dna", class = "fas"),
401
+ h4(textOutput("lme4_n_geno"), style = "font-weight: 600;"),
402
+ p("Genotypes")
403
+ )),
404
+ column(3, div(class = "status-card card-4",
405
+ icon("globe", class = "fas"),
406
+ h4(textOutput("lme4_n_env"), style = "font-weight: 600;"),
407
+ p("Environments")
408
+ ))
409
+ )
410
  )
 
 
 
 
 
411
  )
412
+ ),
 
 
 
413
  div(
414
+ class = "tab-pane fade", id = "lme4-descriptives", role = "tabpanel",
 
415
  div(
416
+ class = "section",
417
+ h2("πŸ“Š Descriptive Statistics"),
 
418
  div(
419
+ id = "lme4_descriptives_content",
420
+ div(class = "table-container", DTOutput("lme4_descriptives_table")),
421
+ div(class = "chart-container", plotlyOutput("lme4_descriptives_plot", height = "500px")),
422
+ div(
423
+ class = "insights",
424
+ h4("πŸ’‘ Interpretation"),
425
+ p("Descriptive statistics provide an overview of central tendency, variability, and range for each trait. Coefficient of Variation (CV) indicates relative variability; lower CV suggests more consistent data across observations.")
426
+ )
427
+ ),
428
+ div(
429
+ id = "lme4_descriptives_placeholder", class = "text-center",
430
+ icon("chart-line", class = "fas", style = "font-size: 72px; color: var(--light); margin: 30px 0;"),
431
+ h4("πŸ“€ Upload data to see descriptive statistics", style = "color: var(--light);")
432
  )
 
 
 
 
 
433
  )
434
+ ),
 
 
 
435
  div(
436
+ class = "tab-pane fade", id = "lme4-blues", role = "tabpanel",
 
437
  div(
438
+ class = "section",
439
+ h2("πŸ“ˆ Predicted Means (BLUEs)"),
440
+ div(
441
+ id = "lme4_blues_content",
442
+ div(class = "chart-container", plotlyOutput("lme4_blues_plot", height = "500px")),
443
+ div(class = "table-container", DTOutput("lme4_blues_table")),
444
+ div(
445
+ class = "insights",
446
+ h4("πŸ’‘ Interpretation"),
447
+ p("The GΓ—E interaction plot shows genotype performance across environments. Stable genotypes have consistent values, while environment-specific genotypes vary. Use for selecting broadly adapted or specific genotypes.")
448
+ )
449
+ ),
450
  div(
451
+ id = "lme4_blues_placeholder", class = "text-center",
452
+ icon("chart-bar", class = "fas", style = "font-size: 72px; color: var(--light); margin: 30px 0;"),
453
+ h4("πŸ“€ Upload data to see predicted means", style = "color: var(--light);")
454
  )
455
+ )
456
+ ),
457
+ div(
458
+ class = "tab-pane fade", id = "lme4-correlations", role = "tabpanel",
459
  div(
460
+ class = "section",
461
+ h2("πŸ”— Trait Correlations"),
462
+ div(
463
+ id = "lme4_correlations_content",
464
+ div(class = "chart-container", plotlyOutput("lme4_correlation_plot", height = "600px")),
465
+ div(class = "table-container", DTOutput("lme4_cor_table")),
466
+ div(
467
+ class = "insights",
468
+ h4("πŸ’‘ Interpretation"),
469
+ p("Correlations reveal trait synergies or trade-offs. Positive correlations (near 1) suggest traits improve together; negative correlations (near -1) indicate trade-offs.")
470
+ )
471
+ ),
472
+ div(
473
+ id = "lme4_correlations_placeholder", class = "text-center",
474
+ icon("link", class = "fas", style = "font-size: 72px; color: var(--light); margin: 30px 0;"),
475
+ h4("πŸ“€ Upload data to see trait correlations", style = "color: var(--light);")
476
+ )
477
  )
478
  )
479
  )
 
481
  )
482
  )
483
  )
 
484
  # Server function
485
  server <- function(input, output, session) {
486
  # LME4 Analysis Reactive Values