From b8e3f9aa96c819c81b4717f8ca67e2ff255990ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Todor=20Kondi=C4=87?= <kontrapunkt@uclmail.net> Date: Thu, 26 Jan 2023 11:33:16 +0100 Subject: [PATCH] app: Restructuring Viewer * app_results_explorer_cindex: New file. * app_results_explorer_cindex_controls: New file. --- R/api.R | 11 +- R/shiny-ui-base.R | 25 ++- inst/rmd/app.Rmd | 211 +----------------- inst/rmd/app_config_and_status.Rmd | 3 + inst/rmd/app_results_explorer_cindex.Rmd | 22 ++ .../app_results_explorer_cindex_controls.Rmd | 18 ++ inst/www/custom.css | 16 ++ 7 files changed, 99 insertions(+), 207 deletions(-) create mode 100644 inst/rmd/app_results_explorer_cindex.Rmd create mode 100644 inst/rmd/app_results_explorer_cindex_controls.Rmd diff --git a/R/api.R b/R/api.R index 46e2f71..9dfd886 100644 --- a/R/api.R +++ b/R/api.R @@ -697,12 +697,17 @@ prepare_app <- function(dir_before, dir_start <- tempfile("shinyscreen") dir.create(dir_start, recursive = T) + ## Get list of app document contents. + dir_rmd = system.file("rmd",package = "shinyscreen") + fnms_rmd = list.files(dir_rmd,pattern = r"(^app.*\.Rmd$)",full.names=T) + ## Copy startup files to that location. dir.create(file.path(dir_start,'www'), showWarnings=F) saveRDS(object = init,file=file.path(dir_start,"init.rds")) - file.copy(system.file(file.path("rmd","app.Rmd"),package = "shinyscreen"),file.path(dir_start,"app_run.Rmd")) - file.copy(system.file(file.path("rmd","app_config_and_status.Rmd"),package = "shinyscreen"),file.path(dir_start,"app_config_and_status.Rmd")) + file.copy(system.file(file.path("www","custom.css"),package = "shinyscreen"),file.path(dir_start,"www","custom.css")) + for (fn in fnms_rmd) file.copy(fn,file.path(dir_start,basename(fn))) + dir_start } @@ -736,7 +741,7 @@ app <- function(projects=getwd(), on.exit(expr=setwd(dir_before)) setwd(dir_start) - rmarkdown::run(file = "app_run.Rmd", shiny_args = shiny_args, render_args = render_args) + rmarkdown::run(file = "app.Rmd", shiny_args = shiny_args, render_args = render_args) } diff --git a/R/shiny-ui-base.R b/R/shiny-ui-base.R index 8193bc7..3bbce3a 100644 --- a/R/shiny-ui-base.R +++ b/R/shiny-ui-base.R @@ -1213,13 +1213,36 @@ mk_shinyscreen_server <- function(projects,init) { updateSelectInput(session=session, inputId="mf_local_database", choices=list.files(path=init$envopts$metfrag$db_dir, - pattern=patt)) + pattern=patt), + selected=character(0)) } else { updateSelectInput(session=session, inputId="mf_local_database", choices=character(0)) } }, label = "mf-database-type") + + observeEvent(input$mf_local_database,{ + + fn = input$mf_local_database + + if (length(fn) && nchar(fn)>0L) { + e = init$envopts + dbdir = e$metfrag$db_dir + fn = file.path(dbdir,fn) + dtnms = data.table::fread(file=fn,nrows=1L) + nms = names(dtnms) + updateSelectInput(session=session, + inputId="mf_local_db_col_ident", + choices = c(character(0),nms), + selected = character(0)) + updateSelectInput(session=session, + inputId="mf_local_db_col_scores", + choices = c(character(0),nms), + selected = character(0)) + } + + }, label = "mf-local-database") ## OBSERVERS: VIEWER diff --git a/inst/rmd/app.Rmd b/inst/rmd/app.Rmd index bad1dcb..2cb33f0 100644 --- a/inst/rmd/app.Rmd +++ b/inst/rmd/app.Rmd @@ -394,212 +394,17 @@ actionButton(inputId = "presc_b", ## Results Explorer - -<div style="display: flex; flex-flow: column nowrap;"> -<div style="display: flex; flex-flow: column; padding-right:1.0em"> - -### Compound Index - -```{r, echo=F} -selectInput("cindex_group",label="Group", - choices=c(NA_character_, - "adduct","tag"), - multiple=T, - selected=c("adduct","tag")) -``` - -<div style="display: flex; flex-flow: row nowrap"> -```{r, echo=F} -selectInput("sort1",label="Sort by ", choices=shinyscreen:::ARRANGE_CHOICES,width="15%",selected="quality") -selectInput("sort2",label="then by ", choices=shinyscreen:::ARRANGE_CHOICES,width="15%",selected="mz") -selectInput("sort3",label="then", choices=shinyscreen:::ARRANGE_CHOICES,width="15%") -selectInput("sort4",label="and finally by", choices=shinyscreen:::ARRANGE_CHOICES,width="15%") -``` -</div> <!-- Arrange --> - -<div> -```{r, echo=F} -DT::DTOutput("cindex") -``` - -</div> <!-- cindex --> - -</div> <!-- Compound Explorer Panel --> - -### Viewer - -<div class="plot-layout"> <!-- Plot Section --> -<div> -```{r, echo=F} -plotOutput("plot_eic_ms1", - hover = hoverOpts(id="plot_hover", - delayType = "throttle", - delay=100), - dblclick = "plot_rt_click", - brush = "plot_brush") -``` -</div> -<div> -```{r, echo=F} -plotOutput("plot_struct") -``` -</div> -<div> -```{r, echo=F} -plotOutput("plot_eic_ms2", - hover = hoverOpts(id="plot_hover", - delayType = "throttle", - delay=100), - dblclick = "plot_rt_click", - brush = "plot_brush") -``` -</div> -<div> - -#### Tweak Plot Parameters - -```{r, echo=F} -textOutput("plot_hover_out") -``` - -#### Retention Time Range - -<div style="display:flex; flex-direction: row;"> <!-- RT div --> -```{r, echo=F} -numericInput(inputId = "plot_rt_min", - label="Start", - value=NA_real_, - width="30%") +<div class='flex-layers'> <!-- cindex --> +<div> <!-- cindex-cindex --> +```{r, child='app_results_explorer_cindex.Rmd'} ``` -```{r, echo=F} -numericInput(inputId = "plot_rt_max", - label="End", - value=NA_real_, - width="30%") - - -``` -</div> <!-- RT div --> - -#### Intensity Range (MS1) - -<div style="display:flex; flex-direction: row;"> <!-- Intensity div --> -```{r, echo=F} -numericInput(inputId = "plot_i_min", - label="Start", - value=NA_real_, - width="30%") +</div> <!-- cindex-cindex --> +<div> <!-- cindex-controls --> +```{r, child='app_results_explorer_cindex_controls.Rmd'} ``` -```{r, echo=F} -numericInput(inputId = "plot_i_max", - label="End", - value=NA_real_, - width="30%") - - -``` -</div> <!-- Intensity div --> - -#### Report - -<div style="display: flex-flow: row nowrap"> <!-- Control Bar --> -```{r, echo=F} -textInput("single_plot_fname", - label="Filename of the single entry plot", - value="default.pdf") -actionButton("plot_save_single", - label="Save single entry plot") -textInput("report_name", - label="Report Name", - value="report") -actionButton("make_report_b", - label="Create report") -textInput("summ_name", - label="Summary table name", - value="summary.csv") -actionButton("summ_tab_b", "Save summary table") - -textInput("ms2_spectra_tab_name", - label="Table of MS2 spectra", - value="ms2_spectra_table.csv") -actionButton("ms2_spectra_tab_b", "Save MS2 spectra table") -``` - -</div> <!-- Control Bar --> - -</div> -<div> -```{r, echo=F} -plotOutput("plot_spec_ms2", - hover = hoverOpts(id="plot_hover", - delayType = "throttle", - delay=100), - dblclick = "plot_mz_click", - brush = brushOpts(id="plot_mz_brush")) -``` -</div> -<div></div> -</div> <!-- Plots --> - - -### Measurement Properties - -<div class="measure-prop-sec"> - -<div class="sel-spec"> <!-- sel-spec --> - -#### Select Spectrum - -```{r, echo=F} -selectInput("sel_parent_trace",label="Select parent", choices=character(),size=10L,selectize=F) -``` - -```{r, echo=F} -selectInput("sel_spec",label="Select spectrum", choices=character(),size=10L,selectize=F) -``` - -```{r, echo=F} -actionButton("cmt_changes_b",label="Commit changes") -``` - -</div> <!-- sel-spec --> - -<div class="measure-props"> <!-- measure-props --> - -#### Properties - -```{r,echo=F} -numericInput(inputId="chg_ms1_rt", - label="Retention time (MS1)", - value=NA_real_) -numericInput(inputId="chg_ms1_int", - label="Intensity (MS1)", - value=NA_real_) -``` - -```{r,echo=F} -checkboxGroupInput(inputId="qabox", - label="Quality Control", - choices=QABOX_VALS) -``` -```{r,echo=F} -checkboxInput(inputId="chg_ms2sel", - label="MS2 Selected", - value=F) -``` -</div> <!-- measure-props --> - -<div class="spec-tab"> <!-- spec tab --> - -#### Mass Spectrum - -```{r, echo=F} -verbatimTextOutput("print_spec_tab") -``` - -</div> <!-- spec tab --> +</div> <!-- cindex-controls --> +</div> <!-- cindex --> -</div> <!-- measure-prop-sec --> <!-- ENGINE --> diff --git a/inst/rmd/app_config_and_status.Rmd b/inst/rmd/app_config_and_status.Rmd index 29f5fb8..8e4229b 100644 --- a/inst/rmd/app_config_and_status.Rmd +++ b/inst/rmd/app_config_and_status.Rmd @@ -211,6 +211,7 @@ selectInput("mf_local_database", choices=character(0)) selectInput("mf_local_db_col_ident", label="Select Identifiers", + multiple = T, choices=character(0)) ``` @@ -224,6 +225,7 @@ selectInput("mf_local_db_col_ident", selectInput("mf_scores_intrinsic", label="Select Scoring Types", choices = METFRAG_INTRINSIC_SCORES, + multiple = T, selected = names(METFRAG_DEFAULT_SCORES)) DT::DTOutput("mf_local_ident") ``` @@ -236,6 +238,7 @@ DT::DTOutput("mf_local_ident") ```{r, echo = F} selectInput("mf_local_db_col_scores", label="Select local scoring terms", + multiple = T, choices=character(0)) DT::DTOutput("mf_local_db_scores") ``` diff --git a/inst/rmd/app_results_explorer_cindex.Rmd b/inst/rmd/app_results_explorer_cindex.Rmd new file mode 100644 index 0000000..a12d057 --- /dev/null +++ b/inst/rmd/app_results_explorer_cindex.Rmd @@ -0,0 +1,22 @@ +### Compound Index + +```{r, echo=F} +selectInput("cindex_group",label="Group", + choices=c(NA_character_, + "adduct","tag"), + multiple=T, + selected=c("adduct","tag")) +``` + +<div class="flex-cols"> <!-- select-grouping-labels --> +```{r, echo=F} +selectInput("sort1",label="Sort by ", choices=shinyscreen:::ARRANGE_CHOICES,width="15%",selected="quality") +selectInput("sort2",label="then by ", choices=shinyscreen:::ARRANGE_CHOICES,width="15%",selected="mz") +selectInput("sort3",label="then", choices=shinyscreen:::ARRANGE_CHOICES,width="15%") +selectInput("sort4",label="and finally by", choices=shinyscreen:::ARRANGE_CHOICES,width="15%") +``` +</div> <!-- select-grouping-labels -- + +```{r, echo=F} +DT::DTOutput("cindex") +``` diff --git a/inst/rmd/app_results_explorer_cindex_controls.Rmd b/inst/rmd/app_results_explorer_cindex_controls.Rmd new file mode 100644 index 0000000..4f180bf --- /dev/null +++ b/inst/rmd/app_results_explorer_cindex_controls.Rmd @@ -0,0 +1,18 @@ +<div class='flex-ctrl-row'> +```{r, echo=F} +textInput("report_name", + label="Report Name", + value="report") +actionButton("make_report_b", + label="Create report") +textInput("summ_name", + label="Summary table name", + value="summary.csv") +actionButton("summ_tab_b", "Save summary table") + +textInput("ms2_spectra_tab_name", + label="Table of MS2 spectra", + value="ms2_spectra_table.csv") +actionButton("ms2_spectra_tab_b", "Save MS2 spectra table") +``` +</div> diff --git a/inst/www/custom.css b/inst/www/custom.css index 86c38b5..1685ae5 100644 --- a/inst/www/custom.css +++ b/inst/www/custom.css @@ -62,8 +62,24 @@ /* test comment */ +/* Splitting items on the screen in columns. */ .flex-cols { display: flex; flex-direction: row nowrap; column-gap: 1rem; } + + +/* A row of controls. */ +.flex-ctrl-row { + display: flex; + flex-direction: row wrap; + column-gap: 0.5rem; +} + + +/* Splitting items in horizontal layers. */ +.flex-layers { + display: flex; + flex-direction: column; +} -- GitLab