-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.R
More file actions
87 lines (63 loc) · 2.56 KB
/
Copy pathserver.R
File metadata and controls
87 lines (63 loc) · 2.56 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
# This is the server logic for a Shiny web application.
# You can find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com
#
library(shiny)
library(ggplot2)
library(SRP)
load("data/GSE79519.RData")
shinyServer(function(input, output) {
### Data import:
Dataset <- reactive({
if (is.null(input$infile)) {
return(GSE79519)
}
data.frame(data.table::fread(input = input$infile$datapath))
})
Expcol <- reactive({
if (is.null(Dataset())) return(NULL)
grep("basem|logcp|aveex", tolower(colnames(Dataset())))
})
output$setThresh <- renderUI({
if (is.null(Dataset())) {
return(NULL)
} else {
var <- colnames(Dataset())[Expcol()]
sliderInput("thres", paste("To remove uninformative genes with low expression, set filter threshold for", var, "(slider shows 0.1% values from the lower tail):"),
min = 0,
max = floor(0.001 * max(Dataset()[, Expcol()], na.rm = TRUE)),
value = 0)
}
})
Pvalues <- reactive({
if (is.null(Dataset())) return(NULL)
pval_regexp <- "p[:punct:]*[:space:]*[:punct:]*[:space:]*val"
pvcol <- grep(pval_regexp, tolower(colnames(Dataset())))
overthresh <- Dataset()[,Expcol()] > input$thres
Dataset()[overthresh, pvcol]
})
Srp <- reactive({
if (is.null(Pvalues())) return(NULL)
try(srp(Pvalues()))
})
output$distPlot <- renderPlot({
if (is.null(Pvalues())) return(NULL)
data <- data.frame(values = Pvalues())
ggplot(data = data) +
geom_histogram(mapping = aes(x = values), bins = input$bins) +
labs(title = "P value histogram",
x = "P values",
y = "Count")
})
output$srpText <- renderText({
if (is.null(Srp())) return(NULL)
if(inherits(Srp(),"try-error")) return(Srp()[1])
paste0("<hr> Estimated power, based on P value histogram: <span style='color:blue'>", round(Srp()[1], 2),"</span>",
"<br> Proportion of true null hypotheses, π0: <span style='color:blue'>", round(Srp()[2], 2),"</span>",
"<br> Estimated number of false positives: ", round(Srp()[3], 0),
"<br> Effects in replication study: ", round(Srp()[4], 0),
"<br> Undetected effects: ", round(Srp()[5], 0),
"<hr> Cannot make sense of your P value histogram? Please have a look at this blog for help: <a href='http://varianceexplained.org/statistics/interpreting-pvalue-histogram/'>How to interpret a p-value histogram</a>.")
})
})