forked from amanzour/CDP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyshiny.Rmd
executable file
·238 lines (195 loc) · 8.4 KB
/
myshiny.Rmd
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
---
title: "HafnerLab"
author: "Amir Manzour"
date: "6/29/2020"
output: html_document
runtime: shiny
---
## PAR-CLIP RNA-seq CDP
### upload your *MasterTable.csv file and run the CDP
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
options(shiny.maxRequestSize = 30*1024^2)
suppressWarnings(suppressMessages(library(data.table)))
suppressWarnings(suppressMessages(library(plyr)))
suppressWarnings(suppressMessages(library(dplyr)))
suppressWarnings(suppressMessages(library(reshape2)))
suppressWarnings(suppressMessages(library(GenomicFeatures)))
suppressWarnings(suppressMessages(library(GenomicRanges)))
suppressWarnings(suppressMessages(library(GenomeInfoDb)))
suppressWarnings(suppressMessages(library(Rsamtools)))
suppressWarnings(suppressMessages(library(GenomicAlignments)))
suppressWarnings(suppressMessages(library(ggplot2)))
suppressWarnings(suppressMessages(library(gplots)))
suppressWarnings(suppressMessages(library(RColorBrewer)))
suppressWarnings(suppressMessages(library(extrafont)))
suppressWarnings(suppressMessages(library(grid)))
suppressWarnings(suppressMessages(library(gridExtra)))
suppressWarnings(suppressMessages(library(reporttools)))
suppressWarnings(suppressMessages(library(rtracklayer)))
# suppressWarnings(suppressMessages(library(MVN)))
suppressWarnings(suppressMessages(library(ggrepel)))
suppressWarnings(suppressMessages(library(plyr)))
suppressWarnings(suppressMessages(library(dplyr)))
suppressWarnings(suppressMessages(library(ggpubr)))
suppressWarnings(suppressMessages(library(plotly)))
suppressWarnings(suppressMessages(library(idr)))
suppressWarnings(suppressMessages(library(htmlwidgets)))
suppressWarnings(suppressMessages(library(ggfortify)))
suppressWarnings(suppressMessages(library(mclust)))
suppressWarnings(suppressMessages(library(cowplot)))
source(paste0("ggCDPbamv1.R"))
```
```{r eruptions, echo=FALSE}
library(shinythemes)
# library(shinyWidgets)
ui <- fluidPage(theme = shinytheme("cerulean"),
titlePanel("Input Paramters"),
# setBackgroundColor("#FF8C00"),
sidebarLayout(
sidebarPanel(
fileInput("file", NULL, buttonLabel = "Upload...",
multiple = FALSE,
accept = ".csv"),
h6("Run"),
submitButton("Submit"),
radioButtons("radio1", h6("RNAseq differential expression"),
choices = list("gene expression" = "log2fC", "exon expression" = "log2fCexon", "intron expression" = "log2fCintron"),
selected = "log2fC"),
radioButtons("radio2", h6("PAR-CLIP target region"),
choices = list("gene" = "PARCLIPgene", "5' UTR" = "PARCLIP5UTR", "coding" = "PARCLIPCDS", "intron" = "PARCLIPintron", "3' UTR" = "PARCLIP3UTR"),
selected = "PARCLIPgene"),
h6("PAR-CLIP Calibration"),
checkboxInput("PARCLIPRNAseq", "divide by RNAseq", value = TRUE),
h6("PARCLIP Length Normalization"),
checkboxInput("PARCLIPL", "divide by Gene Length", value = TRUE),
numericInput("numg1",
h6("minimum gene expression in both"),
value = 1),
numericInput("numg2",
h6("minimum gene expression in either"),
value = 5),
numericInput("numg3",
h6("minimum transcript length"),
value = 500),
numericInput("nume1",
h6("minimum exon expression in both"),
value = 1),
numericInput("nume2",
h6("minimum exon expression in either"),
value = 5),
numericInput("nume3",
h6("minimum exon length"),
value = 200),
numericInput("numi1",
h6("minimum intron expression in both"),
value = 1),
numericInput("numi2",
h6("minimum intron expression in either"),
value = 5),
numericInput("numi3",
h6("minimum intron length"),
value = 200),
h6("include non-targets"),
checkboxInput("includeBin0", "Bin0", value = TRUE),
numericInput("gg1",
h6("lineSize"),
value = 0.5),
numericInput("gg2",
h6("panelBorderSize"),
value = 1),
numericInput("gg3",
h6("legendSpacing"),
value = 0.4),
numericInput("gg4",
h6("text size"),
value = 5)
),
mainPanel(
textOutput("text1"),
plotOutput("plot1"),
downloadButton("download")
)
)
)
# Define server logic ----
server <- function(input, output, session) {
output$text1 <- renderText({
paste("MasterTable:", input$file$name)
})
output$plot1 <- renderPlot({
data <- reactive({
req(input$file)
ext <- tools::file_ext(input$file$name)
switch(ext,
csv = vroom::vroom(input$file$datapath, delim = "\t"),
validate("Invalid file; Please upload a tab-delimited .csv file")
)
})
data()
inFile <- input$file
if (is.null(inFile))
return("NA")
MT <- read.csv(inFile$datapath, sep="\t", header = TRUE)
setDT(MT)
ggCDPbamv1(MasterTable = MT, plotByColumn=input$radio1, binColumn=input$radio2,
minTPM = input$numg2, maxTPM = Inf,
absminTPM = input$numg1, minTxSize = input$numg3,
minintron = input$numi2, absminintron = input$numi1, minIntronSize = input$numi3,
minexon = input$nume2, absminexon = input$nume1, minExonSize = input$nume3,
minExtensionRatio = 0.1, absminExtensionRatio = 0.01,
exprNormalization = input$PARCLIPRNAseq, # TRUE: calibrate binning by WT expression. False: Just use log2 of normalized XL
PARCLIPLengthNormalize = input$PARCLIPL,
includeBin0 = input$includeBin0, # TRUE: include bin0. FALSE: exclude bin0 and p-values.
lineSize = input$gg1,
panelBorderSize = input$gg2,
legendSpacing = input$gg3,
xlab = "Log2 Fold Change [Treatment/WT]",
ylab = "Cumulative Distribution",
axisTitleSize = input$gg4,
axisTextSize = input$gg4,
ggTitleSize = input$gg4,
legendTextSize = input$gg4
)
})
plotInput <- reactive({
inFile <- input$file
if (is.null(inFile))
return("NA")
MT <- read.csv(inFile$datapath, sep="\t", header = TRUE)
setDT(MT)
plotInput <- ggCDPbamv1(MasterTable = MT, plotByColumn=input$radio1, binColumn=input$radio2,
minTPM = input$numg2, maxTPM = Inf,
absminTPM = input$numg1, minTxSize = input$numg3,
minintron = input$numi2, absminintron = input$numi1, minIntronSize = input$numi3,
minexon = input$nume2, absminexon = input$nume1, minExonSize = input$nume3,
minExtensionRatio = 0.1, absminExtensionRatio = 0.01,
exprNormalization = input$PARCLIPRNAseq, # TRUE: calibrate binning by WT expression. False: Just use log2 of normalized XL
PARCLIPLengthNormalize = input$PARCLIPL,
includeBin0 = input$includeBin0, # TRUE: include bin0. FALSE: exclude bin0 and p-values.
lineSize = input$gg1,
panelBorderSize = input$gg2,
legendSpacing = input$gg3,
xlab = "Log2 Fold Change [Treatment/WT]",
ylab = "Cumulative Distribution",
axisTitleSize = input$gg4,
axisTextSize = input$gg4,
ggTitleSize = input$gg4,
legendTextSize = input$gg4
)
})
output$download <- downloadHandler(
filename = function() { paste0(sub(pattern = "(.*)\\..*$", replacement = "\\1",
input$file$name), '_CDP.png') },
content = function(file) {
device <- function(..., width = 15, height = 5) {
grDevices::png(..., width = width, height = height,
res = 300, units = "in")
}
save_plot(file, plot = plotInput(), device = device)
})
}
# Run the app ----
shinyApp(ui = ui, server = server)
#sessionInfo()
```