Browse code

changed x label in plot1 and plot2 for selected method

pablo-rodr-bio2 authored on 28/04/2021 07:59:37
Showing5 changed files

... ...
@@ -12,7 +12,7 @@ argumentsDataUI <- function(id) {
12 12
         column(
13 13
           12,
14 14
           selectInput(ns("method"), "Choose method:",
15
-                      c("gsva","ssgsea","zscore","plage")),
15
+                      choices = methodChoices),
16 16
           selectInput(ns("kcdf"), "Choose kcdf:",
17 17
                       c("Gaussian","Poisson","none")),
18 18
           radioButtons(ns("absRanking"), "abs.ranking:",
... ...
@@ -20,4 +20,9 @@ source("plot3_Module.R")
20 20
 source("matrixModule.R")
21 21
 source("geneSetsModule.R")
22 22
 source("argumentsDataModule.R")
23
-source("closeModule.R")
24 23
\ No newline at end of file
24
+source("closeModule.R")
25
+
26
+methodChoices <- c( "GSVA" = "gsva",
27
+                    "ssGSEA" = "ssgsea",
28
+                    "zscore" = "zscore",
29
+                    "PLAGE" = "plage")
25 30
\ No newline at end of file
... ...
@@ -10,9 +10,14 @@ plot1_Server <- function(id, rv){
10 10
       
11 11
       output$plot <- renderPlotly({
12 12
         req(rv$dat.t)
13
+        # in order to print the name of the method (and not the 
14
+        # selected value from the method) on the 'x' label, this
15
+        # name is retrieved from the list 'methodChoices' declared
16
+        # in 'global.R
17
+        method <- names(methodChoices)[methodChoices == rv$method]
13 18
         rv$p <- ggplot(data = rv$dat.t, aes(x=value, color=Sample)) +
14 19
           stat_density(geom="line", position = "identity") +
15
-          theme(legend.position = "none") + labs(x="GSVA Scores", y="Density") +
20
+          theme(legend.position = "none") + labs(x=paste0(method, " Scores"), y="Density") +
16 21
           scale_color_manual("Legend", values = rv$dd.col)
17 22
         ggplotly(rv$p, tooltip = "Sample", source = "click1")
18 23
       })
... ...
@@ -10,11 +10,18 @@ plot2_Server <- function(id, eventData1, rv){
10 10
       
11 11
       output$plot2 <- renderPlotly({
12 12
         req(eventData1())
13
+        
14
+        # in order to print the name of the method (and not the 
15
+        # selected value from the method) on the 'x' label, this
16
+        # name is retrieved from the list 'methodChoices' declared
17
+        # in 'global.R
18
+        method <- names(methodChoices)[methodChoices == rv$method]
19
+        
13 20
         rv$sample.c <- colnames(rv$gs)[eventData1()]
14 21
         data <- rv$dat.t[Sample==rv$sample.c]
15 22
         p <- ggplot(data = data, aes(x=value, color=Sample)) +
16 23
           stat_ecdf(geom="point") + theme(legend.position = "none") +
17
-          labs(x="GSVA Scores in selected sample", y="Empirical Cumulative Density") +
24
+          labs(x=paste0(method, " Scores in selected sample"), y="Empirical Cumulative Density") +
18 25
           scale_color_manual("Legend", values = rv$dd.col)
19 26
         rv$p2 <- ggplotly(p, source="click2") %>% style(text=data$gene.sets)
20 27
         rv$p2
... ...
@@ -22,7 +22,8 @@ function(input, output, session) {
22 22
   
23 23
   ## REACTIVE VALUES
24 24
   rv <- reactiveValues(gs=NULL, dat.t=NULL, n=NULL, dd.col=NULL, p=NULL, 
25
-                       p2=NULL, p3=NULL, errors.gsva = NULL, sample.c = NULL)
25
+                       p2=NULL, p3=NULL, errors.gsva = NULL, sample.c = NULL,
26
+                       method=NULL)
26 27
   gsva.cancel <- reactiveVal(FALSE)
27 28
   
28 29
   ## GSVA RESULT
... ...
@@ -41,6 +42,7 @@ function(input, output, session) {
41 42
     rv$p3 <- NULL
42 43
     rv$sample.c <- NULL
43 44
     rv$errors.gsva <- NULL
45
+    rv$method <- argInp$method()
44 46
     
45 47
     ## this is a flag for the future. Futures cannot be canceled or
46 48
     ## terminated in a strict way, so when they get interrupted they