-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathserver.R
82 lines (64 loc) · 2.53 KB
/
server.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
source("./functions/shiny_libs.R")
shinyInput <- function(FUN, len, id, ...) {
inputs <- character(len)
for (i in seq_len(len)) {
inputs[i] <- as.character(FUN(paste0(id, i), ...))
}
inputs
}
options(shiny.maxRequestSize = 30*1024^2)
options(scipen=3)
shinyServer(function(input, output) {
current = reactiveValues(res =NULL)
RUN = eventReactive(input$submit, {
A = read.delim(input$cohort_A$datapath, header=T, stringsAsFactors = F)
B = NULL
gene.set.path = ifelse(!input$customGS,get.gene.set(as.numeric(input$gs_dataset)),input$gene_set$datapath)
geneset = read.gmt.file(gene.set.path)
s.test = input$stat.test
fdr_th = 0.1
bootstrapping = input$bootstrapping=="True"
montecarlo = input$stat.test==4
nsim = input$nsim
genome = input$genome
if (!montecarlo)
B = read.delim(input$cohort_B$datapath, header=T, stringsAsFactors = F)
if(!is.null(A) & (montecarlo | !is.null(B)) & !is.null(geneset) ){
if (montecarlo)
load(paste("./RData/",genome,".gene.cds.length.RData",sep = ""))
cpus = detectCores()
if (!is.null(cpus))
{
cpus = cpus - 1
} else {
cpus = 2
}
MEGA(A, B, geneset, fdr_th, bootstrapping, nsim, s.test, montecarlo, gene.cds.length, cpus)
}
})
# TAB results
output$mega_results = DT::renderDataTable({
results = RUN()
current$res = results
DT::datatable(results, options = list(orderClasses = TRUE, pageLength = 15),selection= 'single',rownames = FALSE)
})
output$downloadData <- downloadHandler(
filename = function() {
"MEGA-RVs_results.tsv"
},
content = function(con) {
write.table(current$res,con,col.names = T, row.names = F, quote = F, sep="\t")
}
)
output$downloadExample <- downloadHandler(
filename = function(){
"Example_dataset.zip"
},
content = function(con){
filesToSave <- c( "example_dataset/ncomm.cereda.syCRCs.tsv.gz"
,"example_dataset/ncomm.cereda.1000.genomes.tsv.gz")
zip(zipfile=con, files = filesToSave)
},
contentType = "application/zip"
)
})