-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.R
More file actions
executable file
·105 lines (88 loc) · 3.28 KB
/
server.R
File metadata and controls
executable file
·105 lines (88 loc) · 3.28 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# crisprepo-shiny
# Copyright (c) 2018 Tobias Neumann, Jesse Lipp.
#
# crisprepo-shiny is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# crisprepo-shiny is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
function(input, output, session) {
### Genome-wide Screens
# Gene Search
output$gwsGeneTable <- renderDataTable({
if (nrow(gwsGeneTableReactive()) > 0) {
print(gwsGeneTableReactive())
gwsGeneTableReactive() %>%
select(contrast_id, gene_id, hgnc_symbol, input$gwsIndexRadio) %>%
spread(contrast_id, input$gwsIndexRadio) %>%
arrange(gene_id)
}
},
filter = "bottom",
options = list(pageLength = 50,
lengthMenu = c(50, 100, 200)))
gwsGeneList <- reactive({
features %>%
filter(library_id %in% (
pheno %>% filter(species == input$gwsSpeciesSelect) %>%
select(library_id) %>%
distinct() %>%
.$library_id)
) %>% select(hgnc_symbol) %>%
distinct() %>%
.$hgnc_symbol
})
gwsContrastList <- reactive({
contrasts %>%
filter(species == input$gwsSpeciesSelect) %>%
select(contrast_id) %>%
distinct() %>%
.$contrast_id
})
observeEvent(input$gwsSpeciesSelect, {
updateSelectizeInput(session, 'gwsGeneSelect', choices = gwsGeneList(), server = TRUE)
updateSelectizeInput(session, 'gwsContrastSelect', choices = gwsContrastList(), server = TRUE)
})
gwsGeneTableReactive <- reactive({
presel = features %>%
filter(hgnc_symbol %in% input$gwsGeneSelect) %>%
select(gene_id) %>% distinct %>% .$gene_id
con %>%
tbl("gene_stats") %>%
filter(gene_id %in% presel, contrast_id %in% input$gwsContrastSelect) %>%
left_join(con %>% tbl("contrasts"), by = "contrast_id") %>%
filter(auc >= input$gwsGeneSelectAUC) %>%
filter(abs(ssmd) >= input$gwsGeneSelectSSMD) %>%
left_join(con %>% tbl("features"), by = "gene_id") %>%
select(contrast_id, gene_id, lfc, effect, hgnc_symbol) %>%
distinct() %>%
collect()
})
output$gwsGeneFCAverage <- renderInfoBox({
infoBox(title = "Average Fold-change",
value = gwsGeneTableReactive() %>%
summarize(value = round(mean(lfc, na.rm = TRUE), 3)) %>%
.$value)
})
output$gwsGeneEffectAverage <- renderInfoBox({
infoBox(title = "Average Effect",
value = gwsGeneTableReactive() %>%
summarize(value = round(mean(effect, na.rm = TRUE), 3)) %>%
.$value)
})
output$gwsGeneButtonDownload <- downloadHandler(
filename = function() {
paste0(paste(input$gwsGeneSelect,collapse="_"), ".txt")
},
content = function(file) {
gwsGeneTableReactive() %>% write_tsv(file)
}
)
}