From 09018441eedea997cecdd6ef1c22edf9c91306fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Todor=20Kondi=C4=87?= <todor.kondic@uni.lu> Date: Thu, 24 Feb 2022 10:46:23 +0100 Subject: [PATCH] app, shiny-ui-base: Add filter for entries in compound selector --- DESCRIPTION | 4 ++-- R/shiny-ui-base.R | 31 ++++++++++++++++++++++--------- inst/rmd/app.Rmd | 43 ++++++++++++++++++++++++++++++++++++++++++- inst/www/custom.css | 12 ++++++++++++ 4 files changed, 78 insertions(+), 12 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 85f1230..2b40bd5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: shinyscreen Title: Pre-screening of Mass Spectrometry Data -Version: 1.0.6 +Version: 1.0.7 Author: Todor Kondić Maintainer: Todor Kondić <todor.kondic@uni.lu> Authors@R: @@ -41,7 +41,7 @@ Description: Pre-screening of Mass Spectrometry Data. License: Apache License (>= 2.0) Encoding: UTF-8 LazyData: true -RoxygenNote: 7.1.1 +RoxygenNote: 7.1.2 Roxygen: list(markdown = TRUE) Collate: 'base.R' diff --git a/R/shiny-ui-base.R b/R/shiny-ui-base.R index 428c834..088781e 100644 --- a/R/shiny-ui-base.R +++ b/R/shiny-ui-base.R @@ -479,12 +479,23 @@ mk_shinyscreen_server <- function(projects,init) { ## Modifiable version. the_ord_summ <- data.table::copy(def_ord_summ) - gen_compsel_tab <- function(summ) { + gen_compsel_tab <- function(summ,criteria=character(0)) { ## Given summary table, create a table with only adduct/tag/ID ## entries and associated MS1 quantities. - res <- summ[,unique(.SD),.SDcol=c("adduct","tag","ID", - "mz","ms1_rt","ms1_int", - "Name")] + seln <- logical(length(criteria)) + res <-if (length(seln)>0) { + names(seln) <-criteria + seln[] <- T + critab <- do.call(data.table::data.table,as.list(seln)) + summ <- summ[critab,on=names(critab)] + summ[,unique(.SD),.SDcol=c("adduct","tag","ID", + "mz","ms1_rt","ms1_int", + "Name")] + } else { + summ[,unique(.SD),.SDcol=c("adduct","tag","ID", + "mz","ms1_rt","ms1_int", + "Name")] + } data.table::setkeyv(res,c("adduct", "tag", "mz","ms1_rt")) res @@ -897,9 +908,11 @@ mk_shinyscreen_server <- function(projects,init) { rf_gen_struct_figs <- eventReactive(rvs$m$out$tab$comp,gen_struct_plots(rvs$m)) rf_compsel_tab <- reactive({ + input$cmpd_sel_filter + message("cmpd_sel_filter:",paste0(input$cmpd_sel_filter,collapse=";")) tab <- rvs$m$out$tab$flt_summ req(NROW(tab)>0) - gen_compsel_tab(tab) + gen_compsel_tab(tab,criteria=input$cmpd_sel_filter) }) rf_qa_compsel_tab <- reactive({ @@ -1136,11 +1149,11 @@ mk_shinyscreen_server <- function(projects,init) { } }, label = "project-b") - observeEvent(rv_projects, - { - message("This is triggered as it should be.") + ## observeEvent(rv_projects, + ## { + ## message("Project updated.") - },label = "upd-proj-list") + ## },label = "upd-proj-list") observeEvent(input$save_proj_b,{ diff --git a/inst/rmd/app.Rmd b/inst/rmd/app.Rmd index 9cb7006..a3feed5 100644 --- a/inst/rmd/app.Rmd +++ b/inst/rmd/app.Rmd @@ -1,5 +1,7 @@ --- -output: html_document +output: + html_document: + css: custom.css runtime: shiny_prerendered author: Environmental Cheminformatics Group, LCSB, University of Luxembourg title: "`r paste('Shinyscreen', packageVersion('shinyscreen'))`" @@ -634,11 +636,49 @@ DT::DTOutput("compound_selector") DT::DTOutput("compound_selector_qa") ``` +<div id="footer"> + +<details><summary>Narrow down entries according to the QA criteria.</summary> + +* **qa_pass** : entries that passed all checks + +* **qa_ms1_exists** : MS1 intensity is above the MS1 threshold + +* **qa_ms2_exists** : those entries for which some MS2 spectra have been found + +* **qa_ms1_above_noise** : MS1 is intense enough and above the noise level + +* **qa_ms2_good_int** : MS2 intensity is above the MS2 threshold + +* **qa_ms2_near** : MS2 spectrum is close enough to the MS1 peak + +</details> + +```{r, echo=F} +checkboxGroupInput("cmpd_sel_filter", + label="Filter Results", + choices = c(qa_pass="qa_pass", + qa_ms2_near="qa_ms2_near", + qa_ms2_good_int="qa_ms2_good_int", + qa_ms2_exists="qa_ms2_exists", + qa_ms1_above_noise="qa_ms1_above_noise", + qa_ms1_exists="qa_ms1_exists"), + inline=T, + selected = character(0)) + +``` + </div> +</div> + + + <div style="width: 50%"> + + #### MS2 quality check table ```{r, echo=F} @@ -653,6 +693,7 @@ DT::DTOutput("compound_ms2_table") ```{r, echo=F} DT::DTOutput("compound_ms2_spectrum") ``` + </div> </div> diff --git a/inst/www/custom.css b/inst/www/custom.css index 869eb9f..a551ad0 100644 --- a/inst/www/custom.css +++ b/inst/www/custom.css @@ -6,3 +6,15 @@ #inline label{ display: table-cell; text-align: center; vertical-align: middle; } #inline .form-group { display: table-row;} + + +/* From SO 8565819 */ +#wrapper { + min-height: 100%; + height: auto !important; + height: 100%; + margin-bottom: -100px; /* <- If you change this height... */ +} +#footer, #push { + height: 100px; /* <- ...then you should also change this height! */ +} -- GitLab