-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.R
233 lines (189 loc) · 7.21 KB
/
app.R
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
library(shiny)
library(shinyWidgets)
library(shinyjs)
library(shinycssloaders)
library(shinydashboard)
library(BiocManager)
options(repos = BiocManager::repositories())
library(ggplot2)
library(dplyr)
library(DT)
library(tibble)
library(data.table)
library(pheatmap, include.only = "pheatmap")
library(RColorBrewer, include.only = "brewer.pal")
library(tableHTML)
library(gprofiler2, include.only = c("gost", "gostplot"))
library(enrichplot)
library(clusterProfiler)
library(org.Hs.eg.db)
library(AnnotationDbi)
library(VennDiagram)
library(eulerr)
library(htmlwidgets)
library(gridExtra)
################### Helper function #############################################
footerHTML <- function() { # defines style of the footer
"
<footer class='footer' style='background-color: #333333; color: white; height: 1cm; display: flex; justify-content: center; align-items: center;'>
<div>
<span style='margin: 0;'>DoxoDB © 2023 Copyright:</span>
<a href='http://heartlncrna.github.io' target='_blank'>heartlncrna</a>
<span> </span>
<a href='https://github.com/Reb08/DoxoDB/' target='_blank'>
<img src='GitHub-Mark-Light-64px.png' height='20'>
</div>
</footer>
"
}
# colors used in heatmap
mypalette <- brewer.pal(11,"RdYlBu")
morecols <- colorRampPalette(mypalette)
myCol1 <- brewer.pal(4, "Pastel2")
myCol2 <- brewer.pal(3, "Pastel2")
########################################### shiny app ########################################
ui <- fluidPage(
useShinyjs(),
tags$head(
tags$link(rel = "stylesheet", href = "https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"),
tags$style( # details position of footer
HTML("
html {
position: relative;
min-height: 100%;
}
body {
margin-bottom: 1cm;
padding-bottom: 20px; /* add margin to the top */
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
background-color: #333333;
color: white;
height: 1cm;
display: flex;
justify-content: center;;
align-items: center;
}
")
),
tags$script(
"var downloadTimeout;
$(document).on('click', '#downloadData', function(){
$('#downloadData').removeClass('btn-primary').addClass('btn-success');
var timeoutSeconds = input$dataset == 'GSE154416' ? 38 : 10;
downloadTimeout = setTimeout(function(){
$('#downloadData').removeClass('btn-success').addClass('btn-primary');
}, timeoutSeconds * 1000); // Change the button back to blue after the specified seconds
});
$(document).ajaxComplete(function(event, xhr, settings) {
clearTimeout(downloadTimeout); // Clear the timeout when the download is complete
$('#downloadData').removeClass('btn-success').addClass('btn-primary');
});"
)
),
theme = bslib::bs_theme(bootswatch = "yeti"),
navbarPage(
"DoxoDB",
source(file.path("ui", "homePage.R"), local=TRUE)$value,
source(file.path("ui", "explorePage.R"), local=TRUE)$value,
source(file.path("ui", "lncRNAPage.R"), local=TRUE)$value,
source(file.path("ui", "downloadPage.R"), local=TRUE)$value,
source(file.path("ui", "documentationPage.R"), local=TRUE)$value,
),# end navbarPage
tags$footer(HTML(footerHTML()))
) # end fluidPage
server <- function(input, output, session){
studyInput <- reactive({
if(input$study == "GSE135842"){
data <- data.frame(fread("data/GSE135842-All.txt"))
} else if (input$study == "GSE198396"){
data <- data.frame(fread("data/GSE198396-All.txt"))
} else if (input$study == "GSE154101") {
data <- data.frame(fread("data/GSE154101-All.txt"))
} else {
data <- data.frame(fread("data/GSE163361-All.txt"))
}
on.exit(rm(data))
return(data)
})
# change the options for the "comparison" drop down menu (in ExplorePanel.R) based on the study selected in the "study" drop down menu (in ExplorePanel.R)
comparisons <- reactive({
if(input$study == "GSE135842"){
c("ctrl_p130_siCTRL vs DOX_p130_siCTRL",
"ctrl_p130_siP107 vs DOX_p130_siP107",
"ctrl_RB+p130_siCTRL vs DOX_RB+p130_siCTRL",
"ctrl_RB+p130_siP107 vs DOX_RB+p130_siP107")
} else if (input$study == "GSE198396"){
c("Normal vs Doxo_PDL1-pos",
"Normal vs Doxo_PDL1-neg")
} else if (input$study == "GSE154101") {
c("Normal vs Doxo-treated")
} else {
c("FCIBC02 Parent_ctrl vs Parent_Doxo",
"SUM149 Parent_ctrl vs Parent_Doxo",
"FCIBC02 Parent_ctrl vs DoxoR_ctrl",
"SUM149 Parent_ctrl vs DoxoR_ctrl")
}
})
observeEvent(input$study, {
updateSelectInput(
session,
inputId = "comparison",
label = "Select Comparison",
choices = comparisons(),
selected = comparisons()[1]
)
})
studyInput_mutated <- reactive({
df <- studyInput()[studyInput()$Comparison == input$comparison, ] %>%
mutate(
Significance = case_when(
logFC >= input$FC & FDR < input$FDR & Biotype == "Protein_Coding" ~ "Up-reg protein-coding gene",
logFC >= input$FC & FDR < input$FDR & Biotype == "lncRNA" ~ "Up-reg lncRNA",
logFC <= -input$FC & FDR < input$FDR & Biotype == "Protein_Coding" ~ "Down-reg protein-coding gene",
logFC <= -input$FC & FDR < input$FDR & Biotype == "lncRNA" ~ "Down-reg lncRNA",
TRUE ~ "Unchanged"))
on.exit(rm(df))
return(df)
})
# allow user to select a row in table
selected_row <- reactive({
data.frame(Ensembl_ID = character(),
Gene_symbol = character(),
logFC = numeric(),
FDR = numeric(),
Biotype = character(),
Significance = character())
})
observeEvent(input$table_rows_selected, {
row_index <- input$table_rows_selected
row_name <- studyInput_mutated()[row_index, "Gene_symbol"]
updateSelectInput(session, "gene", choices = row_name, selected=row_name[1])
})
selected_row <- reactive({
row_name <- input$gene
if (!is.null(row_name)) {
studyInput_mutated()[studyInput_mutated()$Gene_symbol == row_name, ]
} else {
data.frame(Ensembl_ID = character(),
Gene_symbol = character(),
logFC = numeric(),
FDR = numeric(),
Biotype = character(),
Significance = character())
}
})
source(file.path("server", "mainTable.R"), local=TRUE)$value
source(file.path("server", "volcanoPlot.R"), local=TRUE)$value
source(file.path("server", "summaryTable.R"), local=TRUE)$value
source(file.path("server", "heatmapPlot.R"), local=TRUE)$value
source(file.path("server", "goAnalysis.R"), local=TRUE)$value
source(file.path("server", "keggPlot.R"), local=TRUE)$value
source(file.path("server", "vennDiagram.R"), local=TRUE)$value
source(file.path("server", "lncRNATable.R"), local=TRUE)$value
source(file.path("server", "downloadTable.R"), local=TRUE)$value
}
shinyApp(ui, server)