diff --git a/R/api.R b/R/api.R index 20a3fe3528ca68d5b416fdfafa2d5f97b04fec0a..03fb25793612cae6e32f94b38de18c62ef127ea7 100644 --- a/R/api.R +++ b/R/api.R @@ -681,14 +681,18 @@ create_plots <- function(m) { #' `rmarkdown::run` `render_args` argument. #' @param top_data_dir `character(1)`, a location on the server side #' containing data directories. -#' @param projects `character(1)`, a location on the server side containing project directories. +#' @param metfrag_db_dir `character(1)`, a location on the server side +#' containing MetFrag databases. +#' @param projects `character(1)`, a location on the server side +#' containing project directories. #' @return Nada. #' @author Todor Kondić -app <- function(shiny_args=list(launch.browser=F),render_args=NULL,top_data_dir=getwd(),projects=getwd()) { +app <- function(shiny_args=list(launch.browser=F),render_args=NULL,top_data_dir=getwd(),projects=getwd(),metfrag_db_dir="") { dir_before <- getwd() init <- list() init$dir_before <- dir_before init$top_data_dir <- norm_path(top_data_dir) + init$metfrag_db_dir <- metfrag_db_dir init$projects <- norm_path(projects) if (!dir.exists(init$top_data_dir)) stop("Data directory (top_data_dir), currently `", init$top_data_dir, diff --git a/inst/rmd/app.Rmd b/inst/rmd/app.Rmd index c557b267911b5cdebd21c3e19c5f07825fa48184..b9d9ad16f0d44d714fa99a580b3772bae2dd423b 100644 --- a/inst/rmd/app.Rmd +++ b/inst/rmd/app.Rmd @@ -859,336 +859,6 @@ verbatimTextOutput("print_spec_tab") </div> <!-- measure-prop-sec --> - - - - - -<!-- ### Compound Index --> - -<!-- ```{r, echo=F} --> - -<!-- fluidRow(column(h5("Arrange"), --> -<!-- selectInput("sort1",label="Sort by ", choices=shinyscreen:::ARRANGE_CHOICES), --> -<!-- selectInput("sort2",label="then by ", choices=shinyscreen:::ARRANGE_CHOICES), --> -<!-- selectInput("sort3",label="then", choices=shinyscreen:::ARRANGE_CHOICES), --> -<!-- selectInput("sort4",label="and finally by", choices=shinyscreen:::ARRANGE_CHOICES), --> -<!-- width = 2), --> -<!-- column(wellPanel(DT::DTOutput("cindex")), --> -<!-- width = 10)) --> - -<!-- ``` --> - - - - - -<!-- ### Viewer --> - -<!-- ```{r, echo=F} --> -<!-- sidebarLayout(sidebarPanel(h5("Pointer position"), --> -<!-- textOutput("plot_hover_out"), --> -<!-- textInput("rtrange", --> -<!-- label = "Global RT range"), --> -<!-- hr(), --> -<!-- ## Not so important, TODO later. --> -<!-- ## h5("Log scale"), --> -<!-- ## checkboxGroupInput("plot_log", --> -<!-- ## label=NULL, --> -<!-- ## choices = c("MS1 EIC","MS2 EIC","MS2 Spectrum"), --> -<!-- ## selected = character(0)), --> -<!-- ## hr(), --> -<!-- ## uiOutput("plot_b_ctrl"), --> -<!-- hr(), --> -<!-- textInput("plot_ext", --> -<!-- label = "Plot extension", --> -<!-- value = "pdf"), --> -<!-- actionButton("plot_save_single", --> -<!-- label="Save this plot"), --> -<!-- actionButton("plot_save_all", --> -<!-- label="Save all plots"), --> -<!-- actionButton("make_report_b", --> -<!-- label="Create report"), --> -<!-- width=4), --> -<!-- wellPanel(id = "tPanel",style = "overflow-y:scroll; max-height:80vh; background: white", --> -<!-- plotOutput("plot_eic_ms1", --> -<!-- hover = hoverOpts(id="plot_hover", --> -<!-- delayType = "throttle", --> -<!-- delay=100), --> -<!-- dblclick = "plot_rt_click", --> -<!-- brush = "plot_brush"), --> -<!-- plotOutput("plot_eic_ms2", --> -<!-- hover = hoverOpts(id="plot_hover", --> -<!-- delayType = "throttle", --> -<!-- delay=100), --> -<!-- dblclick = "plot_rt_click", --> -<!-- brush = "plot_brush"), --> -<!-- plotOutput("plot_ms2_spec", --> -<!-- hover = hoverOpts(id="plot_hover", --> -<!-- delayType = "throttle", --> -<!-- delay=100), --> -<!-- dblclick = "plot_mz_click", --> -<!-- brush = brushOpts(id="plot_mz_brush")) --> -<!-- ## ,plotOutput("plot_struct") --> -<!-- )) --> - - - -<!-- ``` --> - - -<!-- ## Compound Explorer {.tabset} --> - -<!-- This is where the prescreening results are presented. The _Browser_ --> -<!-- tab shows a detailed view of the MS2 data as well as the associated --> -<!-- precursors in searchable tables. The _Viewer_ tab shows the --> -<!-- visualisations of the EICs and the plots of the spectra. Both kinds --> -<!-- of outputs can be exported using portable formats. --> - -<!-- Auto quality checks built into Shinyscreen can sometimes yield --> -<!-- unsatisfactory results. In such cases, it is possible to manually --> -<!-- update relevant data. --> - -<!-- Please see the respective subsections for more details. --> - - -<!-- ### Browser --> - -<!-- <details><summary>Organise, filter and search through data.</summary> --> - -<!-- **Data Organisation** --> - -<!-- Postprocessed spectral data is presented in three tables. The first, --> -<!-- always visible, table shows the list of precursors. The entries of this --> -<!-- table are ordered by the following categories in order of --> -<!-- significance: adduct, a data file where they were found, the ion mass --> -<!-- of the precursor and then the retention time. The ordering was chosen --> -<!-- because it will group together isobars. --> - -<!-- The second table shows the metadata of all the MS2 entries associated --> -<!-- with the currently selected MS1 entry : the accession number (_an_, a --> -<!-- chronological tag unique to the data file it stems from), the --> -<!-- retention time of the signal (_RT(ms2)_), the intensity (_I(ms2)_), --> -<!-- the collision energy and several quality control flags. --> - -<!-- Meaning of QC flags: --> - -<!-- - **Selected?** : Is this spectrum the _one_? Auto precscreening will --> -<!-- select the spectral entry that passed all QC checks and is the --> -<!-- closest to the MS1 peak. --> - -<!-- - **Above threshold?** : Is the MS2 signal greater than the intensity --> -<!-- threshold specified in the _Configuration_ section? --> - -<!-- - **MS1/MS2 RT match?** : Is the MS2 within the allowed retention time --> -<!-- window around the MS1 peak? The retention time window can be change --> -<!-- in the _Configuration_ section. --> - -<!-- - **MS2 Exists?** : If no MS2 was found for the selected MS1 entry, --> -<!-- this will be unchecked. --> - -<!-- If an entry is selected from the MS2 metadata table, its mass spectrum --> -<!-- is going to be shown in the third table. The spectral table is in the --> -<!-- MetFrag-compatible format and can be directly pasted in the spectral --> -<!-- widget on the MetFrag website. Please bear in mind that this method of --> -<!-- spectral matching is for interactive purpouses only, if there are many --> -<!-- spectra that should be processed with MetFrag it is much better to --> -<!-- employ MetFragCL program for batch analysis. Some Shinyscreen support --> -<!-- for this is already there (see _Exporting_). --> - - -<!-- **Filtering and Searching** --> - -<!-- The filters just below the table headers can be used to limit the --> -<!-- displayed data. Numerical columns accept ranges, while the content of --> -<!-- the textual columns will be matched against character strings in the --> -<!-- filters. --> - -<!-- </details> --> - -<!-- <div style="display: flex; vertical-align: top;margin: auto;"> --> - -<!-- <div style="width: 50%;padding-right=1.0em"> --> - -<!-- #### Compound selector --> - -<!-- ```{r, echo=F} --> -<!-- DT::DTOutput("compound_selector") --> -<!-- ``` --> - -<!-- #### MS1 quality check table --> - -<!-- ```{r, echo=F} --> -<!-- 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} --> -<!-- DT::DTOutput("compound_ms2_table") --> -<!-- ``` --> - - - -<!-- #### MS2 spectrum --> - - -<!-- ```{r, echo=F} --> -<!-- DT::DTOutput("compound_ms2_spectrum") --> -<!-- ``` --> - -<!-- </div> --> - -<!-- </div> --> - -<!-- <details><summary>Override auto-prescreening results (Commit manual QA).</summary> --> - -<!-- After the automatic quality control check based on the criteria --> -<!-- defined in the _Prescreening_ tab is done ,it is possible to manually --> -<!-- update the quality of the retrieved spectra.This can be achieved by --> -<!-- double clicking on the required QA fields namely _MS1/MS2 match?_, --> -<!-- _Above threshold_, _MS2 exists_ after inspecting the peaklist. Once --> -<!-- the manual QA step is done, the changes can be saved by clicking the --> -<!-- _Commit manual QA_ button. --> - -<!-- </details> --> - -<!-- ```{r, echo=F} --> -<!-- uiOutput("update_summ_ui") --> -<!-- ``` --> - -<!-- <details><summary>Export Data Browser contents.</summary> --> - -<!-- A detailed _summary table_ combining all the information from the --> -<!-- _Browser_ tab can be saved in a _CSV_ file by clicking the _Export --> -<!-- MS1/MS2 summary_ tab. The table can be used in combination with --> -<!-- MetFragCL for batch scoring of the entries. --> - -<!-- </details> --> -<!-- ```{r, echo=F} --> -<!-- uiOutput("export_summ_ui") --> -<!-- ``` --> - - -<!-- ### Viewer --> - - -<!-- <details><summary> Visualize and export the plots. </summary> --> - -<!-- For any given ID, the EICs of MS1 and MS2, as well as the --> -<!-- representative mass spectrum (MS2 entry with _Selected?_ checked in --> -<!-- the _Data Browser_) can be visualized by selecting the corresponding --> -<!-- row in the table. The plots can be zoomed-in by selecting the region --> -<!-- of interest using the cursor and double click to zoom-out. It is also --> -<!-- possible to plot mutiple figures by selecting different rows. --> - -<!-- Shinyscreen can export the plots in all the formats supported by R --> -<!-- package _ggplot2_ (pdf, png, ...). The plot of the EICs and the mass --> -<!-- spectra will be saved in _figures_ subdirectory of the project --> -<!-- directory. Associated metadata for the plots are saved in _CSV_ files --> -<!-- of the same basename as the plots. The plots themselves feature --> -<!-- minimal legends, so please do create legends more appropriate to your --> -<!-- particular use from the data in the plot _CSV_s. The plots can also be --> -<!-- saved as _ggplot2_ objects by changing the extension to _.rds_. Such a --> -<!-- file can be loaded into R using the `readRDS` function, and then every --> -<!-- visual aspect of the plot can be manually tweaked. This can be useful --> -<!-- when there is a need to comply with specific publication requirements. --> - -<!-- Button _Save this plot_ will save the currently selected plot with --> -<!-- currently selected axes ranges and scaling properties. Button _Save --> -<!-- all plots_ will save all the plots with default zoom/axes ranges. --> - -<!-- </details> --> - -<!-- ```{r, echo=F} --> -<!-- sidebarLayout(sidebarPanel(DT::DTOutput("plot_comp_select"), --> -<!-- h5("Pointer position"), --> -<!-- textOutput("plot_hover_out"), --> -<!-- textInput("rtrange", --> -<!-- label = "Global RT range"), --> -<!-- shinyscreen::rt_input(input_rt = "plot_rt_min", --> -<!-- input_unit = "plot_rt_min_unit", --> -<!-- width=55, --> -<!-- width_u=40, --> -<!-- def_rt = "min", --> -<!-- def_unit = "min", --> -<!-- pref = "RT min"), --> - -<!-- shinyscreen::rt_input(input_rt = "plot_rt_max", --> -<!-- input_unit = "plot_rt_max_unit", --> -<!-- width=55, --> -<!-- width_u=40, --> -<!-- def_rt = "max", --> -<!-- def_unit = "min", --> -<!-- pref = "RT max"), --> -<!-- hr(), --> -<!-- ## Not so important, TODO later. --> -<!-- ## h5("Log scale"), --> -<!-- ## checkboxGroupInput("plot_log", --> -<!-- ## label=NULL, --> -<!-- ## choices = c("MS1 EIC","MS2 EIC","MS2 Spectrum"), --> -<!-- ## selected = character(0)), --> -<!-- ## hr(), --> -<!-- ## uiOutput("plot_b_ctrl"), --> -<!-- hr(), --> -<!-- textInput("plot_ext", --> -<!-- label = "Plot extension", --> -<!-- value = "pdf"), --> -<!-- actionButton("plot_save_single", --> -<!-- label="Save this plot"), --> -<!-- actionButton("plot_save_all", --> -<!-- label="Save all plots"), --> -<!-- actionButton("make_report_b", --> -<!-- label="Create report"), --> -<!-- width=4), --> - - - - - <!-- ENGINE --> ```{r, echo = F, context = 'setup'}