Browse code

fixing btn and plot2 errors

pablo-rodr-bio2 authored on 15/04/2021 14:12:31
Showing5 changed files

... ...
@@ -10,7 +10,11 @@ downloadServer <- function(id, gs){
10 10
       #Controls the Download button
11 11
       
12 12
       observe({
13
-        
13
+        if(is.null(gs())){
14
+          hide("downloadData")
15
+        } else {
16
+          show("downloadData")
17
+        }
14 18
       })
15 19
       
16 20
       output$downloadData <- downloadHandler(
... ...
@@ -18,15 +22,15 @@ downloadServer <- function(id, gs){
18 22
           paste("gsva_es-", Sys.Date(), ".csv", sep="")
19 23
         },
20 24
         content = function(file) {
21
-            if("ExpressionSet" %in% class(gs)) 
25
+            if("ExpressionSet" %in% class(gs())) 
22 26
             {
23
-              expressionSetObs <- exprs(gs)
27
+              expressionSetObs <- exprs(gs())
24 28
               dataFrameObs <- as.data.frame(expressionSetObs)
25 29
               write.csv(dataFrameObs, file)
26 30
             }
27 31
             else
28 32
             {
29
-              dataFrameObs <- as.data.frame(gs)
33
+              dataFrameObs <- as.data.frame(gs())
30 34
               write.csv(dataFrameObs, file)
31 35
             } 
32 36
         }
... ...
@@ -10,7 +10,7 @@ library(future)
10 10
 library(promises)
11 11
 library(shinyjs)
12 12
 library(shinybusy)
13
-plan(multisession, gc=TRUE)
13
+plan(multisession)
14 14
 source("argumentsDataModule.R")
15 15
 source("modalGSVAModule.R")
16 16
 source("downloadModule.R")
... ...
@@ -11,11 +11,11 @@ modalGSVAUI <- function(id){
11 11
   )
12 12
 }
13 13
 
14
-modalGSVAServer <- function(id, console.text, gsva.cancel){
14
+modalGSVAServer <- function(id, console.text, gsva.cancel, rout){
15 15
   moduleServer(
16 16
     id,
17 17
     function(input, output, session){
18
-      
18
+
19 19
       output$text <- renderText({
20 20
         req(console.text())
21 21
         max <- length(console.text())
... ...
@@ -29,7 +29,11 @@ modalGSVAServer <- function(id, console.text, gsva.cancel){
29 29
       observeEvent(input$cancel, {
30 30
         removeModal()
31 31
         gsva.cancel(TRUE)
32
-        plan(multisession, gc=TRUE)
32
+        write("", file=rout)
33
+        # changing plan() is the only and recommended way to safely 'interrupt' a future process:
34
+        # https://github.com/HenrikBengtsson/future/issues/93
35
+        plan(sequential)
36
+        plan(multisession)
33 37
       })
34 38
     }
35 39
   )
... ...
@@ -9,6 +9,7 @@ plot2_Server <- function(id, eventData1, rv){
9 9
     function(input, output, session){
10 10
       
11 11
       output$plot2 <- renderPlotly({
12
+        req(eventData1())
12 13
         rv$sample.c <- colnames(rv$gs)[eventData1()]
13 14
         data <- rv$dat.t[Sample==rv$sample.c]
14 15
         p <- ggplot(data = data, aes(x=value, color=Sample)) +
... ...
@@ -89,7 +89,7 @@ function(input, output, session) {
89 89
   })
90 90
   
91 91
   # PRINTING CONSOLE.TEXT
92
-  modalGSVAServer("modal.text", console.text, gsva.cancel)
92
+  modalGSVAServer("modal.text", console.text, gsva.cancel, rout)
93 93
   
94 94
   # PLOT1 RENDER
95 95
   plot1_Server("plot1", rv)
... ...
@@ -113,7 +113,7 @@ function(input, output, session) {
113 113
   plot3_Server("plot3", eventData2, rv, rv$matrix, rv$genesets)
114 114
   
115 115
   # DWN BTN
116
-  downloadServer("download", rv$gs)
116
+  downloadServer("download", reactive(rv$gs))
117 117
   
118 118
   # CLOSE BTN
119 119
   closeBtnServer("close", reactive(rv$gs))