Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
shinyscreen
Manage
Activity
Members
Labels
Plan
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Environmental Cheminformatics
shinyscreen
Commits
61ebfc23
Commit
61ebfc23
authored
2 years ago
by
Todor Kondic
Browse files
Options
Downloads
Patches
Plain Diff
app: Reintroduced structures.
parent
b55019cb
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
R/plotting.R
+28
-23
28 additions, 23 deletions
R/plotting.R
R/resources.R
+2
-0
2 additions, 0 deletions
R/resources.R
R/shiny-ui-base.R
+42
-32
42 additions, 32 deletions
R/shiny-ui-base.R
inst/rmd/app.Rmd
+12
-2
12 additions, 2 deletions
inst/rmd/app.Rmd
with
84 additions
and
57 deletions
R/plotting.R
+
28
−
23
View file @
61ebfc23
...
@@ -348,7 +348,13 @@ theme_eic <- function(...) theme_light()+ggplot2::theme(axis.title=ggplot2::elem
...
@@ -348,7 +348,13 @@ theme_eic <- function(...) theme_light()+ggplot2::theme(axis.title=ggplot2::elem
legend.text
=
ggplot2
::
element_text
(
size
=
12L
),
legend.text
=
ggplot2
::
element_text
(
size
=
12L
),
plot.caption
=
ggplot2
::
element_text
(
size
=
12L
),
...
)
plot.caption
=
ggplot2
::
element_text
(
size
=
12L
),
...
)
theme_empty
<-
ggplot2
::
theme_bw
()
theme_empty
$
line
<-
ggplot2
::
element_blank
()
theme_empty
$
rect
<-
ggplot2
::
element_blank
()
theme_empty
$
strip.text
<-
ggplot2
::
element_blank
()
theme_empty
$
axis.text
<-
ggplot2
::
element_blank
()
theme_empty
$
plot.title
<-
ggplot2
::
element_blank
()
theme_empty
$
axis.title
<-
ggplot2
::
element_blank
()
sci10
<-
function
(
x
)
{
sci10
<-
function
(
x
)
{
prefmt
<-
formatC
(
x
,
format
=
"e"
,
digits
=
2
)
prefmt
<-
formatC
(
x
,
format
=
"e"
,
digits
=
2
)
...
@@ -438,18 +444,21 @@ get_data_4_eic_ms1 <- function(extr_ms1,kvals,labs) {
...
@@ -438,18 +444,21 @@ get_data_4_eic_ms1 <- function(extr_ms1,kvals,labs) {
}
}
## Prepare MS2 eic data: rt and intensity + key made of splitby.
## Prepare MS2 eic data: rt and intensity + key made of splitby.
get_data_4_eic_ms2
<-
function
(
summ
,
adduct
,
id
,
splitby
)
{
get_data_4_eic_ms2
<-
function
(
summ
,
kvals
,
labs
)
{
key
<-
list
(
adduct
=
adduct
,
ID
=
id
)
tab
<-
get_data_from_key
(
tab
=
summ
,
key
=
kvals
)
tab
<-
get_data_from_key
(
tab
=
summ
,
key
=
key
)
nms
<-
names
(
kvals
)
pdata
<-
tab
[,
.
(
intensity
=
ms2_int
,
rt
=
ms2_rt
),
by
=
c
(
'ID'
,
splitby
,
"an"
)]
byby
<-
unique
(
c
(
nms
,
labs
,
"an"
))
pdata
<-
eval
(
bquote
(
pdata
[,
label
:=
make_line_label
(
..
(
lapply
(
splitby
,
as.symbol
))),
by
=
.
(
splitby
)],
splice
=
T
))
pdata
<-
tab
[,
.
(
intensity
=
ms2_int
,
rt
=
ms2_rt
),
by
=
byby
]
setkeyv
(
pdata
,
cols
=
c
(
"ID"
,
splitby
,
"rt"
))
if
(
NROW
(
pdata
)
==
0L
)
return
(
NULL
)
xlxx
<-
as.character
(
labs
)
pdata
<-
eval
(
bquote
(
pdata
[,
label
:=
make_line_label
(
..
(
lapply
(
xlxx
,
as.symbol
))),
by
=
.
(
xlxx
)],
splice
=
T
))
setkeyv
(
pdata
,
cols
=
c
(
labs
,
"rt"
))
pdata
pdata
}
}
make_eic_ms1_plot
<-
function
(
extr_ms1
,
summ
,
kvals
,
labs
,
axis
=
"linear"
,
rt_range
=
NULL
)
{
make_eic_ms1_plot
<-
function
(
extr_ms1
,
summ
,
kvals
,
labs
,
axis
=
"linear"
,
rt_range
=
NULL
,
asp
=
0.5
)
{
## Get the table with ms1 data.
## Get the table with ms1 data.
...
@@ -465,7 +474,7 @@ make_eic_ms1_plot <- function(extr_ms1,summ,kvals,labs,axis="linear",rt_range=NU
...
@@ -465,7 +474,7 @@ make_eic_ms1_plot <- function(extr_ms1,summ,kvals,labs,axis="linear",rt_range=NU
dy
<-
abs
(
yrng
[[
2
]]
-
yrng
[[
1
]])
dy
<-
abs
(
yrng
[[
2
]]
-
yrng
[[
1
]])
## Calculate aspect ratio.
## Calculate aspect ratio.
aspr
<-
if
(
dx
<
.Machine
$
double.eps
)
1
else
0.5
*
as.numeric
(
dx
)
/
as.numeric
(
dy
)
aspr
<-
if
(
dx
<
.Machine
$
double.eps
)
1
else
asp
*
as.numeric
(
dx
)
/
as.numeric
(
dy
)
tag_txt
=
paste0
(
sapply
(
names
(
kvals
),
function
(
nx
)
paste0
(
nx
,
": "
,
kvals
[[
nx
]])),
tag_txt
=
paste0
(
sapply
(
names
(
kvals
),
function
(
nx
)
paste0
(
nx
,
": "
,
kvals
[[
nx
]])),
...
@@ -486,22 +495,17 @@ make_eic_ms1_plot <- function(extr_ms1,summ,kvals,labs,axis="linear",rt_range=NU
...
@@ -486,22 +495,17 @@ make_eic_ms1_plot <- function(extr_ms1,summ,kvals,labs,axis="linear",rt_range=NU
}
}
make_eic_ms2_plot
<-
function
(
summ
,
key
,
splitby
,
axis
=
"linear"
,
rt_range
=
NULL
)
{
make_eic_ms2_plot
<-
function
(
summ
,
kvals
,
labs
,
axis
=
"linear"
,
rt_range
=
NULL
,
asp
=
0.5
)
{
set
<-
key
[[
'set'
]]
## TODO
id
<-
key
[[
'id'
]]
adduct
<-
key
[[
'adduct'
]]
key
<-
list
(
set
=
set
,
adduct
=
adduct
,
ID
=
id
)
## Get plotting data for the compound.
## Get plotting data for the compound.
pdata
<-
get_data_4_eic_ms2
(
summ
,
pdata
<-
get_data_4_eic_ms2
(
summ
,
adduct
=
adduct
,
kvals
=
kvals
,
id
=
id
,
labs
=
labs
)
splitby
=
splitby
)
if
(
NROW
(
pdata
)
==
0L
)
return
(
NULL
)
## Get metadata.
## Get metadata.
summ_row
<-
get_data_from_key
(
summ
,
key
=
k
ey
)
summ_row
<-
get_data_from_key
(
summ
,
key
=
k
vals
)
## Deal with retention time range.
## Deal with retention time range.
rt_lim
<-
if
(
is.null
(
rt_range
))
NULL
else
ggplot2
::
xlim
(
rt_range
)
rt_lim
<-
if
(
is.null
(
rt_range
))
NULL
else
ggplot2
::
xlim
(
rt_range
)
...
@@ -511,10 +515,11 @@ make_eic_ms2_plot <- function(summ,key,splitby,axis="linear",rt_range=NULL) {
...
@@ -511,10 +515,11 @@ make_eic_ms2_plot <- function(summ,key,splitby,axis="linear",rt_range=NULL) {
dy
<-
abs
(
yrng
[[
2
]]
-
yrng
[[
1
]])
dy
<-
abs
(
yrng
[[
2
]]
-
yrng
[[
1
]])
## Fix aspect ratio.
## Fix aspect ratio.
aspr
<-
if
(
dx
<
.Machine
$
double.eps
)
1
else
0.5
*
as.numeric
(
dx
)
/
as.numeric
(
dy
)
aspr
<-
if
(
dx
<
.Machine
$
double.eps
)
1
else
asp
*
as.numeric
(
dx
)
/
as.numeric
(
dy
)
## Derive various labels.
## Derive various labels.
tag_txt
=
paste0
(
"Set: "
,
set
,
" ID: "
,
id
)
tag_txt
=
paste0
(
sapply
(
names
(
kvals
),
function
(
nx
)
paste0
(
nx
,
": "
,
kvals
[[
nx
]])),
collapse
=
'; '
)
title_txt
=
paste0
(
"MS2 EIC for ion m/z = "
,
paste0
(
signif
(
unique
(
summ_row
$
mz
),
digits
=
7L
),
collapse
=
", "
))
title_txt
=
paste0
(
"MS2 EIC for ion m/z = "
,
paste0
(
signif
(
unique
(
summ_row
$
mz
),
digits
=
7L
),
collapse
=
", "
))
subt_txt
=
if
(
!
length
(
summ_row
$
Name
)
==
0L
&&
!
is.na
(
summ_row
$
Name
)
&&
nchar
(
summ_row
$
Name
)
>
0L
)
summ_row
$
Name
else
NULL
subt_txt
=
if
(
!
length
(
summ_row
$
Name
)
==
0L
&&
!
is.na
(
summ_row
$
Name
)
&&
nchar
(
summ_row
$
Name
)
>
0L
)
summ_row
$
Name
else
NULL
## Base plot.
## Base plot.
...
...
This diff is collapsed.
Click to expand it.
R/resources.R
+
2
−
0
View file @
61ebfc23
...
@@ -292,3 +292,5 @@ ARRANGE_CHOICES <- c(nothing="nothing",
...
@@ -292,3 +292,5 @@ ARRANGE_CHOICES <- c(nothing="nothing",
mz
=
"mz"
,
mz
=
"mz"
,
rt
=
"rt"
,
rt
=
"rt"
,
id
=
"ID"
)
id
=
"ID"
)
PLOT_EIC_ASPECT
<-
0.75
This diff is collapsed.
Click to expand it.
R/shiny-ui-base.R
+
42
−
32
View file @
61ebfc23
...
@@ -767,53 +767,59 @@ mk_shinyscreen_server <- function(projects,init) {
...
@@ -767,53 +767,59 @@ mk_shinyscreen_server <- function(projects,init) {
})
})
req
(
NROW
(
summ
)
>
0L
)
req
(
NROW
(
summ
)
>
0L
)
req
(
NROW
(
ms1
)
>
0L
)
req
(
NROW
(
ms1
)
>
0L
)
make_eic_ms1_plot
(
ms1
,
summ
,
kvals
=
req
(
rf_get_cindex_kval
()),
labs
=
req
(
rf_get_cindex_labs
()))
make_eic_ms1_plot
(
ms1
,
summ
,
kvals
=
req
(
rf_get_cindex_kval
()),
labs
=
req
(
rf_get_cindex_labs
()),
asp
=
PLOT_EIC_ASPECT
)
})
})
rf_plot_eic_ms2
<-
reactive
({
rf_plot_eic_ms2
<-
reactive
({
isolate
({
isolate
({
summ
<-
rvs
$
m
$
out
$
tab
$
summ
summ
<-
rvs
$
m
$
out
$
tab
$
summ
cind
<-
rf_get_cindex
()
})
})
req
(
NROW
(
summ
)
>
0L
)
req
(
NROW
(
summ
)
>
0L
)
req
(
NROW
(
cind
)
>
0L
)
row
<-
input
$
cindex_row_last_clicked
req
(
row
)
sel
<-
cind
[
row
]
gg
<-
rf_plot_eic_ms1
()
gg
<-
rf_plot_eic_ms1
()
rt_rng
<-
range
(
gg
$
data
$
rt
)
rt_rng
<-
range
(
gg
$
data
$
rt
)
make_eic_ms2_plot
(
summ
,
make_eic_ms2_plot
(
summ
,
key
=
rf_get_cindex_kval
(),
kvals
=
rf_get_cindex_kval
(),
splitby
=
c
(
"tag"
),
labs
=
rf_get_cindex_labs
(),
rt_range
=
rt_rng
)
rt_range
=
rt_rng
,
asp
=
PLOT_EIC_ASPECT
)
})
})
rf_plot_spec_ms2
<-
reactive
({
rf_plot_struct
<-
reactive
({
isolate
({
cind
<-
rf_get_cindex
()
summ
<-
rvs
$
m
$
out
$
tab
$
summ
key
<-
rf_get_cindex_key
()
ms2
<-
rvs
$
m
$
extr
$
ms2
cind
<-
rf_get_cindex
()
})
req
(
NROW
(
summ
)
>
0L
)
req
(
NROW
(
ms2
)
>
0L
)
req
(
NROW
(
cind
)
>
0L
)
req
(
NROW
(
cind
)
>
0L
)
row
<-
input
$
cindex_row_last_clicked
row
<-
req
(
input
$
cindex_row_last_clicked
)
req
(
row
)
id
<-
rowtab
<-
cind
[
row
][,
..key
][[
"ID"
]][[
1
]]
sel
<-
cind
[
row
]
smi
<-
rvs
$
m
$
out
$
tab
$
comp
[
ID
==
(
id
),
SMILES
][[
1
]]
print
(
"smiles:"
)
make_spec_ms2_plot
(
ms2
,
print
(
smi
)
summ
,
grb
<-
smiles2img
(
smi
)
set
=
sel
$
set
,
xx
<-
qplot
(
1
:
5
,
2
*
(
1
:
5
),
geom
=
"blank"
)
+
adduct
=
sel
$
adduct
,
annotation_custom
(
grb
,
xmin
=-
Inf
,
xmax
=
Inf
,
ymin
=-
Inf
,
ymax
=
Inf
)
+
id
=
sel
$
ID
,
theme_empty
splitby
=
c
(
"adduct"
,
"tag"
))
xx
})
})
## rf_plot_spec_ms2 <- reactive({
## isolate({
## summ <- rvs$m$out$tab$summ
## ms2 <- rvs$m$extr$ms2
## })
## req(NROW(summ)>0L)
## req(NROW(ms2)>0L)
## req(NROW(cind)>0L)
## make_spec_ms2_plot(ms2,
## summ,
## kvals=req(rf_get_cindex_kval()),
## labs=req(rf_get_cindex_labs()))
## })
## OBSERVERS
## OBSERVERS
...
@@ -1227,9 +1233,13 @@ mk_shinyscreen_server <- function(projects,init) {
...
@@ -1227,9 +1233,13 @@ mk_shinyscreen_server <- function(projects,init) {
output
$
plot_eic_combined
<-
renderPlot
({
output
$
plot_eic_combined
<-
renderPlot
({
p1
<-
rf_plot_eic_ms1
()
p1
<-
rf_plot_eic_ms1
()
p2
<-
NULL
#
rf_plot_eic_ms2()
p2
<-
rf_plot_eic_ms2
()
combine_plots
(
p1
,
p2
)
combine_plots
(
p1
,
p2
)
})
})
output
$
plot_struct
<-
renderPlot
({
rf_plot_struct
()
})
## output$plot_eic_ms1 <- renderPlot({
## output$plot_eic_ms1 <- renderPlot({
## rf_plot_eic_ms1()
## rf_plot_eic_ms1()
## })
## })
...
@@ -1239,7 +1249,7 @@ mk_shinyscreen_server <- function(projects,init) {
...
@@ -1239,7 +1249,7 @@ mk_shinyscreen_server <- function(projects,init) {
## })
## })
output
$
plot_spec_ms2
<-
renderPlot
({
output
$
plot_spec_ms2
<-
renderPlot
({
rf_plot_spec_ms2
()
NULL
#
rf_plot_spec_ms2()
})
})
...
...
This diff is collapsed.
Click to expand it.
inst/rmd/app.Rmd
+
12
−
2
View file @
61ebfc23
...
@@ -666,6 +666,8 @@ DT::DTOutput("cindex")
...
@@ -666,6 +666,8 @@ DT::DTOutput("cindex")
<div style="display: flex-flow: column nowrap">
<div style="display: flex-flow: column nowrap">
### Viewer
### Viewer
<div style="display: flex; flex-direction: row; flex-wrap: nowrap;">
<div style="width: 70%;"> <!-- EIC ID Plot -->
```{r,echo=F}
```{r,echo=F}
## plotOutput("plot_eic_ms1",
## plotOutput("plot_eic_ms1",
## hover = hoverOpts(id="plot_hover",
## hover = hoverOpts(id="plot_hover",
...
@@ -693,14 +695,22 @@ plotOutput("plot_eic_combined",
...
@@ -693,14 +695,22 @@ plotOutput("plot_eic_combined",
dblclick = "plot_rt_click",
dblclick = "plot_rt_click",
brush = "plot_brush")
brush = "plot_brush")
```
</div> <!-- EIC ID Plot -->
<div style="width: 30%;"> <!-- Structure -->
```{r, echo=F}
plotOutput("plot_struct")
```
</div>
</div>
```{r, echo=F}
plotOutput("plot_spec_ms2",
plotOutput("plot_spec_ms2",
hover = hoverOpts(id="plot_hover",
hover = hoverOpts(id="plot_hover",
delayType = "throttle",
delayType = "throttle",
delay=100),
delay=100),
dblclick = "plot_mz_click",
dblclick = "plot_mz_click",
brush = brushOpts(id="plot_mz_brush"))
brush = brushOpts(id="plot_mz_brush"))
```
```
<div style="display: flex-flow: row nowrap"> <!-- Control Bar -->
<div style="display: flex-flow: row nowrap"> <!-- Control Bar -->
...
...
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