-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQC_normalized_data.R
More file actions
81 lines (70 loc) · 2.42 KB
/
Copy pathQC_normalized_data.R
File metadata and controls
81 lines (70 loc) · 2.42 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
source("functions.R")
QC_normalized_UI<-function(id)
{
ns<-NS(id)
tagList(
downloadButton(ns('download_density'), 'Download plot'),
plotOutput(ns("density_plot"),
brush = brushOpts(id = ns("dense_brush"),resetOnNew = TRUE),
dblclick = ns("dense_dblclick")),
downloadButton(ns('download_ecdf'), 'Download plot'),
plotOutput(ns("ecdf_plot"))
)
}
QC_normalized<-function(input,output,session,normal,zoom)
{# Single zoomable plot (on left)
dense_ranges <- reactiveValues(x = c(0,1000), y = c(0,0.035))
progress <- shiny::Progress$new()
# Make sure it closes when we exit this reactive, even if there's an error
on.exit(progress$close())
progress$set(message = "Preparing plots", value = 0)
# Number of times we'll go through the loop to update progress bar
n <- 3
# Increment the progress bar, and update the detail text.
progress$inc(1/n, detail = paste("Doing part", 1,"/",n))
# Pause for 0.1 seconds to simulate a long computation.
Sys.sleep(0.1)
#Step 1: get density plot
output$density_plot<-renderPlot({
density_plot(normal,dense_ranges$x,dense_ranges$y,zoom)
})
observeEvent(input$dense_dblclick,{
brush <- input$dense_brush
if (!is.null(brush)) {
dense_ranges$x <- c(brush$xmin, brush$xmax)
dense_ranges$y <- c(brush$ymin, brush$ymax)
} else {
dense_ranges$x<-c(0,1000)
dense_ranges$y<- c(0,0.035)
}
})
#download density plot
output$download_density <- downloadHandler(
filename = paste(" Density plot for normalized data.png"),
content = function(file) {
png(file)
density_plot(normal,dense_ranges$x,dense_ranges$y,zoom)
dev.off()
})
# Increment the progress bar after density plot is obtained, and update the detail text.
progress$inc(1/n, detail = paste("Doing part", 2,"/",n))
# Pause for 0.1 seconds to simulate a long computation.
Sys.sleep(0.1)
#Step 2: Get ECDF plot
output$ecdf_plot<-renderPlot(
{
ECDF_plot(normal)
})
#download ecdf plot
output$download_ecdf <- downloadHandler(
filename = paste("ECDF plot of normalized data.png"),
content = function(file) {
png(file)
ECDF_plot(normal)
dev.off()
})
# Increment the progress bar, and update the detail text.
progress$inc(1/n, detail = paste("Doing part", 3,"/",n))
# Pause for 0.1 seconds to simulate a long computation.
Sys.sleep(0.1)
}