forked from Ulas-lab/Shiny-Seq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MA_plot.R
71 lines (58 loc) · 1.94 KB
/
MA_plot.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
source("functions.R")
MA_plot_UI<-function(id)
{
ns<-NS(id)
tagList(
uiOutput(ns("ma_comb")),
sliderInput(ns("scale"),"y-limit",1,15,value = 4,step = 1),
plotOutput(ns("MA_ploti"), width = "700px", height = "600px"),
downloadButton(ns('download_ma_plot'), 'Download plot')
)
}
MA_plot<-function(input,output,session,combination,DE_genes,p_values)
{
combo<-combination()
#combinations: Display comparisons A vs B , C Vs D etc
output$ma_comb <- renderUI({
if(!is.null(combo()))
{
print("inside ma plot module line 16")
#num <- length(combination())
num<- length(combo())
comb<-lapply(1:num, function(i) {
combo()[[i]]
#paste(combination()[[i]][1],' vs ',combination()[[i]][2])
})
checklist<-list()
for (i in seq_along(comb)) {
checklist[[comb[[i]]]] = i
}
selectInput(session$ns("ma_choice"),label = h5("Choose comparison") ,
choices = checklist,selected = 1)
}
})
#ma plot for the comparison selected
output$MA_ploti<- renderPlot({
print(p_values())
print("inside map plot line 40")
print(combo()[as.numeric(input$ma_choice)])
ma_plot(input$ma_choice,combo(),DE_genes(),input$scale,p_values())
})
#download MA plot
output$download_ma_plot <- downloadHandler(
filename = function(){
paste("MA plot",combo()[as.numeric(input$ma_choice)],".png", sep = "")},
content = function(file) {
#p<-ma_plot(input$ma_choice,combo(),DE_genes(),input$scale,p_values())
#ggsave(filename=file, plot=p, width = 20, height=8, units= "cm")
png(filename=file, height = 10, width = 20, units = "cm", res = 600)
#ma_plot(i,combo(),result_de,input_scale(),p_values())
ma_plot(input$ma_choice,combo(),DE_genes(),input$scale,p_values())
dev.off()
})
#
return(list(
input_scale=reactive({input$scale}),
p_values=reactive({p_values()})
))
}