... | ... |
@@ -1,5 +1,5 @@ |
1 | 1 |
Package: GSVA |
2 |
-Version: 1.39.24 |
|
2 |
+Version: 1.39.25 |
|
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"), |
... | ... |
@@ -12,7 +12,7 @@ Imports: methods, stats, utils, graphics, S4Vectors, IRanges, |
12 | 12 |
DelayedMatrixStats, HDF5Array, BiocSingular |
13 | 13 |
Suggests: BiocGenerics, RUnit, BiocStyle, knitr, rmarkdown, limma, RColorBrewer, |
14 | 14 |
org.Hs.eg.db, genefilter, edgeR, GSVAdata, shiny, shinythemes, ggplot2, |
15 |
- data.table, plotly |
|
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) |
18 | 18 |
VignetteBuilder: knitr |
... | ... |
@@ -1,35 +1,48 @@ |
1 | 1 |
igsva <- function() { |
2 | 2 |
|
3 | 3 |
shinydeps <- c("shiny", "shinythemes", "ggplot2", |
4 |
- "data.table", "plotly") |
|
4 |
+ "data.table", "plotly", "future", |
|
5 |
+ "shinyjs", "shinybusy", "limma") |
|
5 | 6 |
maskshinydeps <- shinydeps %in% installed.packages() |
6 | 7 |
if (any(!maskshinydeps)) |
7 |
- stop(sprintf("Please install the following packages to use the GenomiScores WebApp:\n\n %s\n", |
|
8 |
+ stop(sprintf("Please install the following packages to use the GSVA WebApp:\n\n %s\n", |
|
8 | 9 |
paste(shinydeps[!maskshinydeps], collapse=", "))) |
9 | 10 |
|
10 |
- namespaceImportFrom(self=getNamespace("base"), |
|
11 |
- ns=getNamespace("shiny")) |
|
12 |
- |
|
13 |
- namespaceImportFrom(self=getNamespace("base"), |
|
14 |
- ns=getNamespace("shinythemes"), |
|
15 |
- vars="shinytheme") |
|
16 |
- |
|
17 |
- namespaceImportFrom(self=getNamespace("base"), |
|
18 |
- ns=getNamespace("ggplot2"), |
|
19 |
- vars="ggplot") |
|
20 |
- |
|
21 |
- namespaceImportFrom(self=getNamespace("base"), |
|
22 |
- ns=getNamespace("data.table"), |
|
23 |
- vars="as.data.table") |
|
24 |
- |
|
25 |
- namespaceImportFrom(self=getNamespace("base"), |
|
26 |
- ns=getNamespace("plotly"), |
|
27 |
- vars=c("ggplotly", "event_data", "style")) |
|
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")) |
|
28 | 40 |
|
29 | 41 |
appDir <- system.file("shinyApp", package="GSVA") |
30 | 42 |
if (appDir == "") |
31 | 43 |
stop("The GSVA Shiny app cannot be found within the package.") |
32 | 44 |
|
33 |
- runWebApp <- get("runApp", mode="function") |
|
34 |
- runWebApp(appDir) |
|
45 |
+ # runWebApp <- get("runApp", mode="function") |
|
46 |
+ # runWebApp(appDir) |
|
47 |
+ shiny::runApp(appDir) |
|
35 | 48 |
} |
36 | 49 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,79 @@ |
1 |
+argumentsDataUI <- function(id) { |
|
2 |
+ # Create a namespace function using the provided id |
|
3 |
+ ns <- NS(id) |
|
4 |
+ |
|
5 |
+ #UI Definition |
|
6 |
+ column( |
|
7 |
+ width=3, |
|
8 |
+ conditionalPanel( |
|
9 |
+ condition = "input.arg == 'yes'", |
|
10 |
+ h3("Parameters"), |
|
11 |
+ wellPanel(fluidRow( |
|
12 |
+ column( |
|
13 |
+ 12, |
|
14 |
+ selectInput(ns("method"), "Choose method:", |
|
15 |
+ c("gsva","ssgsea","zscore","plage")), |
|
16 |
+ selectInput(ns("kcdf"), "Choose kcdf:", |
|
17 |
+ c("Gaussian","Poisson","none")), |
|
18 |
+ radioButtons(ns("absRanking"), "abs.ranking:", |
|
19 |
+ c("False" = FALSE, |
|
20 |
+ "True" = TRUE)), |
|
21 |
+ numericInput(ns("minSz"),"min.sz:",value = 1), |
|
22 |
+ numericInput(ns("maxSz"),"max.sz (Write 0 for infinite):",value = 0), |
|
23 |
+ radioButtons(ns("mxDiff"), "mx.diff:", |
|
24 |
+ c("True" = TRUE, |
|
25 |
+ "False" = FALSE)), |
|
26 |
+ conditionalPanel( |
|
27 |
+ condition = "input.method == 'gsva'", ns = ns, |
|
28 |
+ numericInput(ns("tau1"),"tau:",value = 1) |
|
29 |
+ ), |
|
30 |
+ conditionalPanel( |
|
31 |
+ condition = "input.method == 'ssgsea'", ns = ns, |
|
32 |
+ numericInput(ns("tau2"),"tau:",value = 0.25), |
|
33 |
+ radioButtons(ns("ssgseaNorm"), "ssgsea.norm:", |
|
34 |
+ c("True" = TRUE, |
|
35 |
+ "False" = FALSE))) |
|
36 |
+ ))) |
|
37 |
+ ) |
|
38 |
+ ) |
|
39 |
+} |
|
40 |
+ |
|
41 |
+argumentsDataServer <- function(id){ |
|
42 |
+ moduleServer(id, function(input, output, session){ |
|
43 |
+ varMinsz <- reactive({ |
|
44 |
+ validate(need(!is.na(input$minSz), "Value 'min.sz' cannot be empty and must be an integer value")) |
|
45 |
+ input$minSz }) |
|
46 |
+ varMaxsz <- reactive({ |
|
47 |
+ validate(need(!is.na(input$maxSz), "Value 'max.sz' cannot be empty and must be an integer value")) |
|
48 |
+ ifelse(input$maxSz==0, Inf, input$maxSz) }) |
|
49 |
+ selectedTau <- reactive({ |
|
50 |
+ if(input$method == "gsva"){ |
|
51 |
+ validate(need(!is.na(input$tau1), "Value 'tau' cannot be empty and must be an integer value")) |
|
52 |
+ input$tau1 |
|
53 |
+ } else { |
|
54 |
+ if(input$method == "ssgsea"){ |
|
55 |
+ validate(need(!is.na(input$tau2), "Value 'tau' cannot be empty and must be an integer value")) |
|
56 |
+ input$tau2 |
|
57 |
+ } else { |
|
58 |
+ NULL |
|
59 |
+ } |
|
60 |
+ } |
|
61 |
+ }) |
|
62 |
+ method <- reactive({ input$method }) |
|
63 |
+ kcdf <- reactive({ input$kcdf }) |
|
64 |
+ absRanking <- reactive({ as.logical(input$absRanking) }) |
|
65 |
+ mxDiff <- reactive({ as.logical(input$mxDiff) }) |
|
66 |
+ ssgseaNorm <- reactive({ as.logical(input$ssgseaNorm) }) |
|
67 |
+ |
|
68 |
+ return(list( |
|
69 |
+ varMinsz = varMinsz, |
|
70 |
+ varMaxsz = varMaxsz, |
|
71 |
+ selectedTau = selectedTau, |
|
72 |
+ method = method, |
|
73 |
+ kcdf = kcdf, |
|
74 |
+ absRanking = absRanking, |
|
75 |
+ mxDiff = mxDiff, |
|
76 |
+ ssgseaNorm = ssgseaNorm |
|
77 |
+ )) |
|
78 |
+ }) |
|
79 |
+} |
|
0 | 80 |
\ No newline at end of file |
1 | 81 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,24 @@ |
1 |
+closeBtnUI <- function(id){ |
|
2 |
+ ns <- NS(id) |
|
3 |
+ hidden(actionButton(ns("closeSave"), "Save & Close")) |
|
4 |
+} |
|
5 |
+ |
|
6 |
+closeBtnServer <- function(id, gs){ |
|
7 |
+ moduleServer( |
|
8 |
+ id, |
|
9 |
+ function(input, output, session){ |
|
10 |
+ # SAVE & CLOSE BTN |
|
11 |
+ observe({ |
|
12 |
+ if(is.null(gs())){ |
|
13 |
+ hide("closeSave") |
|
14 |
+ } else { |
|
15 |
+ show("closeSave") |
|
16 |
+ } |
|
17 |
+ }) |
|
18 |
+ |
|
19 |
+ observeEvent(input$closeSave, { |
|
20 |
+ stopApp(gs()) #Stops the app and returns the rv$gs object to the R session |
|
21 |
+ }) |
|
22 |
+ } |
|
23 |
+ ) |
|
24 |
+} |
|
0 | 25 |
\ No newline at end of file |
1 | 26 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,40 @@ |
1 |
+downloadUI <- function(id) { |
|
2 |
+ ns <- NS(id) |
|
3 |
+ hidden(downloadButton(ns('downloadData'), 'Download')) |
|
4 |
+} |
|
5 |
+ |
|
6 |
+downloadServer <- function(id, gs){ |
|
7 |
+ moduleServer( |
|
8 |
+ id, |
|
9 |
+ function(input, output, session){ |
|
10 |
+ #Controls the Download button |
|
11 |
+ |
|
12 |
+ observe({ |
|
13 |
+ if(is.null(gs())){ |
|
14 |
+ hide("downloadData") |
|
15 |
+ } else { |
|
16 |
+ show("downloadData") |
|
17 |
+ } |
|
18 |
+ }) |
|
19 |
+ |
|
20 |
+ output$downloadData <- downloadHandler( |
|
21 |
+ filename = function() { |
|
22 |
+ paste("gsva_es-", Sys.Date(), ".csv", sep="") |
|
23 |
+ }, |
|
24 |
+ content = function(file) { |
|
25 |
+ if("ExpressionSet" %in% class(gs())) |
|
26 |
+ { |
|
27 |
+ expressionSetObs <- exprs(gs()) |
|
28 |
+ dataFrameObs <- as.data.frame(expressionSetObs) |
|
29 |
+ write.csv(dataFrameObs, file) |
|
30 |
+ } |
|
31 |
+ else |
|
32 |
+ { |
|
33 |
+ dataFrameObs <- as.data.frame(gs()) |
|
34 |
+ write.csv(dataFrameObs, file) |
|
35 |
+ } |
|
36 |
+ } |
|
37 |
+ ) |
|
38 |
+ } |
|
39 |
+ ) |
|
40 |
+} |
|
0 | 41 |
\ No newline at end of file |
1 | 42 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,44 @@ |
1 |
+geneSetsUI <- function(id){ |
|
2 |
+ ns <- NS(id) |
|
3 |
+ tagList( |
|
4 |
+ radioButtons(ns("genesetSourceType"), "Select gene sets:", |
|
5 |
+ c("From file" = "fileGeneset", |
|
6 |
+ "From workspace" = "varGeneset")), |
|
7 |
+ conditionalPanel( |
|
8 |
+ condition = "input.genesetSourceType == 'fileGeneset'", ns = ns, |
|
9 |
+ fileInput(ns("genesetFile"), "Choose GeneSet file:", |
|
10 |
+ accept = c(".gmt", "text/csv", ".csv")) |
|
11 |
+ ), |
|
12 |
+ conditionalPanel( |
|
13 |
+ condition = "input.genesetSourceType == 'varGeneset'", ns = ns, |
|
14 |
+ selectInput(ns("genesetVar"), "Choose GeneSet var:", |
|
15 |
+ ls(envir=.GlobalEnv)) |
|
16 |
+ ) |
|
17 |
+ ) |
|
18 |
+} |
|
19 |
+ |
|
20 |
+geneSetsServer <- function(id){ |
|
21 |
+ moduleServer( id, function(input, output, session){ |
|
22 |
+ geneSets <- reactive({ |
|
23 |
+ if(input$genesetSourceType == "fileGeneset"){ |
|
24 |
+ if(is.null(input$genesetFile)) return(NULL) #this is in order to disable "run" btn |
|
25 |
+ ext <- tools::file_ext(input$genesetFile$name) |
|
26 |
+ genesets <- |
|
27 |
+ switch(ext, |
|
28 |
+ csv = as.list(read.csv(input$genesetFile$datapath)), |
|
29 |
+ gmt = getGmt(input$genesetFile$datapath) |
|
30 |
+ ) |
|
31 |
+ } else { |
|
32 |
+ if(is.null(input$genesetVar)) return(NULL) |
|
33 |
+ genesets <- get(input$genesetVar) |
|
34 |
+ } |
|
35 |
+ genesets |
|
36 |
+ }) %>% bindCache({ |
|
37 |
+ if(input$genesetSourceType == "fileGeneset"){ |
|
38 |
+ input$genesetFile$name |
|
39 |
+ } else { |
|
40 |
+ input$genesetVar |
|
41 |
+ } |
|
42 |
+ }) |
|
43 |
+ }) |
|
44 |
+} |
|
0 | 45 |
\ No newline at end of file |
1 | 46 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,23 @@ |
1 |
+library(shiny) |
|
2 |
+library(shinythemes) |
|
3 |
+library(plotly) |
|
4 |
+library(GSVA) |
|
5 |
+library(GSEABase) |
|
6 |
+library(limma) |
|
7 |
+library(ggplot2) |
|
8 |
+library(data.table) |
|
9 |
+library(future) |
|
10 |
+library(promises) |
|
11 |
+library(shinyjs) |
|
12 |
+library(shinybusy) |
|
13 |
+plan(multisession) |
|
14 |
+source("argumentsDataModule.R") |
|
15 |
+source("modalGSVAModule.R") |
|
16 |
+source("downloadModule.R") |
|
17 |
+source("plot1_Module.R") |
|
18 |
+source("plot2_Module.R") |
|
19 |
+source("plot3_Module.R") |
|
20 |
+source("matrixModule.R") |
|
21 |
+source("geneSetsModule.R") |
|
22 |
+source("argumentsDataModule.R") |
|
23 |
+source("closeModule.R") |
|
0 | 24 |
\ No newline at end of file |
1 | 25 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,42 @@ |
1 |
+matrixUI <- function(id){ |
|
2 |
+ ns <- NS(id) |
|
3 |
+ tagList( |
|
4 |
+ radioButtons(ns("matrixSourceType"), "Select expression data matrix:", |
|
5 |
+ c("From file" = "fileMatrix", |
|
6 |
+ "From workspace" = "varMatrix")), |
|
7 |
+ conditionalPanel( |
|
8 |
+ condition = "input.matrixSourceType == 'fileMatrix'", ns = ns, |
|
9 |
+ fileInput(ns("matrixFile"), "Choose matrix file:", |
|
10 |
+ accept = c( |
|
11 |
+ "text/csv", |
|
12 |
+ "text/comma-separated-values,text/plain", |
|
13 |
+ ".csv",".ods",".xls",".xlt")) |
|
14 |
+ ), |
|
15 |
+ conditionalPanel( |
|
16 |
+ condition = "input.matrixSourceType == 'varMatrix'", ns= ns, |
|
17 |
+ selectInput(ns("matrixVar"), "Choose matrix var:", |
|
18 |
+ ls(envir=.GlobalEnv)) |
|
19 |
+ ) |
|
20 |
+ ) |
|
21 |
+} |
|
22 |
+ |
|
23 |
+matrixServer <- function(id){ |
|
24 |
+ moduleServer( id, function(input, output, session){ |
|
25 |
+ matrix <- reactive({ |
|
26 |
+ if(input$matrixSourceType=="fileMatrix"){ |
|
27 |
+ if(is.null(input$matrixFile)) return(NULL) #this is in order to disable "run" btn |
|
28 |
+ matrix <- data.matrix(read.csv(file=input$matrixFile$datapath, row.names = 1L)) |
|
29 |
+ } else { |
|
30 |
+ if(is.null(input$matrixVar)) return(NULL) |
|
31 |
+ matrix <- get(input$matrixVar) |
|
32 |
+ } |
|
33 |
+ matrix |
|
34 |
+ }) %>% bindCache({ |
|
35 |
+ if(input$matrixSourceType == "fileMatrix"){ |
|
36 |
+ input$matrixFile$name |
|
37 |
+ } else { |
|
38 |
+ input$matrixVar |
|
39 |
+ } |
|
40 |
+ }) |
|
41 |
+ }) |
|
42 |
+} |
|
0 | 43 |
\ No newline at end of file |
1 | 44 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,40 @@ |
1 |
+modalGSVAUI <- function(id){ |
|
2 |
+ ns <- NS(id) |
|
3 |
+ showModal( |
|
4 |
+ modalDialog( |
|
5 |
+ size="l", |
|
6 |
+ title = "GSVA calculations", |
|
7 |
+ div(id="install.text", "Calculating, please wait... "), |
|
8 |
+ div(p("\n")), |
|
9 |
+ verbatimTextOutput(ns("text")), |
|
10 |
+ footer = actionButton(ns("cancel"), "Cancel")) |
|
11 |
+ ) |
|
12 |
+} |
|
13 |
+ |
|
14 |
+modalGSVAServer <- function(id, console.text, gsva.cancel, rout){ |
|
15 |
+ moduleServer( |
|
16 |
+ id, |
|
17 |
+ function(input, output, session){ |
|
18 |
+ |
|
19 |
+ output$text <- renderText({ |
|
20 |
+ req(console.text()) |
|
21 |
+ max <- length(console.text()) |
|
22 |
+ if(max>1){ |
|
23 |
+ paste(console.text()[1], console.text()[max], sep= "\n") |
|
24 |
+ } else { |
|
25 |
+ console.text() |
|
26 |
+ } |
|
27 |
+ }) |
|
28 |
+ |
|
29 |
+ observeEvent(input$cancel, { |
|
30 |
+ removeModal() |
|
31 |
+ gsva.cancel(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) |
|
37 |
+ }) |
|
38 |
+ } |
|
39 |
+ ) |
|
40 |
+} |
|
0 | 41 |
\ No newline at end of file |
1 | 42 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,21 @@ |
1 |
+plot1_UI <- function(id){ |
|
2 |
+ ns <- NS(id) |
|
3 |
+ plotlyOutput(ns("plot")) |
|
4 |
+} |
|
5 |
+ |
|
6 |
+plot1_Server <- function(id, rv){ |
|
7 |
+ moduleServer( |
|
8 |
+ id, |
|
9 |
+ function(input, output, session){ |
|
10 |
+ |
|
11 |
+ output$plot <- renderPlotly({ |
|
12 |
+ req(rv$dat.t) |
|
13 |
+ rv$p <- ggplot(data = rv$dat.t, aes(x=value, color=Sample)) + |
|
14 |
+ stat_density(geom="line", position = "identity") + |
|
15 |
+ theme(legend.position = "none") + labs(x="GSVA Scores", y="Density") + |
|
16 |
+ scale_color_manual("Legend", values = rv$dd.col) |
|
17 |
+ ggplotly(rv$p, tooltip = "Sample", source = "click1") |
|
18 |
+ }) |
|
19 |
+ } |
|
20 |
+ ) |
|
21 |
+} |
|
0 | 22 |
\ No newline at end of file |
1 | 23 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,24 @@ |
1 |
+plot2_UI <- function(id){ |
|
2 |
+ ns <- NS(id) |
|
3 |
+ plotlyOutput(ns("plot2")) |
|
4 |
+} |
|
5 |
+ |
|
6 |
+plot2_Server <- function(id, eventData1, rv){ |
|
7 |
+ moduleServer( |
|
8 |
+ id, |
|
9 |
+ function(input, output, session){ |
|
10 |
+ |
|
11 |
+ output$plot2 <- renderPlotly({ |
|
12 |
+ req(eventData1()) |
|
13 |
+ rv$sample.c <- colnames(rv$gs)[eventData1()] |
|
14 |
+ data <- rv$dat.t[Sample==rv$sample.c] |
|
15 |
+ p <- ggplot(data = data, aes(x=value, color=Sample)) + |
|
16 |
+ stat_ecdf(geom="point") + theme(legend.position = "none") + |
|
17 |
+ labs(x="GSVA Scores in selected sample", y="Empirical Cumulative Density") + |
|
18 |
+ scale_color_manual("Legend", values = rv$dd.col) |
|
19 |
+ rv$p2 <- ggplotly(p, source="click2") %>% style(text=data$gene.sets) |
|
20 |
+ rv$p2 |
|
21 |
+ }) |
|
22 |
+ } |
|
23 |
+ ) |
|
24 |
+} |
|
0 | 25 |
\ No newline at end of file |
1 | 26 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,36 @@ |
1 |
+plot3_UI <- function(id){ |
|
2 |
+ ns <- NS(id) |
|
3 |
+ plotlyOutput(ns("plot3")) |
|
4 |
+} |
|
5 |
+ |
|
6 |
+plot3_Server <- function(id, eventData2, rv, matrix, genesets){ |
|
7 |
+ moduleServer( |
|
8 |
+ id, |
|
9 |
+ function(input, output, session){ |
|
10 |
+ output$plot3 <- renderPlotly({ |
|
11 |
+ req(eventData2()) |
|
12 |
+ selected.gene.set <- rv$p2$x$data[[1]]$text[eventData2()] |
|
13 |
+ if(is(genesets(), "GeneSetCollection")){ |
|
14 |
+ genes.toplot <- geneIds(genesets())[[selected.gene.set]] |
|
15 |
+ } else { |
|
16 |
+ genes.toplot <- genesets()[[selected.gene.set]] |
|
17 |
+ } |
|
18 |
+ mt <- match(genes.toplot, rownames(matrix())) |
|
19 |
+ x <- matrix()[na.omit(mt), rv$sample.c] |
|
20 |
+ df <- as.data.frame(x) |
|
21 |
+ df$x <- as.numeric(df$x) |
|
22 |
+ df$Gene <- rownames(df) |
|
23 |
+ df$Sample <- rv$sample.c |
|
24 |
+ rv$p3 <- ggplot(data = df, aes(x=x, color = Sample, label = Gene)) + |
|
25 |
+ stat_density(geom="line", position = "identity") + |
|
26 |
+ geom_rug() + theme(legend.position = "none") + |
|
27 |
+ labs(x="Gene Expressions in selected sample", y="Density") + |
|
28 |
+ xlim(as.numeric(range(matrix()))) + |
|
29 |
+ scale_color_manual("legend", values= rv$dd.col) |
|
30 |
+ ggplotly(rv$p3, tooltip = c("Gene", "x")) %>% style(hoverinfo="none", traces = 1) %>% |
|
31 |
+ layout(title = list(text = paste0('<br><sup><i>', selected.gene.set, '</i></sup>'), |
|
32 |
+ font = list(size=15))) |
|
33 |
+ }) |
|
34 |
+ } |
|
35 |
+ ) |
|
36 |
+} |
|
0 | 37 |
\ No newline at end of file |
... | ... |
@@ -1,361 +1,207 @@ |
1 |
-library(GSVA) |
|
2 |
-library(shiny) |
|
3 |
-library(shinythemes) |
|
4 |
-library(GSEABase) |
|
5 |
-library(GSVAdata) |
|
6 |
-library(limma) |
|
7 |
-library(ggplot2) |
|
8 |
-library(data.table) |
|
9 |
-library(plotly) |
|
10 |
- |
|
11 |
-argumentsDataInput <- function(id) { |
|
12 |
- # Create a namespace function using the provided id |
|
13 |
- ns <- NS(id) |
|
1 |
+function(input, output, session) { |
|
14 | 2 |
|
15 |
- #UI Definition |
|
16 |
- column( |
|
17 |
- 3, |
|
18 |
- conditionalPanel( |
|
19 |
- condition = "input.arg == 'yes'", |
|
20 |
- h3("Select arguments:"), |
|
21 |
- wellPanel(fluidRow( |
|
22 |
- column( |
|
23 |
- 12, |
|
24 |
- selectInput("method", "Choose method:", |
|
25 |
- c("gsva","ssgsea","zscore","plage")), |
|
26 |
- selectInput("kcdf", "Choose kcdf:", |
|
27 |
- c("Gaussian","Poisson","none")), |
|
28 |
- radioButtons("absRanking", "abs.ranking:", |
|
29 |
- c("False" = FALSE, |
|
30 |
- "True" = TRUE)), |
|
31 |
- numericInput("minSz","min.sz:",value = 1), |
|
32 |
- numericInput("maxSz","max.sz (Write 0 for infinite):",value = 0), |
|
33 |
- ## numericInput("parallelSz","parallel.sz:",value = 0), |
|
34 |
- ## selectInput("parallelType", "parallel.type:", |
|
35 |
- ## c("SOCK","MPI","NWS")), |
|
36 |
- radioButtons("mxDiff", "mx.diff:", |
|
37 |
- c("True" = TRUE, |
|
38 |
- "False" = FALSE)), |
|
39 |
- conditionalPanel( |
|
40 |
- condition = "input.method == 'gsva'", |
|
41 |
- numericInput("tau1","tau:",value = 1) |
|
42 |
- ), |
|
43 |
- conditionalPanel( |
|
44 |
- condition = "input.method == 'ssgsea'", |
|
45 |
- numericInput("tau2","tau:",value = 0.25) |
|
46 |
- ), |
|
47 |
- conditionalPanel( |
|
48 |
- condition = "input.method == 'zscore' || input.method == 'plage'" |
|
49 |
- ), |
|
50 |
- radioButtons("ssgseaNorm", "ssgsea.norm:", |
|
51 |
- c("True" = TRUE, |
|
52 |
- "False" = FALSE)), |
|
53 |
- radioButtons("verbose", "verbose:", |
|
54 |
- c("True" = TRUE, |
|
55 |
- "False" = FALSE)) |
|
56 |
- ))) |
|
57 |
- ) |
|
58 |
- ) |
|
59 |
-} |
|
60 |
- |
|
61 |
-gsva_validation <- function(input, output, session) { |
|
62 |
- success <- FALSE #Variable to control if the GSVA variables are assigned correctly |
|
63 |
- if(input$matrixSourceType == "fileMatrix") |
|
64 |
- { |
|
65 |
- if (is.null(input$matrixFile)) |
|
66 |
- { |
|
67 |
- paste("No matrix file selected!") |
|
68 |
- success <- FALSE |
|
69 |
- } |
|
70 |
- else |
|
71 |
- { |
|
72 |
- #Matrix file selected |
|
73 |
- if(input$genesetSourceType == "fileGeneset") |
|
74 |
- { |
|
75 |
- if (is.null(input$genesetFile)) |
|
76 |
- { |
|
77 |
- paste("No geneSet file selected!") |
|
78 |
- success <- FALSE |
|
79 |
- } |
|
80 |
- else |
|
81 |
- { |
|
82 |
- #User selects matrix file and geneSet file |
|
83 |
- inFile <- input$matrixFile |
|
84 |
- newY <- as.matrix(read.csv(inFile$datapath, header = TRUE, sep = ",")) #Reading file as matrix |
|
85 |
- rownames(newY) <- newY[,1] #Taking the first column as rownames |
|
86 |
- newY <- newY[,-1] #Deleting the first column |
|
87 |
- inGenesetFile <- input$genesetFile |
|
88 |
- genes <- getGmt(inGenesetFile$datapath) |
|
89 |
- if(input$maxSz == 0) { |
|
90 |
- varMaxsz <- Inf |
|
91 |
- }else { |
|
92 |
- varMaxsz <- input$maxSz |
|
93 |
- } |
|
94 |
- success <- TRUE |
|
95 |
- } |
|
96 |
- } |
|
97 |
- else |
|
98 |
- { |
|
99 |
- #User selects matrix file and geneset var |
|
100 |
- inFile <- input$matrixFile |
|
101 |
- newY <- as.matrix(read.csv(inFile$datapath, header = TRUE, sep = ",")) #Reading file as matrix |
|
102 |
- rownames(newY) <- newY[,1] #Taking the first column as rownames |
|
103 |
- newY <- newY[,-1] #Deleting the first column |
|
104 |
- assign("genes",get(input$genesetVar)) |
|
105 |
- if(input$maxSz == 0) { |
|
106 |
- varMaxsz <- Inf |
|
107 |
- }else { |
|
108 |
- varMaxsz <- input$maxSz |
|
109 |
- } |
|
110 |
- success <- TRUE |
|
111 |
- } |
|
112 |
- } |
|
113 |
- } |
|
114 |
- else |
|
115 |
- { |
|
116 |
- #User selects matrix var and geneset file |
|
117 |
- if(input$genesetSourceType == "fileGeneset") |
|
118 |
- { |
|
119 |
- if (is.null(input$genesetFile)) |
|
120 |
- { |
|
121 |
- paste("No geneSet file selected!") |
|
122 |
- success <- FALSE |
|
123 |
- } |
|
124 |
- else |
|
125 |
- { |
|
126 |
- assign("newY",get(input$matrixVar)) |
|
127 |
- inGenesetFile <- input$genesetFile |
|
128 |
- genes <- getGmt(inGenesetFile$datapath) |
|
129 |
- if(input$maxSz == 0) { |
|
130 |
- varMaxsz <- Inf |
|
131 |
- }else { |
|
132 |
- varMaxsz <- input$maxSz |
|
133 |
- } |
|
134 |
- success <- TRUE |
|
135 |
- } |
|
136 |
- } |
|
137 |
- else |
|
138 |
- { |
|
139 |
- #User selects matrix var selected and geneset var |
|
140 |
- assign("newY",get(input$matrixVar)) |
|
141 |
- assign("genes",get(input$genesetVar)) |
|
142 |
- if(input$maxSz == 0) { |
|
143 |
- varMaxsz <- Inf |
|
144 |
- }else { |
|
145 |
- varMaxsz <- input$maxSz |
|
146 |
- } |
|
147 |
- success <- TRUE |
|
148 |
- } |
|
149 |
- } |
|
150 |
- if(success==TRUE) |
|
151 |
- { |
|
152 |
- gsva_generation(input, output, session, newY, genes,varMaxsz) |
|
153 |
- gsva_information(input,output,session, newY, genes) |
|
154 |
- } |
|
155 |
-} |
|
156 |
- |
|
157 |
-gsva_generation <- function(input, output, session, newY, genes,varMaxsz) { |
|
158 |
- x <- input$method |
|
159 |
- selectedTau <- NULL |
|
160 |
- switch (x, |
|
161 |
- "gsva" = { |
|
162 |
- selectedTau <- input$tau1 |
|
163 |
- }, |
|
164 |
- "ssgsea" = { |
|
165 |
- selectedTau <- input$tau2 |
|
166 |
- }, |
|
167 |
- "zscore" = { |
|
168 |
- selectedTau <- NULL |
|
169 |
- }, |
|
170 |
- "plage" = { |
|
171 |
- selectedTau <- NULL |
|
172 |
- } |
|
173 |
- ) |
|
174 |
- # GSVA Generation |
|
175 |
- withProgress(message = 'Runing GSVA', value = 0, { |
|
176 |
- incProgress(1, detail = "This may take a while...") |
|
177 |
- generated_gsva <<- gsva(newY, genes, method=input$method, kcdf=input$kcdf, |
|
178 |
- abs.ranking=as.logical(input$absRanking), |
|
179 |
- min.sz=input$minSz, max.sz=varMaxsz, |
|
180 |
- parallel.sz=1L, ## by now, disable parallelism |
|
181 |
- mx.diff=as.logical(input$mxDiff), |
|
182 |
- tau=selectedTau, |
|
183 |
- ssgsea.norm=as.logical(input$ssgseaNorm), |
|
184 |
- verbose=as.logical(input$verbose)) |
|
185 |
- }) |
|
186 |
- |
|
187 |
-} |
|
188 |
- |
|
189 |
-gsva_information <- function(input, output, session, newY, genes) { |
|
190 |
- gsva_es <- NA |
|
191 |
- if("matrix" %in% class(generated_gsva)) |
|
192 |
- gsva_es <- as.data.frame(generated_gsva) |
|
193 |
- else if ("ExpressionSet" %in% class(generated_gsva)) |
|
194 |
- gsva_es <- as.data.frame(exprs(generated_gsva)) |
|
195 |
- else if ("SummarizedExperiment" %in% class(generated_gsva)) |
|
196 |
- gsva_es <- as.data.frame(assays(generated_gsva)[[1]]) |
|
197 |
- else |
|
198 |
- stop("Unknown output generated by the call to the 'gsva()' function.") |
|
199 |
- |
|
200 |
- #Rendering text1 |
|
201 |
- output$text1 <- renderUI({ |
|
202 |
- HTML(paste("<br/>", "\t To see the Empirical Cumulative Distribution Function |
|
203 |
- of a Sample, click on its line in this plot and go |
|
204 |
- to the 'Gene.Set' Panel", "<br/>", sep="<br/>")) |
|
205 |
- }) |
|
3 |
+ # CREATE REACTIVE FOR CONSOLE TEXT PROGRESS BAR |
|
4 |
+ rout <- tempfile("consoleText", fileext = ".txt") |
|
5 |
+ file.create(rout) |
|
6 |
+ console.text <- reactiveFileReader(200, session, rout, readLines, warn=F) |
|
206 | 7 |
|
207 |
- # Rendering graph1 |
|
208 |
- dat.t <- melt(as.data.table(generated_gsva, keep.rownames = "gene.sets"), |
|
209 |
- variable.name = "Sample", id.vars="gene.sets") |
|
210 |
- n <- length(levels(dat.t$Sample)) |
|
211 |
- dd.col <- hcl(h = seq(15, 375, length=n), l = 65, c = 100)[1:n] |
|
212 |
- names(dd.col) <- levels(dat.t$Sample) |
|
213 | 8 |
|
9 |
+ ##################### INPUTS ##################### |
|
214 | 10 |
|
215 |
- output$plot <- renderPlotly({ |
|
216 |
- p <- ggplot(data = dat.t, aes(x=value, color=Sample)) + |
|
217 |
- stat_density(geom="line", position = "identity") + |
|
218 |
- theme(legend.position = "none") + labs(x="GSVA Scores", y="Density") + |
|
219 |
- scale_color_manual("Legend", values = dd.col) |
|
220 |
- ggplotly(p, tooltip = "Sample", source = "click1") |
|
221 |
- }) |
|
11 |
+ # DATA MATRIX |
|
12 |
+ matrix <- matrixServer("matrix1") |
|
222 | 13 |
|
223 |
- # Rendering table |
|
224 |
- resultInformation <- matrix(data = c(nrow(generated_gsva), |
|
225 |
- ncol(generated_gsva)), |
|
226 |
- nrow = 1, ncol = 2) |
|
227 |
- colnames(resultInformation) <- c("Nr. of gene sets", "Nr. of samples") |
|
228 |
- output$result <- renderTable(resultInformation) |
|
14 |
+ # GENES |
|
15 |
+ genesets <- geneSetsServer("genes1") |
|
229 | 16 |
|
230 |
- #Rendering text2 |
|
231 |
- output$text2 <- renderUI({ |
|
232 |
- title1 <- sample.c() |
|
233 |
- h2(tags$b(title1), align ="center") |
|
234 |
- }) |
|
17 |
+ # ARGUMENTS |
|
18 |
+ argInp <- argumentsDataServer("argumentsInput") |
|
235 | 19 |
|
236 |
- #Rendering text3 |
|
237 |
- output$text3 <- renderUI({ |
|
238 |
- HTML(paste("<br/>", "\t To see the Kernel Density Estimation of genes of |
|
239 |
- any given Gene Set in this Sample, click on any point in this plot and a |
|
240 |
- second plot will appear bellow it", "<br/>", sep="<br/>")) |
|
20 |
+ |
|
21 |
+ ##################### GSVA RESULTS ##################### |
|
22 |
+ |
|
23 |
+ ## REACTIVE VALUES |
|
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) |
|
26 |
+ gsva.cancel <- reactiveVal(FALSE) |
|
27 |
+ |
|
28 |
+ ## GSVA RESULT |
|
29 |
+ observeEvent( input$button, { |
|
30 |
+ |
|
31 |
+ ## This js is in order to reset the event_data from the plotlys, |
|
32 |
+ ## so every time the .user hits the 'run' button, plotlys get back to null |
|
33 |
+ runjs("Shiny.setInputValue('plotly_click-click1', null);") |
|
34 |
+ runjs("Shiny.setInputValue('plotly_click-click2', null);") |
|
35 |
+ |
|
36 |
+ ## here we reset all the reactiveValues to NULL |
|
37 |
+ rv$gs <- NULL |
|
38 |
+ rv$dat.t <- NULL |
|
39 |
+ rv$p <- NULL |
|
40 |
+ rv$p2 <- NULL |
|
41 |
+ rv$p3 <- NULL |
|
42 |
+ rv$sample.c <- NULL |
|
43 |
+ rv$errors.gsva <- NULL |
|
44 |
+ |
|
45 |
+ ## this is a flag for the future. Futures cannot be canceled or |
|
46 |
+ ## terminated in a strict way, so when they get interrupted they |
|
47 |
+ ## throw an error that is not related to gsva(). When future is |
|
48 |
+ ## interrupted, the flag goes TRUE in order to make the errors |
|
49 |
+ ## message print NULL |
|
50 |
+ gsva.cancel(FALSE) |
|
51 |
+ |
|
52 |
+ modalGSVAUI("modal.text") |
|
53 |
+ |
|
54 |
+ ## future() cannot take reactive values, so we must isolate() them |
|
55 |
+ future({ |
|
56 |
+ ## sink() will redirect all console cats and prints to a |
|
57 |
+ ## text file that the main session will be reading in order |
|
58 |
+ ## to print the progress bar from bplaply() |
|
59 |
+ sink(rout) |
|
60 |
+ result <- gsva(isolate(matrix()), |
|
61 |
+ isolate(genesets()), |
|
62 |
+ method=isolate(argInp$method()), |
|
63 |
+ kcdf=isolate(argInp$kcdf()), |
|
64 |
+ abs.ranking=isolate(argInp$absRanking()), |
|
65 |
+ min.sz= isolate(argInp$varMinsz()), |
|
66 |
+ max.sz=isolate(argInp$varMaxsz()), |
|
67 |
+ parallel.sz=1L, ## by now, disable parallelism |
|
68 |
+ mx.diff=isolate(argInp$mxDiff()), |
|
69 |
+ tau=isolate(argInp$selectedTau()), |
|
70 |
+ ssgsea.norm=isolate(argInp$ssgseaNorm()), |
|
71 |
+ verbose=TRUE) |
|
72 |
+ sink() |
|
73 |
+ ## when gsva() ends, we reset the console text file to empty |
|
74 |
+ write("", file=rout) |
|
75 |
+ return(result) |
|
76 |
+ }, seed = TRUE) %...>% |
|
77 |
+ (function(result){ |
|
78 |
+ ## the future's result will be the gsva() result, and we save it |
|
79 |
+ ## and transform it in reactiveValues(). In order to make the future |
|
80 |
+ ## not block the app at an inner-session level, we save the results in |
|
81 |
+ ## reactiveValues() and then at the end of the observeEvent() we return NULL |
|
82 |
+ ## in order to make the plots. |
|
83 |
+ ## https://github.com/rstudio/promises/issues/23#issuecomment-386687705 |
|
84 |
+ rv$gs <- result |
|
85 |
+ rv$dat.t <- melt(as.data.table(rv$gs, keep.rownames = "gene.sets"), |
|
86 |
+ variable.name = "Sample", id.vars="gene.sets") |
|
87 |
+ rv$n <- length(levels(rv$dat.t$Sample)) |
|
88 |
+ rv$dd.col <- hcl(h = seq(15, 375, length=rv$n), l = 65, c = 100)[1:rv$n] |
|
89 |
+ names(rv$dd.col) <- levels(rv$dat.t$Sample) |
|
90 |
+ |
|
91 |
+ ## finally, we leave the console.text file empty again and |
|
92 |
+ ## remove the modal |
|
93 |
+ write("", file=rout) |
|
94 |
+ removeModal() |
|
95 |
+ }) %...!% |
|
96 |
+ (function(error){ |
|
97 |
+ ## there can be two ways to get an error here: |
|
98 |
+ ## 1. gsva() fails, which is an ok error and should be returnet to user |
|
99 |
+ ## 2. User interrupts the future, which shouldn't be printed, that's |
|
100 |
+ ## why I use a flag to identify if error comes from pressing "Cancel" btn |
|
101 |
+ ## on the modal |
|
102 |
+ removeModal() |
|
103 |
+ write("", file=rout) |
|
104 |
+ if(gsva.cancel()){ |
|
105 |
+ rv$errors.gsva <- NULL |
|
106 |
+ } else { |
|
107 |
+ rv$errors.gsva <- as.character(error) |
|
108 |
+ } |
|
109 |
+ |
|
110 |
+ }) |
|
111 |
+ NULL |
|
241 | 112 |
}) |
242 | 113 |
|
243 |
- #Rendering graph2 |
|
244 |
- eventData1 <- reactive({ |
|
245 |
- event_data("plotly_click", source = "click1") |
|
246 |
- }) |
|
114 |
+ # PRINTING CONSOLE.TEXT |
|
115 |
+ modalGSVAServer("modal.text", console.text, gsva.cancel, rout) |
|
247 | 116 |
|
248 |
- sample.c <- reactive({ |
|
249 |
- req(eventData1()) |
|
250 |
- ind <- eventData1()$curveNumber+1 |
|
251 |
- colnames(generated_gsva)[ind] |
|
252 |
- }) |
|
253 | 117 |
|
254 |
- plot2 <- reactive({ |
|
255 |
- req(sample.c()) |
|
256 |
- data <- dat.t[Sample==sample.c()] |
|
257 |
- p <- ggplot(data = data, aes(x=value, color=Sample)) + |
|
258 |
- stat_ecdf(geom="point") + theme(legend.position = "none") + |
|
259 |
- labs(x="GSVA Scores in selected sample", y="Empirical Cumulative Density") + |
|
260 |
- scale_color_manual("Legend", values = dd.col) |
|
261 |
- p <- ggplotly(p, source="click2") %>% style(text=data$gene.sets) |
|
262 |
- }) |
|
118 |
+ ##################### OUTPUTS ################## |
|
263 | 119 |
|
264 |
- output$plot2 <- renderPlotly({ |
|
265 |
- req(plot2()) |
|
266 |
- plot2() |
|
120 |
+ # PLOT1 RENDER |
|
121 |
+ plot1_Server("plot1", rv) |
|
122 |
+ |
|
123 |
+ # PLOT2 RENDER |
|
124 |
+ eventData1 <- reactive({ |
|
125 |
+ if(is.null(rv$p))return(NULL) |
|
126 |
+ ind <- event_data("plotly_click", source = "click1") |
|
127 |
+ ind <- ind$curveNumber+1 |
|
267 | 128 |
}) |
268 |
- |
|
269 |
- # Rendering graph 3 |
|
129 |
+ plot2_Server("plot2", eventData1, rv) |
|
130 |
+ |
|
131 |
+ # PLOT3 RENDER |
|
270 | 132 |
eventData2 <- reactive({ |
271 |
- event_data("plotly_click", source = "click2") |
|
133 |
+ req(rv$p2) |
|
134 |
+ ind <- event_data("plotly_click", source = "click2") |
|
135 |
+ ind <- ind$pointNumber+1 |
|
272 | 136 |
}) |
273 |
- |
|
274 |
- gene.set <- reactive({ |
|
275 |
- plot2()$x$data[[1]]$text[eventData2()$pointNumber+1] |
|
276 |
- }) |
|
277 |
- |
|
278 |
- output$plot3 <- renderPlotly({ |
|
279 |
- req(eventData2()) |
|
280 |
- genes.toplot <- geneIds(genes)[[gene.set()]] |
|
281 |
- mt <- match(genes.toplot, rownames(newY)) |
|
282 |
- x <- newY[na.omit(mt), sample.c()] |
|
283 |
- df <- as.data.frame(x) |
|
284 |
- df$x <- as.numeric(df$x) |
|
285 |
- df$Gene <- rownames(df) |
|
286 |
- df$Sample <- sample.c() |
|
287 |
- p1 <- ggplot(data = df, aes(x=x, color = Sample, label = Gene)) + |
|
288 |
- stat_density(geom="line", position = "identity") + |
|
289 |
- geom_rug() + theme(legend.position = "none") + |
|
290 |
- labs(x="Gene Expressions in selected sample", y="Density") + |
|
291 |
- xlim(as.numeric(range(newY))) + |
|
292 |
- scale_color_manual("legend", values= dd.col) |
|
293 |
- ggplotly(p1, tooltip = c("Gene", "x")) %>% style(hoverinfo="none", traces = 1) %>% |
|
294 |
- layout(title = list(text = paste0('<br><sup><i>', gene.set(), '</i></sup>'), |
|
295 |
- font = list(size=15))) |
|
137 |
+ plot3_Server("plot3", eventData2, rv, matrix, genesets) |
|
138 |
+ |
|
139 |
+ # ERRORS MESSAGES |
|
140 |
+ output$errorsGsva <- renderText({ |
|
141 |
+ req(argInp$varMinsz(), argInp$varMaxsz(), argInp$selectedTau()) |
|
142 |
+ rv$errors.gsva |
|
296 | 143 |
}) |
297 | 144 |
|
298 |
- # Rendering Session Info |
|
145 |
+ # SESSION INFO |
|
299 | 146 |
output$sessionInfo <- renderPrint({ |
300 | 147 |
sessionInfo() |
301 | 148 |
}) |
302 | 149 |
|
303 |
- tagList( |
|
304 |
- downloadButton('downloadData', 'Download'), |
|
305 |
- actionButton('closeSave','Save & Close') |
|
306 |
- ) |
|
307 |
-} |
|
308 |
- |
|
309 |
-download_handler <- function(input, output, session) { |
|
310 |
- #Controls the Download button |
|
311 |
- output$downloadData <- downloadHandler( |
|
312 |
- filename = function() { |
|
313 |
- paste("gsva_es-", Sys.Date(), ".csv", sep="") |
|
314 |
- }, |
|
315 |
- content = function(file) { |
|
316 |
- if("matrix" %in% class(generated_gsva)) # if the whole object is a matrix |
|
317 |
- { |
|
318 |
- dataFrameObs <- as.data.frame(generated_gsva) |
|
319 |
- write.csv(dataFrameObs, file) |
|
320 |
- } |
|
321 |
- else |
|
322 |
- { |
|
323 |
- if("ExpressionSet" %in% class(generated_gsva)) #If the generated gsva result object is an ExpressionSet |
|
324 |
- { |
|
325 |
- expressionSetObs <- exprs(generated_gsva) |
|
326 |
- dataFrameObs <- as.data.frame(expressionSetObs) |
|
327 |
- write.csv(dataFrameObs, file) |
|
328 |
- } |
|
329 |
- else |
|
330 |
- { |
|
331 |
- dataFrameObs <- as.data.frame(generated_gsva) |
|
332 |
- write.csv(dataFrameObs, file) |
|
333 |
- } |
|
334 |
- } |
|
150 |
+ |
|
151 |
+ ##################### UI SETUPS ##################### |
|
152 |
+ |
|
153 |
+ ## ENABLING 'RUN' BTN |
|
154 |
+ observe({ |
|
155 |
+ if(!is.null(matrix()) && !is.null(genesets())){ |
|
156 |
+ enable("button") |
|
157 |
+ } else { |
|
158 |
+ disable("button") |
|
335 | 159 |
} |
336 |
- ) |
|
337 |
-} |
|
160 |
+ }) |
|
161 |
+ |
|
162 |
+ ## HIDE 'GeneSets' PANEL WHILE THERE IS NO CLICK EVENT ON THE FIRST PLOT |
|
163 |
+ observe({ |
|
164 |
+ if( length(eventData1()) == 0){ |
|
165 |
+ hideTab(inputId = "Panels", target = "GeneSets") |
|
166 |
+ } else { |
|
167 |
+ showTab(inputId = "Panels", target = "GeneSets", select = TRUE) |
|
168 |
+ } |
|
169 |
+ }) |
|
170 |
+ |
|
171 |
+ # DNLD BTN |
|
172 |
+ downloadServer("download", reactive(rv$gs)) |
|
173 |
+ |
|
174 |
+ # CLOSE BTN |
|
175 |
+ closeBtnServer("close", reactive(rv$gs)) |
|
338 | 176 |
|
339 |
-function(input, output, session) { |
|
340 |
- v <- reactiveValues(action = FALSE) |
|
341 | 177 |
|
342 |
- observeEvent(input$button, { |
|
343 |
- v$action <- input$button |
|
178 |
+ # TEXT1 |
|
179 |
+ output$text1 <- renderUI({ |
|
180 |
+ req(rv$gs) |
|
181 |
+ HTML(paste("<br/>", "\t To see the Empirical Cumulative Distribution Function |
|
182 |
+ of a Sample, click on its line in this plot and go |
|
183 |
+ to the 'Gene.Set' Panel", "<br/>", sep="<br/>")) |
|
344 | 184 |
}) |
345 | 185 |
|
346 |
- output$download <- renderUI({ |
|
347 |
- if(v$action) |
|
348 |
- { |
|
349 |
- #Isolates the Run event, that allows the program to run the generation only if the user clicks the button. |
|
350 |
- isolate({ |
|
351 |
- gsva_validation(input,output,session) |
|
352 |
- }) |
|
353 |
- } |
|
186 |
+ # TABLE |
|
187 |
+ output$result <- renderTable({ |
|
188 |
+ req(rv$gs) |
|
189 |
+ resultInformation <- data.frame("Nr of gene sets" = nrow(rv$gs), |
|
190 |
+ "Nr of samples" = ncol(rv$gs)) |
|
191 |
+ resultInformation |
|
354 | 192 |
}) |
355 |
- download_handler(input,output,session) |
|
356 | 193 |
|
357 |
- #Observe the Save & Close button |
|
358 |
- observeEvent(input$closeSave, { |
|
359 |
- stopApp(generated_gsva) #Stops the app and returns the generated_gsva object |
|
194 |
+ # TEXT2 |
|
195 |
+ output$text2 <- renderUI({ |
|
196 |
+ title1 <- rv$sample.c |
|
197 |
+ h2(tags$b(title1), align ="center") |
|
360 | 198 |
}) |
199 |
+ |
|
200 |
+ # TEXT3 |
|
201 |
+ output$text3 <- renderUI({ |
|
202 |
+ HTML(paste("<br/>", "\t To see the Kernel Density Estimation of genes of |
|
203 |
+ any given Gene Set in this Sample, click on any point in this plot and a |
|
204 |
+ second plot will appear bellow it", "<br/>", sep="<br/>")) |
|
205 |
+ }) |
|
206 |
+ |
|
361 | 207 |
} |
... | ... |
@@ -1,147 +1,63 @@ |
1 |
-library(shiny) |
|
2 |
-library(shinythemes) |
|
3 |
-library(plotly) |
|
4 |
- |
|
5 |
-selectDataInput <- function(id) { |
|
6 |
- # Create a namespace function using the provided id |
|
7 |
- ns <- NS(id) |
|
8 |
- |
|
9 |
- #UI declaration |
|
10 |
- column( |
|
11 |
- 3, |
|
12 |
- h3("Data input:"), |
|
13 |
- #Select data source |
|
14 |
- wellPanel(fluidRow( |
|
15 |
- column( |
|
16 |
- 12, |
|
17 |
- #Select expression data matrix |
|
18 |
- radioButtons("matrixSourceType", "Select expression data matrix:", |
|
19 |
- c("From file" = "fileMatrix", |
|
20 |
- "From workspace" = "varMatrix")) |
|
21 |
- , |
|
22 |
- #If the selected data source is a file |
|
23 |
- conditionalPanel( |
|
24 |
- condition = "input.matrixSourceType == 'fileMatrix'", |
|
25 |
- fileInput("matrixFile", "Choose matrix file:", |
|
26 |
- accept = c( |
|
27 |
- "text/csv", |
|
28 |
- "text/comma-separated-values,text/plain", |
|
29 |
- ".csv",".ods",".xls",".xlt") |
|
30 |
- ) |
|
31 |
- ), |
|
32 |
- #If the selected data source is a workspace object |
|
33 |
- conditionalPanel( |
|
34 |
- condition = "input.matrixSourceType == 'varMatrix'", |
|
35 |
- selectInput("matrixVar", "Choose matrix var:", |
|
36 |
- ls(envir=.GlobalEnv)) |
|
37 |
- ), |
|
38 |
- fluidRow(column(12, |
|
39 |
- HTML("<br>"))), |
|
40 |
- #Select geneset |
|
41 |
- radioButtons("genesetSourceType", "Select gene sets:", |
|
42 |
- c("From file" = "fileGeneset", |
|
43 |
- "From workspace" = "varGeneset")) |
|
44 |
- , |
|
45 |
- #If the selected data source is a file |
|
46 |
- conditionalPanel( |
|
47 |
- condition = "input.genesetSourceType == 'fileGeneset'", |
|
48 |
- fileInput("genesetFile", "Choose GeneSet file:", |
|
49 |
- accept = ".gmt") |
|
50 |
- ), |
|
51 |
- #If the selected data source is a workspace object |
|
52 |
- conditionalPanel( |
|
53 |
- condition = "input.genesetSourceType == 'varGeneset'", |
|
54 |
- selectInput("genesetVar", "Choose GeneSet var:", |
|
55 |
- ls(envir=.GlobalEnv)) |
|
56 |
- ), |
|
57 |
- HTML("<br>"), |
|
58 |
- radioButtons("arg", "Change default settings:", |
|
59 |
- c("No" = "no", |
|
60 |
- "Yes" = "yes")) |
|
61 |
- ) |
|
62 |
- ), |
|
63 |
- actionButton("button", "Run")) |
|
64 |
- ) |
|
65 |
-} |
|
66 |
- |
|
67 |
-mainDataInput <- function(id) { |
|
68 |
- # Create a namespace function using the provided id |
|
69 |
- ns <- NS(id) |
|
70 |
- |
|
71 |
- #UI Definition |
|
72 |
- mainPanel( width = 6, |
|
73 |
- tabsetPanel(type="tabs", |
|
74 |
- tabPanel("Samples", |
|
75 |
- htmlOutput("text1"), |
|
76 |
- plotlyOutput("plot"), |
|
77 |
- tableOutput("result"), |
|
78 |
- uiOutput("download")), |
|
79 |
- tabPanel("Gene Sets", |
|
80 |
- uiOutput("text2"), |
|
81 |
- htmlOutput("text3"), |
|
82 |
- plotlyOutput("plot2"), |
|
83 |
- plotlyOutput("plot3")), |
|
84 |
- tabPanel("Session Info", |
|
85 |
- verbatimTextOutput("sessionInfo")) |
|
86 |
- ) |
|
87 |
- ) |
|
88 |
-} |
|
89 |
- |
|
90 |
-argumentsDataInput <- function(id) { |
|
91 |
- # Create a namespace function using the provided id |
|
92 |
- ns <- NS(id) |
|
1 |
+fluidPage( |
|
2 |
+ theme = shinytheme("spacelab"), |
|
3 |
+ shinyjs::useShinyjs(), |
|
4 |
+ add_busy_spinner(spin = "double-bounce", position = "bottom-right", height = "100px", width = "100px"), |
|
5 |
+ tags$head( |
|
6 |
+ tags$link(rel = "stylesheet", type = "text/css", href = "style.css") |
|
7 |
+ ), |
|
8 |
+ titlePanel( |
|
9 |
+ fluidRow( |
|
10 |
+ column(6, |
|
11 |
+ h2("GSVA Shiny App", align="left")), |
|
12 |
+ column(6, |
|
13 |
+ tags$img(src="GSVA.png", align="right", height=75, width=75)) |
|
14 |
+ ), windowTitle="GSVA"), |
|
93 | 15 |
|
94 |
- #UI Definition |
|
95 |
- column( |
|
96 |
- 3, |
|
97 |
- conditionalPanel( |
|
98 |
- condition = "input.arg == 'yes'", |
|
99 |
- h3("Parameters:"), |
|
16 |
+ fluidRow( |
|
17 |
+ column( |
|
18 |
+ width=3, |
|
19 |
+ h3("Data input"), |
|
20 |
+ #Select data source |
|
100 | 21 |
wellPanel(fluidRow( |
101 | 22 |
column( |
102 | 23 |
12, |
103 |
- selectInput("method", "Choose method:", |
|
104 |
- c("gsva","ssgsea","zscore","plage")), |
|
105 |
- selectInput("kcdf", "Choose kcdf:", |
|
106 |
- c("Gaussian","Poisson","none")), |
|
107 |
- radioButtons("absRanking", "abs.ranking:", |
|
108 |
- c("False" = FALSE, |
|
109 |
- "True" = TRUE)), |
|
110 |
- numericInput("minSz","min.sz:",value = 1), |
|
111 |
- numericInput("maxSz","max.sz (Write 0 for infinite):",value = 0), |
|
112 |
- radioButtons("mxDiff", "mx.diff:", |
|
113 |
- c("True" = TRUE, |
|
114 |
- "False" = FALSE)), |
|
115 |
- conditionalPanel( |
|
116 |
- condition = "input.method == 'gsva'", |
|
117 |
- numericInput("tau1","tau:",value = 1) |
|
118 |
- ), |
|
119 |
- conditionalPanel( |
|
120 |
- condition = "input.method == 'ssgsea'", |
|
121 |
- numericInput("tau2","tau:",value = 0.25), |
|
122 |
- radioButtons("ssgseaNorm", "ssgsea.norm:", |
|
123 |
- c("True" = TRUE, |
|
124 |
- "False" = FALSE)), |
|
125 |
- ), |
|
126 |
- radioButtons("verbose", "verbose:", |
|
127 |
- c("True" = TRUE, |
|
128 |
- "False" = FALSE)) |
|
129 |
- ))) |
|
130 |
- ) |
|
24 |
+ matrixUI("matrix1"), |
|
25 |
+ fluidRow(column(12, |
|
26 |
+ HTML("<br>"))), |
|
27 |
+ geneSetsUI("genes1"), |
|
28 |
+ HTML("<br>"), |
|
29 |
+ radioButtons("arg", "Change default settings:", |
|
30 |
+ c("No" = "no", |
|
31 |
+ "Yes" = "yes")), |
|
32 |
+ actionButton("button", "Run"), |
|
33 |
+ fluidRow( |
|
34 |
+ column(12, |
|
35 |
+ HTML("<br>"), |
|
36 |
+ downloadUI("download"), |
|
37 |
+ closeBtnUI("close") |
|
38 |
+ ) |
|
39 |
+ ) |
|
40 |
+ ) |
|
41 |
+ )) |
|
42 |
+ ), |
|
43 |
+ mainPanel(width=6, |
|
44 |
+ tabsetPanel(id = "Panels", type="tabs", |
|
45 |
+ tabPanel("Samples", |
|
46 |
+ textOutput("errorsGsva"), |
|
47 |
+ htmlOutput("text1"), |
|
48 |
+ plot1_UI("plot1"), |
|
49 |
+ tableOutput("result") |
|
50 |
+ ), |
|
51 |
+ tabPanel("GeneSets", |
|
52 |
+ uiOutput("text2"), |
|
53 |
+ htmlOutput("text3"), |
|
54 |
+ plot2_UI("plot2"), |
|
55 |
+ plot3_UI("plot3") |
|
56 |
+ ), |
|
57 |
+ tabPanel("Session Info", |
|
58 |
+ verbatimTextOutput("sessionInfo")) |
|
59 |
+ ) |
|
60 |
+ ), |
|
61 |
+ argumentsDataUI("argumentsInput") |
|
131 | 62 |
) |
132 |
-} |
|
133 |
- |
|
134 |
-fluidPage( |
|
135 |
- theme = shinytheme("spacelab"), |
|
136 |
- tags$head( |
|
137 |
- tags$link(rel = "stylesheet", type = "text/css", href = "style.css") |
|
138 |
- ), |
|
139 |
- titlePanel(div(h2("GSVA WebApp", align="left"), |
|
140 |
- tags$img(src="GSVA.png", align="center", height=75, width=75)), |
|
141 |
- windowTitle="GSVA"), |
|
142 |
- fluidRow( |
|
143 |
- selectDataInput("dataInput"), |
|
144 |
- mainDataInput("mainInput"), |
|
145 |
- argumentsDataInput("argumentsInput") |
|
146 |
- ) |
|
147 | 63 |
) |