Browse code

Merge branch 'pablo-rodr-bio2-shinyDashboard'

Robert Castelo authored on 18/05/2021 06:19:55
Showing11 changed files

... ...
@@ -1,5 +1,5 @@
1 1
 Package: GSVA
2
-Version: 1.39.31
2
+Version: 1.39.32
3 3
 Title: Gene Set Variation Analysis for microarray and RNA-seq data
4 4
 Authors@R: c(person("Justin", "Guinney", role=c("aut", "cre"), email="justin.guinney@sagebase.org"),
5 5
              person("Robert", "Castelo", role="aut", email="robert.castelo@upf.edu"),
... ...
@@ -11,7 +11,7 @@ Imports: methods, stats, utils, graphics, S4Vectors, IRanges,
11 11
          BiocParallel, SingleCellExperiment, sparseMatrixStats, DelayedArray,
12 12
          DelayedMatrixStats, HDF5Array, BiocSingular
13 13
 Suggests: BiocGenerics, RUnit, BiocStyle, knitr, rmarkdown, limma, RColorBrewer,
14
-          org.Hs.eg.db, genefilter, edgeR, GSVAdata, shiny, shinythemes, ggplot2,
14
+          org.Hs.eg.db, genefilter, edgeR, GSVAdata, shiny, shinydashboard, ggplot2,
15 15
           data.table, plotly, future, promises, shinybusy, shinyjs
16 16
 Description: Gene Set Variation Analysis (GSVA) is a non-parametric, unsupervised method for estimating variation of gene set enrichment through the samples of a expression data set. GSVA performs a change in coordinate systems, transforming the data from a gene by sample matrix to a gene-set by sample matrix, thereby allowing the evaluation of pathway enrichment for each sample. This new matrix of GSVA enrichment scores facilitates applying standard analytical methods like functional enrichment, survival analysis, clustering, CNV-pathway analysis or cross-tissue pathway analysis, in a pathway-centric manner.
17 17
 License: GPL (>= 2)
... ...
@@ -1,48 +1,53 @@
1 1
 igsva <- function() {
2 2
 
3
-  shinydeps <- c("shiny", "shinythemes", "ggplot2",
3
+  shinydeps <- c("shiny", "shinydashboard", "ggplot2",
4 4
                  "data.table", "plotly", "future",
5
-                 "shinyjs", "shinybusy", "limma")
5
+                 "shinyjs", "shinybusy", "limma", "magrittr")
6 6
   maskshinydeps <- shinydeps %in% installed.packages()
7 7
   if (any(!maskshinydeps))
8 8
     stop(sprintf("Please install the following packages to use the GSVA WebApp:\n\n  %s\n",
9 9
                  paste(shinydeps[!maskshinydeps], collapse=", ")))
10
-  
11
-  # namespaceImportFrom(self=getNamespace("base"),
12
-  #                     ns=getNamespace("shiny"))
13
-  # 
14
-  # namespaceImportFrom(self=getNamespace("base"),
15
-  #                     ns=getNamespace("shinythemes"),
16
-  #                     vars="shinytheme")
17
-  # 
18
-  # namespaceImportFrom(self=getNamespace("base"),
19
-  #                     ns=getNamespace("ggplot2"),
20
-  #                     vars="ggplot")
21
-  # 
22
-  # namespaceImportFrom(self=getNamespace("base"),
23
-  #                     ns=getNamespace("data.table"))
24
-  # 
25
-  # namespaceImportFrom(self=getNamespace("base"),
26
-  #                     ns=getNamespace("plotly"),
27
-  #                     vars=c("ggplotly", "event_data", "style"))
28
-  # 
29
-  # namespaceImportFrom(self=getNamespace("base"),
30
-  #                     ns=getNamespace("future"))
31
-  # 
32
-  # namespaceImportFrom(self=getNamespace("base"),
33
-  #                     ns=getNamespace("shinyjs"))
34
-  # 
35
-  # namespaceImportFrom(self=getNamespace("base"),
36
-  #                     ns=getNamespace("shinybusy"))
37
-  # 
38
-  # namespaceImportFrom(self=getNamespace("base"),
39
-  #                     ns=getNamespace("limma"))
40 10
 
41 11
   appDir <- system.file("shinyApp", package="GSVA")
42 12
   if (appDir == "")
43 13
     stop("The GSVA Shiny app cannot be found within the package.")
44 14
 
45
-  # runWebApp <- get("runApp", mode="function")
46
-  # runWebApp(appDir)
15
+
47 16
   shiny::runApp(appDir)
48 17
 }
18
+
19
+## legacy code
20
+
21
+# runWebApp <- get("runApp", mode="function")
22
+# runWebApp(appDir)
23
+
24
+
25
+# namespaceImportFrom(self=getNamespace("base"),
26
+#                     ns=getNamespace("shiny"))
27
+# 
28
+# namespaceImportFrom(self=getNamespace("base"),
29
+#                     ns=getNamespace("shinythemes"),
30
+#                     vars="shinytheme")
31
+# 
32
+# namespaceImportFrom(self=getNamespace("base"),
33
+#                     ns=getNamespace("ggplot2"),
34
+#                     vars="ggplot")
35
+# 
36
+# namespaceImportFrom(self=getNamespace("base"),
37
+#                     ns=getNamespace("data.table"))
38
+# 
39
+# namespaceImportFrom(self=getNamespace("base"),
40
+#                     ns=getNamespace("plotly"),
41
+#                     vars=c("ggplotly", "event_data", "style"))
42
+# 
43
+# namespaceImportFrom(self=getNamespace("base"),
44
+#                     ns=getNamespace("future"))
45
+# 
46
+# namespaceImportFrom(self=getNamespace("base"),
47
+#                     ns=getNamespace("shinyjs"))
48
+# 
49
+# namespaceImportFrom(self=getNamespace("base"),
50
+#                     ns=getNamespace("shinybusy"))
51
+# 
52
+# namespaceImportFrom(self=getNamespace("base"),
53
+#                     ns=getNamespace("limma"))
49 54
\ No newline at end of file
... ...
@@ -9,30 +9,28 @@ argumentsDataUI <- function(id) {
9 9
       column(
10 10
         width = 12,
11 11
         align = "center",
12
-        h3("Parameters", style="font-weight: bold")
12
+        h4("PARAMETERS", style="font-weight: bold")
13 13
       )
14 14
     ),
15
-    wellPanel(
16
-      
17
-      selectInput(ns("method"), "Choose method:",
15
+    wellPanel( id= "args-well",
16
+      selectInput(ns("method"), "Method",
18 17
                   choices = methodChoices),
19
-      selectInput(ns("kcdf"), "Choose kcdf:",
18
+      selectInput(ns("kcdf"), "kcdf",
20 19
                   c("Gaussian","Poisson","none")),
21 20
       radioButtons(ns("absRanking"), "abs.ranking:",
22 21
                    c("False" = FALSE,
23 22
                      "True" = TRUE)),
24
-      numericInput(ns("minSz"),"min.sz:", value = 1),
25
-      numericInput(ns("maxSz"),"max.sz (Write 0 for infinite):", value = 0),
26
-      radioButtons(ns("mxDiff"), "mx.diff:",
23
+      numericInput(ns("minSz"),"min.sz", value = 1),
24
+      numericInput(ns("maxSz"),"max.sz (Write 0 for infinite)", value = 0),
25
+      radioButtons(ns("mxDiff"), "mx.diff",
27 26
                    c("True" = TRUE,
28 27
                      "False" = FALSE)),
29
-      numericInput(ns("tau"),"tau:", value = 1),
28
+      numericInput(ns("tau"),"tau", value = 1),
30 29
       radioButtons(ns("ssgseaNorm"), "ssgsea.norm:",
31 30
                    c("True" = TRUE,
32 31
                      "False" = FALSE))
33 32
     )
34 33
   )
35
-  
36 34
 }
37 35
 
38 36
 argumentsDataServer <- function(id){
... ...
@@ -1,12 +1,8 @@
1 1
 closeBtnUI <- function(id){
2 2
   ns <- NS(id)
3
-  hidden(actionButton(ns("closeSave"), "Save & Close", style = "color: #fff;
4
-  font-weight: bold;
5
-  background-color: red;
6
-  border-color: #fff;
7
-  width:130;
8
-  padding: 5px 5px 5px 5px;
9
-  margin: 5px 5px 5px 5px; "))
3
+  hidden(actionButton(ns("closeSave"), "SAVE & CLOSE", 
4
+                      icon = icon("window-close"),
5
+                      width = "10vw"))
10 6
 }
11 7
 
12 8
 closeBtnServer <- function(id, gs){
... ...
@@ -1,11 +1,7 @@
1 1
 downloadUI <- function(id) {
2 2
   ns <- NS(id)
3
-  hidden(downloadButton(ns('downloadData'), 'Download', style = "color: #fff;
4
-  font-weight: bold;
5
-  background-color: #27ae60;
6
-  border-color: #fff;
7
-  padding: 5px 14px 5px 14px;
8
-  margin: 5px 5px 5px 5px;" ))
3
+  hidden(
4
+    downloadButton(ns('downloadData'), 'DOWNLOAD')) 
9 5
 }
10 6
 
11 7
 downloadServer <- function(id, gs){
... ...
@@ -1,8 +1,9 @@
1 1
 geneSetsUI <- function(id){
2 2
   ns <- NS(id)
3
-  tagList(
4
-    radioButtons(ns("genesetSourceType"), "Select gene sets:",
5
-                 c("From file" = "fileGeneset",
3
+  div( id = ns("genesets-input"),
4
+    radioButtons(ns("genesetSourceType"), 
5
+                 label = h5("GENE SETS", style="font-weight: bold"),
6
+                 choices = c("From file" = "fileGeneset",
6 7
                    "From workspace" = "varGeneset")),
7 8
     conditionalPanel(
8 9
       condition = "input.genesetSourceType == 'fileGeneset'", ns = ns,
... ...
@@ -1,3 +1,4 @@
1
+### LOADING LIBRARIES
1 2
 library(shiny)
2 3
 library(shinythemes)
3 4
 library(plotly)
... ...
@@ -11,7 +12,17 @@ library(promises)
11 12
 library(shinyjs)
12 13
 library(shinybusy)
13 14
 library(shinydashboard)
15
+
16
+### there seems to be a problem with the DT package colliding with plotly
17
+### so first check if the package is loaded and if it is, unload it
18
+if("DT" %in% (.packages())) {
19
+  detach("package:DT", unload=TRUE)
20
+}
21
+
22
+### setting plan for futures
14 23
 plan(multisession)
24
+
25
+### sourcing all modules
15 26
 source("argumentsDataModule.R")
16 27
 source("modalGSVAModule.R")
17 28
 source("downloadModule.R")
... ...
@@ -23,6 +34,7 @@ source("geneSetsModule.R")
23 34
 source("argumentsDataModule.R")
24 35
 source("closeModule.R")
25 36
 
37
+### setting a global in "method" choices for gsva()
26 38
 methodChoices <- c( "GSVA" = "gsva",
27 39
                     "ssGSEA" = "ssgsea",
28 40
                     "zscore" = "zscore",
... ...
@@ -1,8 +1,9 @@
1 1
 matrixUI <- function(id){
2 2
   ns <- NS(id)
3
-  tagList(
4
-    radioButtons(ns("matrixSourceType"), "Select expression data matrix:",
5
-                 c("From file" = "fileMatrix",
3
+  div(id = ns("matrix-input"),
4
+    radioButtons(ns("matrixSourceType"),
5
+                 label = h5("EXPRESSION DATA MATRIX", style="font-weight: bold"),
6
+                 choices = c("From file" = "fileMatrix",
6 7
                    "From workspace" = "varMatrix")),
7 8
     conditionalPanel(
8 9
       condition = "input.matrixSourceType == 'fileMatrix'", ns = ns,
... ...
@@ -181,14 +181,17 @@ function(input, output, session) {
181 181
   
182 182
   # CLOSE BTN
183 183
   closeBtnServer("close", reactive(rv$gs))
184
-
184
+  
185 185
   
186 186
   # TEXT1
187 187
   output$text1 <- renderUI({
188 188
     req(rv$gs)
189
-    HTML(paste("<br/>", "\t To see the Empirical Cumulative Distribution Function 
190
-    of a Sample, click on its line in this plot and go
191
-      to the 'Gene.Set' Panel", "<br/>", sep="<br/>"))
189
+    tagList(
190
+      br(),
191
+      div("To see the Empirical Cumulative Distribution Function 
192
+      of a Sample, click on its line in this plot and go to the 
193
+      'Gene.Set' Panel", style="text-align: center;")
194
+    )
192 195
   })
193 196
   
194 197
   # TABLE
... ...
@@ -197,7 +200,7 @@ function(input, output, session) {
197 200
     resultInformation <- data.frame("Nr of gene sets" = nrow(rv$gs),
198 201
                                     "Nr of samples" = ncol(rv$gs))
199 202
     resultInformation
200
-  })
203
+  }, bordered = TRUE)
201 204
   
202 205
   # TEXT2
203 206
   output$text2 <- renderUI({
... ...
@@ -207,9 +210,12 @@ function(input, output, session) {
207 210
   
208 211
   # TEXT3
209 212
   output$text3 <- renderUI({
210
-    HTML(paste("<br/>", "\t To see the Kernel Density Estimation of genes of 
211
-    any given Gene Set in this Sample,  click on any point in this plot and a
212
-    second plot will appear bellow it", "<br/>", sep="<br/>"))
213
+    tagList(
214
+      br(),
215
+      div("To see the Kernel Density Estimation of genes of any given
216
+      Gene Set in this Sample,  click on any point in this plot and a
217
+      second plot will appear bellow it", style = "text-align: center;")
218
+    )
213 219
   })
214
-
220
+  
215 221
 }
... ...
@@ -12,32 +12,31 @@ dashboardPage(
12 12
     tags$head(
13 13
       tags$link(rel = "stylesheet", type = "text/css", href = "style.css")
14 14
     ),
15
-    fluidRow(
16
-      column(
17
-        width = 12,
18
-        align = "center",
19
-        h3("Data Input", style="font-weight: bold")
20
-      )
21
-    ),
22
-    # h3("Data input"),
15
+    div(h3("DATA INPUT", style="font-weight: bold"), align = "center"),
16
+    br(),
23 17
     matrixUI("matrix1"),
24 18
     br(),
25 19
     geneSetsUI("genes1"),
26 20
     br(),
27
-    radioButtons("arg", "Change default settings:",
21
+    radioButtons(inputId = "arg",
22
+                 label = h5("CHANGE DEFAULT SETTINGS?", style="font-weight: bold"),
28 23
                  c("No" = "no",
29 24
                    "Yes" = "yes")),
30 25
     br(),
31 26
     fluidRow(
32
-      actionButton("button", "Run"),
33
-      downloadUI("download"),
34
-      closeBtnUI("close"),
27
+      column(
28
+        width = 12, align = "left",
29
+        actionButton("button", "RUN", class = "run-btn", icon = icon("play-circle"),
30
+                     width = "10vw"),
31
+        downloadUI("download"),
32
+        closeBtnUI("close")
33
+      )
35 34
     )
36 35
   ),
37 36
   
38 37
   dashboardBody(
39 38
     shinyjs::useShinyjs(),
40
-    add_busy_spinner(spin = "double-bounce", position = "bottom-right",
39
+    add_busy_spinner(spin = "cube-grid", position = "bottom-right",
41 40
                      height = "100px", width = "100px"),
42 41
     fluidRow(
43 42
       box(
... ...
@@ -47,7 +46,14 @@ dashboardPage(
47 46
                              textOutput("errorsGsva"),
48 47
                              htmlOutput("text1"),
49 48
                              plot1_UI("plot1"),
50
-                             tableOutput("result")
49
+                             br(),
50
+                             fluidRow(
51
+                               column(
52
+                                 width = 12,
53
+                                 align = "center",
54
+                                 tableOutput("result")
55
+                               )
56
+                             )
51 57
                     ),
52 58
                     tabPanel("GeneSets",
53 59
                              uiOutput("text2"),
... ...
@@ -1,6 +1,7 @@
1
-#errorsGsva{color: red;
2
-font-size: 20px;
3
-font-weight: bold;
1
+#errorsGsva {
2
+  color: red;
3
+  font-size: 20px;
4
+  font-weight: bold;
4 5
 }
5 6
 
6 7
 #title_gsva {
... ...
@@ -11,6 +12,46 @@ font-weight: bold;
11 12
   color: white;
12 13
   font-weight: bold;
13 14
   font-size: 30px;
15
+  padding: 5px 5px 5px 5px;
16
+  margin: 5px 5px 5px 5px;
17
+}
18
+
19
+#matrix1-matrix-input, #genes1-genesets-input, #arg {
20
+  background-color: #708090;
21
+  border-radius: 15px;
22
+  padding-bottom: 5px;
23
+}
24
+
25
+#matrix1-matrixSourceType-label, #genes1-genesetSourceType-label, #arg-label {
26
+  background-color: #6495ED;
27
+  display: inline-block;
28
+  text-align: center;
29
+  width: 100%;
30
+  border-radius: 15px;
31
+}
32
+
33
+#args-well {
34
+  background: #708090;
35
+  color: white;
36
+}
37
+
38
+#download-downloadData {
39
+  color: #fff;
40
+  background-color: #27ae60;
41
+  font-weight: bold;
42
+  border-color: #fff;
43
+  padding: 5px 14px 5px 14px;
44
+  margin: 6px 5px 6px 15px;
45
+  width: 10vw;
46
+}
47
+
48
+#close-closeSave{
49
+  color: #fff;
50
+  background-color: red;
51
+  font-weight: bold;
52
+  border-color: #fff;
53
+  padding: 5px 5px 5px 5px;
54
+  margin: 6px 5px 6px 15px;
14 55
 }
15 56
 
16 57
 .left-side, .main-sidebar {
... ...
@@ -26,13 +67,11 @@ font-weight: bold;
26 67
   
27 68
 }
28 69
 
29
-
30
-/**
31
-.main-header {
32
-  max-height: 75px;
33
-}
34
-
35
-.main-header .logo {
36
-  max-height: 75px;
70
+.run-btn {
71
+  color: #fff; 
72
+  background-color: #8A2BE2;
73
+  font-weight: bold;
74
+  border-color: #fff;
75
+  padding: 5px 5px 5px 5px;
76
+  margin: 5px 5px 5px 5px;
37 77
 }
38
-**/
39 78
\ No newline at end of file