-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.R
69 lines (64 loc) · 1.87 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
library(shiny)
library(EnhancedVolcano)
library(limma)
p_cutoff <- 0.05
fc_cutoff <- 1
p_cutoff_col <- "adj.P.Val"
# Server logic
server <- function(input, output) {
# Function to read uploaded data or use default data
data <- reactive({
req(input$file)
if (!is.null(input$file$datapath)) {
read.csv(input$file$datapath, header = TRUE, stringsAsFactors = FALSE)
} else {
# Use default data if no file uploaded
# Here, you can replace this with your own default data generation logic
as.data.frame(matrix(rnorm(100), ncol = 2))
}
})
data <- as.data.frame(matrix(rnorm(100), ncol = 2))
# Generate Enhanced Volcano Plot
output$volcanoPlot <- renderPlot({
req(data())
EnhancedVolcano(
data(),
title = input$plot_title,
# xlim = input$x_range,
xlim = c(input$x_min, input$x_max),
# lab = rownames(data()),
lab = data()[, "Gene.symbol"],
x = "logFC", # Assuming log fold change column is named logFC
y = "adj.P.Val",
# Assuming log adjusted p-value column is named logPValue
labSize = 3,
pCutoffCol = p_cutoff_col,
pCutoff = p_cutoff,
FCcutoff = fc_cutoff,
)
})
# Download plot as PDF
output$downloadPlot <- downloadHandler(
filename = function() {
paste(input$plot_title, ".pdf", sep = "")
},
content = function(file) {
pdf(file)
print(EnhancedVolcano(
data(),
title = input$plot_title,
# xlim = input$x_range,
xlim = c(input$x_min, input$x_max),
lab = data()[, "Gene.symbol"],
x = "logFC", # Assuming log fold change column is named logFC
y = "adj.P.Val",
# Assuming log adjusted p-value column is named logPValue
labSize = 3,
pCutoffCol = p_cutoff_col,
pCutoff = p_cutoff,
FCcutoff = fc_cutoff,
))
dev.off()
}
)
}