Browse code

Two file app

JoanFernandez authored on 06/02/2018 16:30:41
Showing4 changed files

... ...
@@ -1,5 +1,5 @@
1 1
 Package: GSVA
2
-Version: 1.27.0
2
+Version: 1.27.1
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"),
6 6
new file mode 100644
... ...
@@ -0,0 +1,268 @@
1
+library(GSVA)
2
+library(shiny)
3
+library(shinythemes)
4
+library(geneplotter)
5
+library(GSEABase)
6
+library(GSVAdata)
7
+library(limma)
8
+
9
+argumentsDataInput <- function(id) {
10
+  # Create a namespace function using the provided id
11
+  ns <- NS(id)
12
+  
13
+  #UI Definition
14
+  column(
15
+    3,
16
+    conditionalPanel(
17
+      condition = "input.arg == 'yes'",
18
+      h3("Select arguments:"),
19
+      wellPanel(fluidRow(
20
+        column(
21
+          12,
22
+          selectInput("method", "Choose method:",
23
+                      c("gsva","ssgsea","zscore","plage")),
24
+          selectInput("kcdf", "Choose kcdf:",
25
+                      c("Gaussian","Poisson","none")),
26
+          radioButtons("absRanking", "abs.ranking:",
27
+                       c("False" = FALSE,
28
+                         "True" = TRUE)),
29
+          numericInput("minSz","min.sz:",value = 1),
30
+          numericInput("maxSz","max.sz (Write 0 for infinite):",value = 0),
31
+          numericInput("parallelSz","parallel.sz:",value = 0),
32
+          selectInput("parallelType", "parallel.type:",
33
+                      c("SOCK","MPI","NWS")),
34
+          radioButtons("mxDiff", "mx.diff:",
35
+                       c("True" = TRUE,
36
+                         "False" = FALSE)),
37
+          conditionalPanel(
38
+            condition = "input.method == 'gsva'",
39
+            numericInput("tau1","tau:",value = 1)
40
+          ),
41
+          conditionalPanel(
42
+            condition = "input.method == 'ssgsea'",
43
+            numericInput("tau2","tau:",value = 0.25)
44
+          ),
45
+          conditionalPanel(
46
+            condition = "input.method == 'zscore' || input.method == 'plage'"
47
+          ),
48
+          radioButtons("ssgseaNorm", "ssgsea.norm:",
49
+                       c("True" = TRUE,
50
+                         "False" = FALSE)),
51
+          radioButtons("verbose", "verbose:",
52
+                       c("True" = TRUE,
53
+                         "False" = FALSE))
54
+        )))
55
+    )
56
+  )
57
+}
58
+
59
+gsva_validation <- function(input, output, session) {
60
+  success <- FALSE #Variable to control if the GSVA variables are assigned correctly
61
+  if(input$matrixSourceType == "fileMatrix")
62
+  {
63
+    if (is.null(input$matrixFile))
64
+    {
65
+      paste("No matrix file selected!")
66
+      success <- FALSE
67
+    }
68
+    else
69
+    {
70
+      #Matrix file selected
71
+      if(input$genesetSourceType == "fileGeneset")
72
+      {
73
+        if (is.null(input$genesetFile))
74
+        {
75
+          paste("No geneSet file selected!")
76
+          success <- FALSE
77
+        }
78
+        else
79
+        {
80
+          #User selects matrix file and geneSet file
81
+          inFile <- input$matrixFile
82
+          newY <- as.matrix(read.csv(inFile$datapath, header = TRUE, sep = ",")) #Reading file as matrix
83
+          rownames(newY) <- newY[,1] #Taking the first column as rownames
84
+          newY <- newY[,-1] #Deleting the first column
85
+          inGenesetFile <- input$genesetFile
86
+          genes <- getGmt(inGenesetFile$datapath)
87
+          if(input$maxSz == 0) {
88
+            varMaxsz <- Inf
89
+          }else {
90
+            varMaxsz <- input$maxSz
91
+          }
92
+          success <- TRUE
93
+        }
94
+      }
95
+      else
96
+      {
97
+        #User selects matrix file and geneset var
98
+        inFile <- input$matrixFile
99
+        newY <- as.matrix(read.csv(inFile$datapath, header = TRUE, sep = ",")) #Reading file as matrix
100
+        rownames(newY) <- newY[,1] #Taking the first column as rownames
101
+        newY <- newY[,-1] #Deleting the first column
102
+        assign("genes",get(input$genesetVar))
103
+        if(input$maxSz == 0) {
104
+          varMaxsz <- Inf
105
+        }else {
106
+          varMaxsz <- input$maxSz
107
+        }
108
+        success <- TRUE
109
+      }
110
+    }
111
+  }
112
+  else
113
+  {
114
+    #User selects matrix varand geneset file
115
+    if(input$genesetSourceType == "fileGeneset")
116
+    {
117
+      if (is.null(input$genesetFile))
118
+      {
119
+        paste("No geneSet file selected!")
120
+        success <- FALSE
121
+      }
122
+      else
123
+      {
124
+        assign("newY",get(input$matrixVar))
125
+        inGenesetFile <- input$genesetFile
126
+        genes <- getGmt(inGenesetFile$datapath)
127
+        if(input$maxSz == 0) {
128
+          varMaxsz <- Inf
129
+        }else {
130
+          varMaxsz <- input$maxSz
131
+        }
132
+        success <- TRUE
133
+      }
134
+    }
135
+    else
136
+    {
137
+      #User selects matrix var selected and geneset var
138
+      assign("newY",get(input$matrixVar))
139
+      assign("genes",get(input$genesetVar))
140
+      if(input$maxSz == 0) {
141
+        varMaxsz <- Inf
142
+      }else {
143
+        varMaxsz <- input$maxSz
144
+      }
145
+      success <- TRUE
146
+    }
147
+  }
148
+  if(success==TRUE)
149
+  {
150
+    gsva_generation(input, output, session, newY, genes,varMaxsz)
151
+    gsva_information(input,output,session)
152
+  }
153
+}
154
+
155
+gsva_generation <- function(input, output, session, newY, genes,varMaxsz) {
156
+  x <- input$method
157
+  selectedTau <- NULL
158
+  switch (x,
159
+          "gsva" = {
160
+            selectedTau <- input$tau1
161
+          },
162
+          "ssgsea" = {
163
+            selectedTau <- input$tau2
164
+          },
165
+          "zscore" = {
166
+            selectedTau <- NULL
167
+          },
168
+          "plage" = {
169
+            selectedTau <- NULL
170
+          }
171
+  )
172
+  #GSVA Generation
173
+  withProgress(message = 'Runing GSVA', value = 0, {
174
+    incProgress(1, detail = "This may take a while...")
175
+    generated_gsva <<- gsva(newY, genes, method=input$method, kcdf=input$kcdf, abs.ranking=as.logical(input$absRanking),
176
+                            min.sz=input$minSz, max.sz=varMaxsz, parallel.sz=input$parallelSz, parallel.type=input$parallelType,
177
+                            mx.diff=as.logical(input$mxDiff), tau=selectedTau, ssgsea.norm=as.logical(input$ssgseaNorm),
178
+                            verbose=as.logical(input$verbose))
179
+  })
180
+}
181
+
182
+gsva_information <- function(input, output, session) {
183
+  if(class(generated_gsva) == "matrix")
184
+  {
185
+    resultInformation <- matrix(data = c(input$matrixVar,input$genesetVar,ncol(generated_gsva),nrow(generated_gsva)), nrow = 1, ncol = 4)
186
+    colnames(resultInformation) <- c("Matrix used","GeneSet used", "Col num", "Row num")
187
+    output$result <- renderTable(resultInformation)
188
+    output$plot <- renderPlot(multidensity(as.list(as.data.frame(generated_gsva)), legend=NA, las=1, xlab=sprintf("%s scores", input$method), main="", lwd=2))
189
+    tagList(
190
+      downloadButton('downloadData', 'Download'),
191
+      actionButton('closeSave','Save & Close')
192
+    )
193
+  }
194
+  else
195
+  {
196
+    
197
+    resultInformation <- matrix(data = c(input$matrixVar,input$genesetVar,ncol(generated_gsva),nrow(generated_gsva)), nrow = 1, ncol = 4)
198
+    colnames(resultInformation) <- c("Matrix used","GeneSet used", "Col num", "Row num")
199
+    output$result <- renderTable(resultInformation)
200
+    if(class(generated_gsva) == "ExpressionSet") #If the generated gsva is an ExpressionSet
201
+    {
202
+      expressionSetObs <- exprs(generated_gsva)
203
+      output$plot <- renderPlot(multidensity(as.list(as.data.frame(expressionSetObs)), legend=NA, las=1, xlab=sprintf("%s scores", input$method), main="", lwd=2)) 
204
+    }
205
+    else
206
+    {
207
+      output$plot <- renderPlot(multidensity(as.list(as.data.frame(generated_gsva)), legend=NA, las=1, xlab=sprintf("%s scores", input$method), main="", lwd=2))
208
+    }
209
+    tagList(
210
+      downloadButton('downloadData', 'Download'),
211
+      actionButton('closeSave','Save & Close')
212
+    )
213
+  }
214
+}
215
+
216
+download_handler <- function(input, output, session) {
217
+  #Controls the Download button
218
+  output$downloadData <- downloadHandler(
219
+    filename = function() {
220
+      paste("gsva_es-", Sys.Date(), ".csv", sep="")
221
+    },
222
+    content = function(file) {
223
+      if(class(generated_gsva) == "matrix") #If the whole object is a matrix
224
+      {
225
+        dataFrameObs <- as.data.frame(generated_gsva)
226
+        write.csv(dataFrameObs, file)
227
+      }
228
+      else
229
+      {
230
+        if(class(generated_gsva) == "ExpressionSet") #If the generated gsva result value is an ExpressionSet
231
+        {
232
+          expressionSetObs <- exprs(generated_gsva)
233
+          dataFrameObs <- as.data.frame(expressionSetObs)
234
+          write.csv(dataFrameObs, file)
235
+        }
236
+        else
237
+        {
238
+          dataFrameObs <- as.data.frame(generated_gsva)
239
+          write.csv(dataFrameObs, file)
240
+        } 
241
+      }
242
+    }
243
+  )
244
+}
245
+
246
+function(input, output, session) {
247
+ v <- reactiveValues(action = FALSE)
248
+  
249
+  observeEvent(input$button, {
250
+    v$action <- input$button
251
+  })
252
+  
253
+  output$download <- renderUI({
254
+    if(v$action)
255
+    {
256
+      #Isolates the Run event, that allows the program to run the generation only if the user clicks the button.
257
+      isolate({
258
+        gsva_validation(input,output,session)
259
+      })
260
+    }
261
+  })
262
+  download_handler(input,output,session)
263
+  
264
+  #Observe the Save & Close button
265
+  observeEvent(input$closeSave, {
266
+    stopApp(generated_gsva) #Stops the app and returns the generated_gsva object
267
+  })
268
+}
0 269
\ No newline at end of file
1 270
new file mode 100644
... ...
@@ -0,0 +1,138 @@
1
+library(shiny)
2
+library(shinythemes)
3
+
4
+selectDataInput <- function(id) {
5
+  # Create a namespace function using the provided id
6
+  ns <- NS(id)
7
+  
8
+  #UI declaration
9
+  column(
10
+    3,
11
+    h3("Select data source:"),
12
+    #Select data source
13
+    wellPanel(fluidRow(
14
+      column(
15
+        12,
16
+        #Select matrix
17
+        radioButtons("matrixSourceType", "Select matrix:",
18
+                     c("From file" = "fileMatrix",
19
+                       "From workspace" = "varMatrix"))
20
+        ,
21
+        #If the selected data source is a file
22
+        conditionalPanel(
23
+          condition = "input.matrixSourceType == 'fileMatrix'",
24
+          fileInput("matrixFile", "Choose matrix file:",
25
+                    accept = c(
26
+                      "text/csv",
27
+                      "text/comma-separated-values,text/plain",
28
+                      ".csv",".ods",".xls",".xlt")
29
+          )
30
+        ),
31
+        #If the selected data source is a workspace object
32
+        conditionalPanel(
33
+          condition = "input.matrixSourceType == 'varMatrix'",
34
+          selectInput("matrixVar", "Choose matrix var:",
35
+                      ls(envir=.GlobalEnv))
36
+        ),
37
+        fluidRow(column(12,
38
+                        HTML("<br>"))),
39
+        #Select geneset
40
+        radioButtons("genesetSourceType", "Select GeneSet:",
41
+                     c("From file" = "fileGeneset",
42
+                       "From workspace" = "varGeneset"))
43
+        ,
44
+        #If the selected data source is a file
45
+        conditionalPanel(
46
+          condition = "input.genesetSourceType == 'fileGeneset'",
47
+          fileInput("genesetFile", "Choose GeneSet file:",
48
+                    accept = ".gmt")
49
+        ),
50
+        #If the selected data source is a workspace object
51
+        conditionalPanel(
52
+          condition = "input.genesetSourceType == 'varGeneset'",
53
+          selectInput("genesetVar", "Choose GeneSet var:",
54
+                      ls(envir=.GlobalEnv))
55
+        ),
56
+        HTML("<br>"),
57
+        radioButtons("arg", "Control arguments:",
58
+                     c("No" = "no",
59
+                       "Yes" = "yes"))
60
+      )
61
+    ),
62
+    actionButton("button", "Run"))
63
+  )
64
+}
65
+
66
+mainDataInput <- function(id) {
67
+  # Create a namespace function using the provided id
68
+  ns <- NS(id)
69
+  
70
+  #UI Definition
71
+  mainPanel(width = 6,
72
+            h2("Generated GSVA data:"),
73
+            textOutput("information"),
74
+            plotOutput("plot"),
75
+            tableOutput("result"),
76
+            uiOutput("download"))
77
+}
78
+
79
+argumentsDataInput <- function(id) {
80
+  # Create a namespace function using the provided id
81
+  ns <- NS(id)
82
+  
83
+  #UI Definition
84
+  column(
85
+    3,
86
+    conditionalPanel(
87
+      condition = "input.arg == 'yes'",
88
+      h3("Select arguments:"),
89
+      wellPanel(fluidRow(
90
+        column(
91
+          12,
92
+          selectInput("method", "Choose method:",
93
+                      c("gsva","ssgsea","zscore","plage")),
94
+          selectInput("kcdf", "Choose kcdf:",
95
+                      c("Gaussian","Poisson","none")),
96
+          radioButtons("absRanking", "abs.ranking:",
97
+                       c("False" = FALSE,
98
+                         "True" = TRUE)),
99
+          numericInput("minSz","min.sz:",value = 1),
100
+          numericInput("maxSz","max.sz (Write 0 for infinite):",value = 0),
101
+          numericInput("parallelSz","parallel.sz:",value = 0),
102
+          selectInput("parallelType", "parallel.type:",
103
+                      c("SOCK","MPI","NWS")),
104
+          radioButtons("mxDiff", "mx.diff:",
105
+                       c("True" = TRUE,
106
+                         "False" = FALSE)),
107
+          conditionalPanel(
108
+            condition = "input.method == 'gsva'",
109
+            numericInput("tau1","tau:",value = 1)
110
+          ),
111
+          conditionalPanel(
112
+            condition = "input.method == 'ssgsea'",
113
+            numericInput("tau2","tau:",value = 0.25)
114
+          ),
115
+          conditionalPanel(
116
+            condition = "input.method == 'zscore' || input.method == 'plage'"
117
+          ),
118
+          radioButtons("ssgseaNorm", "ssgsea.norm:",
119
+                       c("True" = TRUE,
120
+                         "False" = FALSE)),
121
+          radioButtons("verbose", "verbose:",
122
+                       c("True" = TRUE,
123
+                         "False" = FALSE))
124
+        )))
125
+    )
126
+  )
127
+}
128
+
129
+fluidPage(theme = shinytheme("simplex"),	
130
+	fluidRow(
131
+	  selectDataInput("dataInput"),
132
+	  mainDataInput("mainInput")
133
+	  ,
134
+	  fluidRow(
135
+	    argumentsDataInput("argumentsInput")
136
+	  )
137
+	)
138
+)
0 139
\ No newline at end of file
... ...
@@ -8,353 +8,6 @@
8 8
 #' @export
9 9
 #'
10 10
 
11
-selectDataInput <- function(id) {
12
-  # Create a namespace function using the provided id
13
-  ns <- NS(id)
14
-  
15
-  #UI declaration
16
-  column(
17
-    3,
18
-    h3("Select data source:"),
19
-    #Select data source
20
-    wellPanel(fluidRow(
21
-      column(
22
-        12,
23
-        #Select matrix
24
-        radioButtons("matrixSourceType", "Select matrix:",
25
-                     c("From file" = "fileMatrix",
26
-                       "From workspace" = "varMatrix"))
27
-        ,
28
-        #If the selected data source is a file
29
-        conditionalPanel(
30
-          condition = "input.matrixSourceType == 'fileMatrix'",
31
-          fileInput("matrixFile", "Choose matrix file:",
32
-                    accept = c(
33
-                      "text/csv",
34
-                      "text/comma-separated-values,text/plain",
35
-                      ".csv",".ods",".xls",".xlt")
36
-          )
37
-        ),
38
-        #If the selected data source is a workspace object
39
-        conditionalPanel(
40
-          condition = "input.matrixSourceType == 'varMatrix'",
41
-          selectInput("matrixVar", "Choose matrix var:",
42
-                      ls(envir=.GlobalEnv))
43
-        ),
44
-        fluidRow(column(12,
45
-                        HTML("<br>"))),
46
-        #Select geneset
47
-        radioButtons("genesetSourceType", "Select GeneSet:",
48
-                     c("From file" = "fileGeneset",
49
-                       "From workspace" = "varGeneset"))
50
-        ,
51
-        #If the selected data source is a file
52
-        conditionalPanel(
53
-          condition = "input.genesetSourceType == 'fileGeneset'",
54
-          fileInput("genesetFile", "Choose GeneSet file:",
55
-                    accept = ".gmt")
56
-        ),
57
-        #If the selected data source is a workspace object
58
-        conditionalPanel(
59
-          condition = "input.genesetSourceType == 'varGeneset'",
60
-          selectInput("genesetVar", "Choose GeneSet var:",
61
-                      ls(envir=.GlobalEnv))
62
-        ),
63
-        HTML("<br>"),
64
-        radioButtons("arg", "Control arguments:",
65
-                     c("No" = "no",
66
-                       "Yes" = "yes"))
67
-      )
68
-    ),
69
-    actionButton("button", "Run"))
70
-  )
71
-}
72
-
73
-mainDataInput <- function(id) {
74
-  # Create a namespace function using the provided id
75
-  ns <- NS(id)
76
-  
77
-  #UI Definition
78
-  mainPanel(width = 6,
79
-            h2("Generated GSVA data:"),
80
-            textOutput("information"),
81
-            plotOutput("plot"),
82
-            tableOutput("result"),
83
-            uiOutput("download"))
84
-}
85
-
86
-argumentsDataInput <- function(id) {
87
-  # Create a namespace function using the provided id
88
-  ns <- NS(id)
89
-  
90
-  #UI Definition
91
-  column(
92
-    3,
93
-    conditionalPanel(
94
-      condition = "input.arg == 'yes'",
95
-      h3("Select arguments:"),
96
-      wellPanel(fluidRow(
97
-        column(
98
-          12,
99
-          selectInput("method", "Choose method:",
100
-                      c("gsva","ssgsea","zscore","plage")),
101
-          selectInput("kcdf", "Choose kcdf:",
102
-                      c("Gaussian","Poisson","none")),
103
-          radioButtons("absRanking", "abs.ranking:",
104
-                       c("False" = FALSE,
105
-                         "True" = TRUE)),
106
-          numericInput("minSz","min.sz:",value = 1),
107
-          numericInput("maxSz","max.sz (Write 0 for infinite):",value = 0),
108
-          numericInput("parallelSz","parallel.sz:",value = 0),
109
-          selectInput("parallelType", "parallel.type:",
110
-                      c("SOCK","MPI","NWS")),
111
-          radioButtons("mxDiff", "mx.diff:",
112
-                       c("True" = TRUE,
113
-                         "False" = FALSE)),
114
-          conditionalPanel(
115
-            condition = "input.method == 'gsva'",
116
-            numericInput("tau1","tau:",value = 1)
117
-          ),
118
-          conditionalPanel(
119
-            condition = "input.method == 'ssgsea'",
120
-            numericInput("tau2","tau:",value = 0.25)
121
-          ),
122
-          conditionalPanel(
123
-            condition = "input.method == 'zscore' || input.method == 'plage'"
124
-          ),
125
-          radioButtons("ssgseaNorm", "ssgsea.norm:",
126
-                       c("True" = TRUE,
127
-                         "False" = FALSE)),
128
-          radioButtons("verbose", "verbose:",
129
-                       c("True" = TRUE,
130
-                         "False" = FALSE))
131
-        )))
132
-    )
133
-  )
134
-}
135
-
136
-gsva_validation <- function(input, output, session) {
137
-  success <- FALSE #Variable to control if the GSVA variables are assigned correctly
138
-  if(input$matrixSourceType == "fileMatrix")
139
-  {
140
-    if (is.null(input$matrixFile))
141
-    {
142
-      paste("No matrix file selected!")
143
-      success <- FALSE
144
-    }
145
-    else
146
-    {
147
-      #Matrix file selected
148
-      if(input$genesetSourceType == "fileGeneset")
149
-      {
150
-        if (is.null(input$genesetFile))
151
-        {
152
-          paste("No geneSet file selected!")
153
-          success <- FALSE
154
-        }
155
-        else
156
-        {
157
-          #User selects matrix file and geneSet file
158
-          inFile <- input$matrixFile
159
-          newY <- as.matrix(read.csv(inFile$datapath, header = TRUE, sep = ",")) #Reading file as matrix
160
-          rownames(newY) <- newY[,1] #Taking the first column as rownames
161
-          newY <- newY[,-1] #Deleting the first column
162
-          inGenesetFile <- input$genesetFile
163
-          genes <- getGmt(inGenesetFile$datapath)
164
-          if(input$maxSz == 0) {
165
-            varMaxsz <- Inf
166
-          }else {
167
-            varMaxsz <- input$maxSz
168
-          }
169
-          success <- TRUE
170
-        }
171
-      }
172
-      else
173
-      {
174
-        #User selects matrix file and geneset var
175
-        inFile <- input$matrixFile
176
-        newY <- as.matrix(read.csv(inFile$datapath, header = TRUE, sep = ",")) #Reading file as matrix
177
-        rownames(newY) <- newY[,1] #Taking the first column as rownames
178
-        newY <- newY[,-1] #Deleting the first column
179
-        assign("genes",get(input$genesetVar))
180
-        if(input$maxSz == 0) {
181
-          varMaxsz <- Inf
182
-        }else {
183
-          varMaxsz <- input$maxSz
184
-        }
185
-        success <- TRUE
186
-      }
187
-    }
188
-  }
189
-  else
190
-  {
191
-    #User selects matrix varand geneset file
192
-    if(input$genesetSourceType == "fileGeneset")
193
-    {
194
-      if (is.null(input$genesetFile))
195
-      {
196
-        paste("No geneSet file selected!")
197
-        success <- FALSE
198
-      }
199
-      else
200
-      {
201
-        assign("newY",get(input$matrixVar))
202
-        inGenesetFile <- input$genesetFile
203
-        genes <- getGmt(inGenesetFile$datapath)
204
-        if(input$maxSz == 0) {
205
-          varMaxsz <- Inf
206
-        }else {
207
-          varMaxsz <- input$maxSz
208
-        }
209
-        success <- TRUE
210
-      }
211
-    }
212
-    else
213
-    {
214
-      #User selects matrix var selected and geneset var
215
-      assign("newY",get(input$matrixVar))
216
-      assign("genes",get(input$genesetVar))
217
-      if(input$maxSz == 0) {
218
-        varMaxsz <- Inf
219
-      }else {
220
-        varMaxsz <- input$maxSz
221
-      }
222
-      success <- TRUE
223
-    }
224
-  }
225
-  if(success==TRUE)
226
-  {
227
-    gsva_generation(input, output, session, newY, genes,varMaxsz)
228
-    gsva_information(input,output,session)
229
-  }
230
-}
231
-
232
-gsva_generation <- function(input, output, session, newY, genes,varMaxsz) {
233
-  x <- input$method
234
-  selectedTau <- NULL
235
-  switch (x,
236
-          "gsva" = {
237
-            selectedTau <- input$tau1
238
-          },
239
-          "ssgsea" = {
240
-            selectedTau <- input$tau2
241
-          },
242
-          "zscore" = {
243
-            selectedTau <- NULL
244
-          },
245
-          "plage" = {
246
-            selectedTau <- NULL
247
-          }
248
-  )
249
-  #GSVA Generation
250
-  withProgress(message = 'Runing GSVA', value = 0, {
251
-    incProgress(1, detail = "This may take a while...")
252
-    generated_gsva <<- gsva(newY, genes, method=input$method, kcdf=input$kcdf, abs.ranking=as.logical(input$absRanking),
253
-                            min.sz=input$minSz, max.sz=varMaxsz, parallel.sz=input$parallelSz, parallel.type=input$parallelType,
254
-                            mx.diff=as.logical(input$mxDiff), tau=selectedTau, ssgsea.norm=as.logical(input$ssgseaNorm),
255
-                            verbose=as.logical(input$verbose))
256
-  })
257
-}
258
-
259
-gsva_information <- function(input, output, session) {
260
-  if(class(generated_gsva) == "matrix")
261
-  {
262
-    resultInformation <- matrix(data = c(input$matrixVar,input$genesetVar,ncol(generated_gsva),nrow(generated_gsva)), nrow = 1, ncol = 4)
263
-    colnames(resultInformation) <- c("Matrix used","GeneSet used", "Col num", "Row num")
264
-    output$result <- renderTable(resultInformation)
265
-    output$plot <- renderPlot(multidensity(as.list(as.data.frame(generated_gsva)), legend=NA, las=1, xlab=sprintf("%s scores", input$method), main="", lwd=2))
266
-    tagList(
267
-      downloadButton('downloadData', 'Download'),
268
-      actionButton('closeSave','Save & Close')
269
-    )
270
-  }
271
-  else
272
-  {
273
-
274
-    resultInformation <- matrix(data = c(input$matrixVar,input$genesetVar,ncol(generated_gsva),nrow(generated_gsva)), nrow = 1, ncol = 4)
275
-    colnames(resultInformation) <- c("Matrix used","GeneSet used", "Col num", "Row num")
276
-    output$result <- renderTable(resultInformation)
277
-    if(class(generated_gsva) == "ExpressionSet") #If the generated gsva is an ExpressionSet
278
-    {
279
-      expressionSetObs <- exprs(generated_gsva)
280
-      output$plot <- renderPlot(multidensity(as.list(as.data.frame(expressionSetObs)), legend=NA, las=1, xlab=sprintf("%s scores", input$method), main="", lwd=2)) 
281
-    }
282
-    else
283
-    {
284
-      output$plot <- renderPlot(multidensity(as.list(as.data.frame(generated_gsva)), legend=NA, las=1, xlab=sprintf("%s scores", input$method), main="", lwd=2))
285
-    }
286
-    tagList(
287
-      downloadButton('downloadData', 'Download'),
288
-      actionButton('closeSave','Save & Close')
289
-    )
290
-  }
291
-}
292
-
293
-download_handler <- function(input, output, session) {
294
-  #Controls the Download button
295
-  output$downloadData <- downloadHandler(
296
-    filename = function() {
297
-      paste("gsva_es-", Sys.Date(), ".csv", sep="")
298
-    },
299
-    content = function(file) {
300
-      if(class(generated_gsva) == "matrix") #If the whole object is a matrix
301
-      {
302
-        dataFrameObs <- as.data.frame(generated_gsva)
303
-        write.csv(dataFrameObs, file)
304
-      }
305
-      else
306
-      {
307
-        if(class(generated_gsva) == "ExpressionSet") #If the generated gsva result value is an ExpressionSet
308
-        {
309
-          expressionSetObs <- exprs(generated_gsva)
310
-          dataFrameObs <- as.data.frame(expressionSetObs)
311
-          write.csv(dataFrameObs, file)
312
-        }
313
-        else
314
-        {
315
-          dataFrameObs <- as.data.frame(generated_gsva)
316
-          write.csv(dataFrameObs, file)
317
-        } 
318
-      }
319
-    }
320
-  )
321
-}
322
-
323 11
 igsva <- function() {
324
-  app <- list(ui = NULL, server = NULL)
325
-  app$ui <- fluidPage(theme = shinytheme("simplex"),
326
-                      fluidRow(
327
-                        selectDataInput("dataInput"),
328
-                        mainDataInput("mainInput")
329
-                        ,
330
-                        fluidRow(
331
-                          argumentsDataInput("argumentsInput")
332
-                        )
333
-                      )
334
-  )
335
-  
336
-  app$server <- function(input, output, session) {
337
-    v <- reactiveValues(action = FALSE)
338
-    
339
-    observeEvent(input$button, {
340
-      v$action <- input$button
341
-    })
342
-    
343
-    output$download <- renderUI({
344
-      if(v$action)
345
-      {
346
-        #Isolates the Run event, that allows the program to run the generation only if the user clicks the button.
347
-        isolate({
348
-          gsva_validation(input,output,session)
349
-        })
350
-      }
351
-    })
352
-    download_handler(input,output,session)
353
-    
354
-    #Observe the Save & Close button
355
-    observeEvent(input$closeSave, {
356
-      stopApp(generated_gsva) #Stops the app and returns the generated_gsva object
357
-    })
358
-  }
359
-  runApp(app)
360
-}
12
+  runApp("GSVA/R/app")
13
+}
361 14
\ No newline at end of file