Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NMD complexes 2018 R_shiny
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Cosmin SAVEANU
NMD complexes 2018 R_shiny
Commits
5865aedc
Commit
5865aedc
authored
6 years ago
by
Cosmin SAVEANU
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
93ee0d5a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app.R
+121
-0
121 additions, 0 deletions
app.R
with
121 additions
and
0 deletions
app.R
0 → 100644
+
121
−
0
View file @
5865aedc
library
(
shiny
)
library
(
ggplot2
)
library
(
dplyr
)
library
(
magrittr
)
library
(
ggrepel
)
# this is a global part, ran probably only once.
enrichment
<-
readRDS
(
"data/enrichment.rds"
)
intensity
<-
readRDS
(
"data/intensity.rds"
)
# UI
ui
<-
fluidPage
(
title
=
"Yeast NMD data"
,
sidebarLayout
(
sidebarPanel
(
selectInput
(
"cole_x"
,
"x column ENRICHMENT"
,
names
(
enrichment
)[
c
(
-1
,
-2
)],
multiple
=
FALSE
,
selectize
=
TRUE
),
selectInput
(
"cole_y"
,
"y column ENRICHMENT"
,
names
(
enrichment
)[
c
(
-1
,
-2
)],
multiple
=
FALSE
,
selectize
=
TRUE
),
textOutput
(
"info_text"
),
plotOutput
(
"plot_e"
,
brush
=
brushOpts
(
id
=
"plot_e_brush"
)),
sliderInput
(
"lab_threshold"
,
label
=
"Labeling threshold value"
,
value
=
4
,
min
=
0
,
max
=
10
,
step
=
0.5
),
downloadButton
(
"save_plot"
,
label
=
"Download plot"
),
textOutput
(
"control_text"
),
plotOutput
(
"plot_i"
),
width
=
4
),
mainPanel
(
tabsetPanel
(
tabPanel
(
"Data table"
,
textOutput
(
"info_scrolltable"
),
DT
::
dataTableOutput
(
"mytable1"
),
width
=
8
),
tabPanel
(
"Documentation"
,
includeHTML
(
"Documentation.html"
))
)
)
)
)
# SERVER
server
<-
function
(
input
,
output
)
{
#Reactive that returns the whole dataset if there is no brush
selectedDataE
<-
reactive
({
datae
<-
brushedPoints
(
enrichment
,
input
$
plot_e_brush
)
if
(
nrow
(
datae
)
==
0
)
datae
<-
enrichment
datae
})
labelThreshold
<-
reactive
({
labthreshold
<-
input
$
lab_threshold
labthreshold
})
output
$
mytable1
<-
DT
::
renderDataTable
({
DT
::
datatable
(
selectedDataE
(),
filter
=
'top'
,
extensions
=
'Buttons'
,
options
=
list
(
lengthMenu
=
c
(
25
,
100
,
1000
),
pageLength
=
25
,
dom
=
'Bfrtip'
,
buttons
=
c
(
'copy'
,
'colvis'
),
scrollX
=
TRUE
),
colnames
=
gsub
(
names
(
enrichment
),
pattern
=
"([_\\.])"
,
replacement
=
" "
))
})
plotXY
=
function
()
{
thr
<-
labelThreshold
()
overN
<-
which
((
enrichment
[,
input
$
cole_x
]
>
thr
)
|
(
enrichment
[,
input
$
cole_y
]
>
thr
))
ggplot
(
data
=
enrichment
,
aes_string
(
x
=
input
$
cole_x
,
y
=
input
$
cole_y
))
+
geom_point
()
+
geom_text_repel
(
data
=
enrichment
[
overN
,
],
aes
(
label
=
Gene
))
+
ggtitle
(
"Enrichment (fold, log2 axes)"
)
}
plotXY_intensity
=
function
()
{
thr
<-
labelThreshold
()
overN
<-
which
((
enrichment
[,
input
$
cole_x
]
>
thr
)
|
(
enrichment
[,
input
$
cole_y
]
>
thr
))
ggplot
(
data
=
intensity
,
aes_string
(
x
=
input
$
cole_x
,
y
=
input
$
cole_y
))
+
geom_point
()
+
geom_text_repel
(
data
=
intensity
[
overN
,
],
aes
(
label
=
Gene
))
+
ggtitle
(
"LTOP2 values (log2 axes)"
)
}
saveplotFilename
<-
reactive
({
fname
<-
paste
(
"plot"
,
input
$
cole_x
,
'_'
,
input
$
cole_y
,
'.pdf'
,
sep
=
''
)
fname
})
output
$
plot_e
<-
renderPlot
({
plotXY
()
})
output
$
plot_i
<-
renderPlot
({
plotXY_intensity
()
})
output
$
info_text
<-
renderText
({
"(i) Click-drag selects region of the plot."
})
output
$
info_scrolltable
<-
renderText
({
"(i) Scroll right to see more columns --->"
})
output
$
control_text
<-
renderText
({
saveplotFilename
()
})
output
$
save_plot
<-
downloadHandler
(
filename
=
function
(){
saveplotFilename
()},
content
=
function
(
file
)
{
ggsave
(
file
,
plot
=
plotXY
(),
device
=
"pdf"
)
}
)
}
shinyApp
(
ui
,
server
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment