-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.R
More file actions
87 lines (77 loc) · 3.34 KB
/
app.R
File metadata and controls
87 lines (77 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
######################################################
## MutRank Version 1.2
## Written by Elly Poretsky
## Alisa Huffaker Lab
## University of California, San Diego
##
## mutRank is Shiny web application for Mutual Rank calculations
## More information at: https://github.com/eporetsky/MutRank
######################################################
# Install packages that are not yet installed and loads them
# Based on - https://vbaliga.github.io/verify-that-r-packages-are-installed-and-loaded/
package.check <- lapply(
c("shiny","shinythemes", "igraph","reshape2","visNetwork", "ggplot2",
"data.table", "RColorBrewer", "ontologyIndex"),
FUN = function(x) {
if (!require(x, character.only = TRUE)) {
install.packages(x, dependencies = TRUE)
library(x, character.only = TRUE)
}
}
)
source("global.R") # Loads default_files.csv to specifit which files to load when MutRank starts
source("module_datainput.R") # Shiny module that handles loading user specified data for the analysis
source("module_mutualrank.R") # Shiny module that handles the caluclation and printing of the Mutual Rank table
source("module_heatmap.R") # Shiny module that handles the plotting part of the Mutual Rank table as a heatmap
source("module_network.R") # Shiny module that handles plotting the Mutual Rank table as a network using JS
source("module_enrichment.R") # Shiny module that handles calculation of the GO term enrichment based on the Mutual Rank table
source("mutrank_functions.R") # R script file that contains the functions used by the different modules
# Shiny UI function
ui <- fluidPage(
navbarPage("MutRank v1.1",
theme = shinytheme("flatly"),
dataInputUI("dataInputNS"),
mutualRankUI("mutualRankNS"),
heatmapUI("heatmapNS"),
networkUI("networkNS"),
enrichmentUI("enrichmentNS")
),
tags$head(tags$style('body {color:black; font-size: 175%;}')),
tags$head(tags$style(HTML('.shiny-bound-input {color:black; font-size: 100%;}')))
)
# Shiny server function
server <- function(input, output, session){
# Stops the running Shiny app when the app window is closed
session$onSessionEnded(stopApp)
# Calls module_datainput.R and returns a list containing all the loaded data
data <- callModule(dataInput,"dataInputNS")
# Calls module_mutualrank.R and returns the Mutual Rank table in mutuak_rank_table
mutuak_rank_table <- callModule(mutualRank,"mutualRankNS",
data$expression,
data$annotations,
data$symbols,
data$categories,
data$foldchange,
data$GO_genes,
data$domains)
# Calls module_heatmap.R
callModule(heatmap,"heatmapNS",
mutuak_rank_table,
data$symbols)
# Calls module_network.R
callModule(network,"networkNS",
mutuak_rank_table,
data$annotations,
data$symbols,
data$foldchange,
data$categories,
data$GO_genes,
data$domains)
# Calls module_enrichment.R
callModule(enrichment,"enrichmentNS",
mutuak_rank_table,
data$GO_db,
data$GO_genes)
}
# Create and runs the Shiny app
shinyApp(ui, server)