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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Miroslav Kratochvil
shinyscreen
Commits
ad9fc7bc
Unverified
Commit
ad9fc7bc
authored
4 years ago
by
Todor Kondic
Browse files
Options
Downloads
Patches
Plain Diff
mix,resources,app: Drop config save/restore; replace with state
parent
5ada5694
No related branches found
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
NAMESPACE
+1
-0
1 addition, 0 deletions
NAMESPACE
R/mix.R
+19
-0
19 additions, 0 deletions
R/mix.R
R/resources.R
+1
-2
1 addition, 2 deletions
R/resources.R
inst/rmd/app.Rmd
+79
-60
79 additions, 60 deletions
inst/rmd/app.Rmd
with
100 additions
and
62 deletions
NAMESPACE
+
1
−
0
View file @
ad9fc7bc
...
...
@@ -34,5 +34,6 @@ export(save_plots)
export(setup_phase)
export(sort_spectra)
export(subset_summary)
export(tk_save_file)
import(data.table)
importFrom(shiny,validate)
This diff is collapsed.
Click to expand it.
R/mix.R
+
19
−
0
View file @
ad9fc7bc
...
...
@@ -701,6 +701,7 @@ read_setid <- function(fn,cmpds) {
write_conf
<-
function
(
m
,
fn
)
{
m
$
conf
$
data
<-
get_fn_ftab
(
m
)
if
(
NROW
(
m
$
input
$
tab
$
mzml
)
>
0
)
tab2file
(
tab
=
m
$
input
$
tab
$
mzml
,
file
=
file.path
(
m
$
conf
$
project
,
FN_DATA_TAB
))
yaml
::
write_yaml
(
x
=
m
$
conf
,
file
=
fn
)
...
...
@@ -1252,3 +1253,21 @@ plot_leg_ms2 <- function(df,style_fun) {
cowplot
::
get_legend
(
plot
)
}
#' @export
tk_save_file
<-
function
(
default
=
""
,
caption
=
"Select files"
,
filters
=
NULL
,
index
=
1
)
{
args
<-
list
(
"tk_getSaveFile"
,
title
=
caption
)
if
(
nzchar
(
default
))
args
<-
c
(
args
,
initialdir
=
dirname
(
default
),
initialfile
=
basename
(
default
))
if
(
!
is.null
(
filters
))
{
if
(
!
is.character
(
filters
)
||
length
(
dim
(
filters
))
!=
2
||
ncol
(
filters
)
!=
2
)
stop
(
"'filters' must be a 2-column character matrix"
)
f
<-
filters
f
[]
<-
paste0
(
"{"
,
filters
,
"}"
)
ff
<-
apply
(
f
,
1
,
paste
,
collapse
=
" "
)
fff
<-
paste0
(
"{"
,
ff
,
"}"
)
args
<-
c
(
args
,
filetypes
=
paste
(
fff
,
collapse
=
" "
))
}
as.character
(
do.call
(
tcltk
::
tcl
,
args
))
}
This diff is collapsed.
Click to expand it.
R/resources.R
+
1
−
2
View file @
ad9fc7bc
...
...
@@ -198,8 +198,7 @@ REPORT_TITLE <- "Plots of EICs and MS2 Spectra"
PLOT_FEATURES
<-
c
(
"set"
,
"adduct"
,
"tag"
,
"ID"
,
"CE"
)
"ID"
)
## Select the most fundamental group of entries. Within this group,
## each ID is unique.
...
...
This diff is collapsed.
Click to expand it.
inst/rmd/app.Rmd
+
79
−
60
View file @
ad9fc7bc
...
...
@@ -348,6 +348,44 @@ shinyscreen::rt_input(input_rt = "plot_rt_max",
pref = "max:")
```
### Grouping plots
<details><summary>How to group plots?</summary>
The _Select plot group_ and _Select plot label_ controls control how
the data is visually grouped together. The _plot group_ groups
together multiple curves in a single graph. Each curve in a graph is
designated by the _plot label_.
</details>
<div style= "display: flex; vertical-align:top; ">
<div style="padding-right:0.5em;">
```{r, echo=F}
p_feats <- 1:length(shinyscreen:::PLOT_FEATURES)
names(p_feats) <- shinyscreen:::PLOT_FEATURES
selectInput(inputId = "plot_grp_plot",
label = "Select plot group",
choices = p_feats,
selected = p_feats[[shinyscreen:::FIG_DEF_CONF$grouping[["plot"]]]],
width = "100%")
```
</div>
<div style="padding-left:0.5em;">
```{r, echo=F}
p_feats <- 1:length(shinyscreen:::PLOT_FEATURES)
names(p_feats) <- shinyscreen:::PLOT_FEATURES
selectInput(inputId = "plot_label",
label = "Select plot label",
choices = p_feats,
selected = p_feats[[shinyscreen:::FIG_DEF_CONF$grouping[["label"]]]],
width = "100%")
```
</div>
</div>
## Report
```{r, echo=F}
...
...
@@ -370,33 +408,19 @@ DT::dataTableOutput("setid_table")
# Save and Restore
## Save and Restore from a Config File
Shinyscreen uses _YAML_ config files to initialise the
computation. These operations only save and restore the input
parameters of your computation, _**not**_ your data.
```{r, echo=FALSE}
actionButton(inputId = "conf_file_load_b",
label= "Load project config")
```
Shinyscreen can start from either a previously saved _state_ file (in
RDS format), or from a _YAML_ config file. States saved using GUI can
also be used from the script.
```{r, echo=FALSE}
actionButton(inputId = "
conf
_file_
save
_b",
label= "
Save config
")
actionButton(inputId = "
state
_file_
load
_b",
label= "
Restore project state
")
```
## Restore the project
To retrieve a previously extracted data, restore the project state
here. It is also possible to load it in a script (the state is saved
in the _RDS_ format).
```{r, echo=FALSE}
actionButton(inputId = "state_file_
load
_b",
label= "
Restor
e project state")
actionButton(inputId = "state_file_
save
_b",
label= "
Sav
e project state")
```
...
...
@@ -505,8 +529,6 @@ ord_asc <- grepl("^-.+",shinyscreen:::DEF_INDEX_SUMM)
ord_asc <- factor(ifelse(ord_asc, "descending", "ascending"),levels = c("ascending","descending"))
def_ord_summ <- shinyscreen:::dtable("Column Name"=ord_nms,"Direction"=ord_asc)
update_gui <- function(in_conf, session) {
upd_unit <- function(entry,inp_val,inp_unit,choices) {
if (isTruthy(entry)) {
...
...
@@ -584,7 +606,7 @@ update_gui <- function(in_conf, session) {
## Files
df <- shinyscreen:::file2tab(in_conf$data)
df[,tag:=as.character(tag),with=T]
rv_dfiles(df[,.(File=Files,tag)])
rv_dfiles(df[,.(File=Files,tag)
,by=c("Files","tag"),mult="first"
])
nms <- colnames(df)
nms <- nms[nms!="Files"]
fdt <- df[,..nms]
...
...
@@ -791,7 +813,8 @@ observe({
observe({
dtab <- rv_datatab()
dfiles <- rv_dfiles()
print(dtab)
print(dfiles)
message("(config) Generating mzml from rv.")
isolate(rv_state$input$tab$mzml <- dtab[dfiles,on="tag"])
...
...
@@ -872,56 +895,52 @@ observeEvent(input$plot_b,{
eval(z)
})
observeEvent(input$conf_file_save_b,
{
state <- rf_conf_state()
ftab <- get_fn_ftab(state)
fconf <- get_fn_conf(state)
yaml::write_yaml(state$conf,
file = fconf)
shinyscreen:::tab2file(tab=state$input$tab$mzml,file=ftab)
message("Written data-file table to ",ftab)
message("Written config to ",fconf)
})
observeEvent(input$conf_file_load_b,
{
filters <- matrix(c("YAML files", ".yaml",
observeEvent(input$state_file_load_b,{
filters <- matrix(c("RDS files", ".rds",
"YAML config files", ".yaml",
"All files", "*"),
2
, 2, byrow = TRUE)
3
, 2, byrow = TRUE)
fn <- tcltk::tk_choose.files(filters=filters,
multi = F)
message("(config) Loading config from: ", paste(fn,collapse = ","))
message("(config) Loading state from: ", paste(fn,collapse = ","))
fn <- if (length(fn)>0 && nchar(fn[[1]])>0) fn else ""
if (nchar(fn) > 0) {
state <- new_state_fn_conf(fn)
conf <- state$conf
update_gui(conf,session=session)
}
if (grepl("yaml",fn)) {
state <- new_state_fn_conf(fn)
conf <- state$conf
update_gui(conf,session=session)
} else {
state <- readRDS(file=fn)
z <- shinyscreen::merge2rev(rv_state,lst = state)
eval(z)
update_gui(rv_state$conf, session=session)
}
}
})
observeEvent(input$state_file_
load
_b,{
observeEvent(input$state_file_
save
_b,{
filters <- matrix(c("RDS files", ".rds",
"All files", "*"),
2, 2, byrow = TRUE)
fn <- t
cltk::tk_choose.
file
s
(filters=filters,
m
ult
i
=
F
)
message("(config)
Load
ing state
from
: ", paste(fn,collapse = ","))
fn <- t
k_save_
file(filters=filters,
defa
ult =
"state.rds"
)
message("(config)
Sav
ing state
to
: ", paste(fn,collapse = ","))
fn <- if (length(fn)>0 && nchar(fn[[1]])>0) fn else ""
if (nchar(fn) > 0) {
state <- readRDS(file=fn)
z <- shinyscreen::merge2rev(rv_state,lst = state)
print(z)
eval(z)
update_gui(rv_state$conf, session=session)
m <- rev2list(rv_state)
ftab <- get_fn_ftab(m)
fconf <- get_fn_conf(m)
yaml::write_yaml(m$conf,
file = fconf)
shinyscreen:::tab2file(tab=m$input$tab$mzml,file=ftab)
m$conf$data <- ftab
saveRDS(object=m,file=fn)
}
})
...
...
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