-
Notifications
You must be signed in to change notification settings - Fork 7
/
server-analysisRes.R
101 lines (76 loc) · 2.6 KB
/
server-analysisRes.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
observe({
compareReactive()
})
compareReactive <- reactive({
if(input$getDiffResVs > 0)
{
withProgress(message = "Getting DESeq results , please wait ...",{
isolate({
factorsStr = "Intercept: no replicates"
if(input$no_replicates)
{
myValues$vsResults <- results(myValues$dds)
}
else{
if(input$resultNameOrFactor == 'Result Names')
{
validate(
need((length(input$resultNamesInput) > 0 & length(input$resultNamesInput) < 3), message = "Need to choose at least 1 (Max. 2)")
)
js$addStatusIcon("resultsTab","loading")
myValues$vsResults <- results(myValues$dds,contrast=list(input$resultNamesInput))
factorsStr = paste(list(input$resultNamesInput))
}
else if(input$resultNameOrFactor == 'Factors')
{
validate(
need((input$condition1 != input$condition2) , message = "condition 1 must be different from condition 2")
)
js$addStatusIcon("resultsTab","loading")
myValues$vsResults <- results(myValues$dds,contrast=c(input$factorNameInput,input$condition1,input$condition2))
factorsStr = paste(input$factorNameInput, " : ", input$condition1,input$condition2)
}
}
js$addStatusIcon("resultsTab","done")
return(list('results'=myValues$vsResults, 'conditions'=factorsStr))
})
})
}
})
output$maPlot <- renderPlot({
if(!is.null(compareReactive()))
{
isolate({
plotMA(compareReactive()$results, main="MA Plot", ylim=c(-input$ylim,input$ylim), alpha=input$alpha)
})
}
})
output$comparisonData <- renderDataTable({
if(!is.null(compareReactive()))
{
df = as.data.frame(compareReactive()$results)
df[is.na(df)] = 0
df
}
},
options = list(scrollX = TRUE, pageLength = 5))
output$factorsStr <- renderText({
if(!is.null(compareReactive()))
return(compareReactive()$conditions)
return(NULL)
})
output$downloadVsCsv <- downloadHandler(
filename = function() {paste0(input$condition1,"_vs_",input$condition2,".csv")},
content = function(file) {
csv = myValues$vsResults
write.csv(csv, file, row.names=T)
}
)
output$comparisonComputed <- reactive({
return(!is.null(myValues$vsResults))
})
outputOptions(output, 'comparisonComputed', suspendWhenHidden=FALSE)
output$noReplicates <- reactive({
return(input$no_replicates)
})
outputOptions(output, 'noReplicates', suspendWhenHidden=FALSE)