A U.S. DEPARTMENT OF ENERGY NATIONAL LAB • SAVANNAH RIVER SITE • AIKEN, SC • USA MethodOpt: a Shiny-based graphical user interface for multivariate optimization of sampling and analytical instrumentation Benjamin Luke Stephanie Gamble May 2025 SRNL-STI-2024-00414, Revision 0 This work was prepared under an agreement with and funded by the U.S. Government. Neither the U.S. Government or its employees, nor any of its contractors, subcontractors or their employees, makes any express or implied: • warranty or assumes any legal liability for the accuracy, completeness, or for the use or results of such use of any information, product, or process disclosed; or • representation that such use or results of such use would not infringe privately owned rights; or • endorsement or recommendation of any specifically identified commercial product, process, or service. Any views and opinions of authors expressed in this work do not necessarily state or reflect those of the United States Government, or its contractors, or subcontractors. Printed in the United States of America Prepared for U.S. Department of Energy ii Keywords: R-package, GUI, instrument method optimization, spectrometry optimization MethodOpt: a Shiny-based graphical user interface for multivariate optimization of sampling and analytical instrumentation Benjamin Luke Stephanie Gamble May 2025 Savannah River National Laboratory is operated by Battelle Savannah River Alliance for the U.S. Department of Energy under Contract No. 89303321CEM000080 iii Reviews and Approvals AUTHORS: Signed 2025.07.31 _____________________________________________________________________ Benjamin Luke, SRNL Post-Bachelor’s Intern, Advanced Modeling and Simulation STEPHANIE GAMBLE (Affiliate) Digitally signed by STEPHANIE GAMBLE (Affiliate) ______________________________________________________________________ Date: 2025.07.31 11:24:18 -04'00' Stephanie Gamble, SRNL Staff Scientist, Advanced Modeling and Simulation TECHNICAL REVIEWERS: CAROLINE GRANGER (Affiliate) Digitally signed by CAROLINE GRANGER (Affiliate) ______________________________________________________________________ Date: 2025.07.31 11:26:47 -04'00' Caroline Granger, SRNL Staff Scientist, Trace Nuclear Measurement Technology APPROVAL: ADRIAN MISTREANU Digitally signed by ADRIAN MISTREANU (Affiliate) (Affiliate) Date: 2025.07.31 12:39:11 -04'00' ______________________________________________________________________ Adrian Mistreanu, SRNL Group Manager, Advanced Modeling and Simulation Ethan Farquhar Digitally signed by Ethan Farquhar Date: 2025.07.31 11:52:23 -04'00' ______________________________________________________________________ Ethan Farquhar, SRNL Division Director, Advanced Technology and Analysis iv Preface or Acknowledgements The authors thank Caroline Granger and Joseph Mannion for providing the sample data that aided in building MethodOpt. This work was supported by the Laboratory Directed Research and Development (LDRD) program within the Savannah River National Laboratory (SRNL). This document was prepared in conjunction with work accomplished under Contract No. 89303321CEM000080 with the U.S. Department of Energy (DOE) Office of Environmental Management (EM). v Executive Summary Method optimization is an important step in producing useful data in various experimental settings involving the use of sampling and analytical instrumentation, such as gas- chromatography mass-spectrometry or other analytical techniques. However, traditional optimization techniques often lack the sophistication of more modern optimization techniques developed in areas of applied mathematics. A graphical user interface has been developed that implements a multivariate, multi-objective optimization technique for spectra-generating sampling and analytical instrumentation, which saves substantial time and resources compared to the more traditional approaches to method development. vi Table of Contents 1.0 Introduction ............................................................................................................................... 1 2.0 Methods .................................................................................................................................... 2 2.1 Fractional Factorial Design ................................................................................................... 2 2.2 Analysis of Variance.............................................................................................................. 2 2.2.1 Plot Feature .................................................................................................................... 2 2.2.2 Identify Peaks ................................................................................................................. 3 2.2.3 Objectives ....................................................................................................................... 4 2.2.4 ANOVA ........................................................................................................................... 4 2.3 Box-Behnken Design ............................................................................................................ 4 2.4 Optimization .......................................................................................................................... 5 3.0 Conclusion ................................................................................................................................ 5 vii List of Figures Figure 1: Example of plot viewer tool with logarithmic scale and baseline overlay options selected for sample data................................................................................................................. 3 viii List of Abbreviations ANOVA Analysis of variance BBD Box-Behnken design CRAN Comprehensive R Archive Network CSV Comma separated value FFD Fractional factorial design GC-MS Gas chromatography – mass spectrometry GUI Graphical user interface IDE Integrated development environment IR Infrared LC-MS Liquid chromatography – mass spectrometry SRNL Savannah River National Laboratory ix 1.0 Introduction There are many kinds of instrumentation that produce spectra. Gas chromatography – mass spectrometry (GC-MS) is one such example, but there are several others, including Raman spectroscopy, infrared (IR) spectroscopy, and liquid chromatography – mass spectrometry (LC- MS). Experimentally generated spectra are more desirable when the analytes of interest can be easily identified. In practice, this means that the peaks of the spectra can be clearly identified and distinguished from one another and from the background “noise” of the sample. To generate data in this manner, optimization techniques are often employed to adjust instrument parameters, which can have a substantial impact on the quality of the spectra. Traditional optimization techniques usually involve optimizing one parameter at a time, which is inaccurate if the parameters have mixed effects. In addition, with multiple parameters this can easily become costly in time and resources. Recently, an advanced multivariate optimization technique was developed by Gamble et al. (2023) and is well-suited for spectroscopic techniques. This approach was found to significantly reduce the time and resources required for method optimization.[1] Practicing scientists, however, are often not extensively trained in statistical programming languages, making more sophisticated methods like this impractical or inaccessible. In response to this, a graphical user interface (GUI) called MethodOpt was developed to enable practicing scientists with little to no background in statistical programming languages to use the multivariate optimization technique developed by Gamble, et al. The GUI is written in R using the Shiny framework, which allows non-R users to employ the optimization technique of Gamble, et al. without R language knowledge or command line experience.[2,3] R is widely available for free, with a large community of users and support. The program is constructed with various built-in objective selections that are useful for analytical instrumentation, such as maximizing the height of the peaks and minimizing the widths, among others. The program offers all the required components for the optimization technique, from experimental designs to data analysis to visualization tools. MethodOpt requires installation of the R language and an integrated development environment (IDE), for which RStudio is suggested. (The R language and RStudio can be downloaded from the instructions on https://posit.co/download/rstudio-desktop/.) After installing both R and RStudio, the user will need to install the MethodOpt package. The package is located in the Comprehensive R Archive Network (CRAN) repository and can be downloaded from the CRAN website.[4] (Packages in the CRAN repository can be found at https://cran.r-project.org/). To download and install MethodOpt into the user’s system, it is suggested to use the function install.packages(“MethodOpt”), which is installed with base R. Once R (the programming language), RStudio (the IDE), and MethodOpt (the package) have all been installed, the GUI is ready to be deployed by calling the function MethodOpt::MethodOpt(). (Note that the function that opens the GUI, MethodOpt(), has the same name as the package itself, MethodOpt.) In R, to call a function, the user must first specify to which package the function belongs, which is done using “::”. The alternative option is to load all the functions of MethodOpt (which is only the one, MethodOpt()) by calling library(MethodOpt), and the GUI can be initiated by calling MethodOpt() alone without indicating the namespace. For more information about packages and namespaces, see the manual at https://rstudio.github.io/r-manuals/r-intro/Packages.html. 1 2.0 Methods MethodOpt (v1.0.0) uses the packages shiny, shinythemes, shinyFeedback, shinyalert, FrF2, stringr, DT, ggplot2, stats, dplyr, shinyjs, shinyBS, tibble, glue, rlang, DoE.wrapper, gtools, zip, zoo, magrittr, utils, and purrr.[2,3,5-18] The program is designed to facilitate a multivariate optimization method by completing four broad phases. The phases are (1) generation of a two- level fractional factorial screening experimental design, (2) analysis of variance (ANOVA) testing of the initial screening data, (3) generation of a Box-Behnken experimental design, and (4) application of the optimization method for the data from the Box-Behnken design. Many features have been integrated into MethodOpt as well, such as plotting capabilities for the raw data and various download options for data and plots. Each of these phases are discussed in greater detail below. 2.1 Fractional Factorial Design MethodOpt allows for the construction of a two-level fractional factorial experimental design (FFD) within the FFD tab pane of the interface. The FFD is intended to be used as a screening study to identify the experimental parameters that have a statistically significant impact on the desired objectives as outlined by the user.[19,20] To generate the FFD, the user must input all relevant parameters for the optimization (e.g., for GC-MS, split ratio, column flow, etc.) along with their “high” and “low” values. The high and low values are intended to be an informed, estimated range where the optimal value may be. When the user is finished inputting data, the FFD can be generated by selecting “Generate FFD.” Traditional mathematical formulations of FFDs use +1 and -1 rather than actual, experimental high and low data. MethodOpt offers both an FFD table with experimental data, as well as a more traditional table with plus or minus unity. The tables can also be downloaded in a CSV format. An example data set of GC-MS data collected for a FFD screening experiment has been published and is available for download.[21] 2.2 Analysis of Variance Once the user has performed all the experiments according to the parameters of the generated FFD, the raw data can be uploaded in the Analysis tab. All the uploaded files will appear in a tabulated data table in the main viewing pane of the tab; all data are required to be uploaded in a CSV format. Within this tab, there are multiple subtabs. The subtabs relevant for the analysis of variance (ANOVA) test are used to plot the raw data, identify the peaks of the data, calculate the desired objectives, and perform the ANOVA test. 2.2.1 Plot Feature The first subtab is the Plot tab and is a plotting utility for the uploaded data. Any one of the uploaded files can be selected from the table of files in the main view, and its plot will be automatically rendered. The user may select the number of rows to skip from the uploaded data files if, for example, the raw data contain column titles or other rows of information preceding the actual data. Other plotting options include customizable x- and y-axis labels, and options to plot 2 with a logarithmic (base 10) scale, the baseline subtracted, or the baseline overlayed. The user may download any of the plots via the download handler. Additionally, a mass download option is available that will download plots of all the data in a compressed file format. A screenshot of the MethodOpt Plot tab using sample data can be seen in Figure 1: Example of plot viewer tool with logarithmic scale and baseline overlay options selected for sample data. The user does not need to use the Plot tab to complete the ANOVA test, though it could prove a useful visual tool. Figure 1: Example of plot viewer tool with logarithmic scale and baseline overlay options selected f or sample data 2.2.2 Identify Peaks Once the raw data has been uploaded, the relevant peaks must be identified in order to proceed with analysis. This is most easily done by uploading a CSV containing the retention times of interest. The format of the file is important. The first column should be method number; the first row should be analyte names. The retention times for each analyte for each method should be filled accordingly. An example file for retention times has been included the example GC-MS data.[4] If retention times are not available, the user may utilize the peak finding algorithm built into MethodOpt. This algorithm will search for n maxima resembling chromatographic peaks, where n is a positive integer input by the user. There is an interactive component to the search 3 algorithm that allows the user to discard incorrectly identified peaks and advance to the next viable replacement. Though this method is straightforward in principle, it can easily become time consuming to sort through data and verify peaks. Hence, it is recommended that the user upload retention times for peaks of interest. 2.2.3 Objectives In the Objectives tab, the user selects the desired objectives from a checkbox list and the calculated objectives are displayed in a reactive table in the main viewing pane. Objective options in the present version of MethodOpt are as follows: (1) maximize average peak height, (2) minimize average peak width, (3) maximize average peak area, (4) minimize average baseline, (5) minimize baseline variability, and (6) maximize retention time separation. Maximizing the retention time separation is useful when two peaks coelute. Up to three pairs of retention times may be selected as independent objectives. Note that the user cannot select the following conflicting objectives: maximize peak area and minimize peak width. The objective values displayed in the main viewing pane for peak height, width, and area are all averages taken across the total number of peaks, rather than a much larger table with peak heights, widths, and areas for each individual peak of each method. However, a master datasheet can be downloaded that contains such information. 2.2.4 ANOVA Once all the objective data are computed, the ANOVA test can be carried out to determine which parameters have a statistically significant impact on the user-defined objectives.[22] The user must upload the FFD with the actual experimental data. The format must be the same as that generated in the FFD section. The format is important to keep in mind, as the FFD should have parameter values contained by column (not row). The first row is reserved as a header for parameter names. An alpha value must also be selected for ANOVA analysis using a dropdown box for the selection of α = 0.01, 0.005, or 0.001. Running ANOVA will output a table with each parameter and the p-values corresponding to each objective. A column specifying the significance of each parameter is also displayed, as is a suggested change for each parameter for the upcoming Box-Behnken experimental design. 2.3 Box-Behnken Design Following the completion of the ANOVA test, a Box-Behnken experimental design (BBD) should be created for conducting a surface response experiment to evaluate the objectives’ response to the input parameters determined to be statistically significant.[23] The BBD can be generated under the BBD Setup tab, in a manner similar to the FFD table. The only relevant difference is that three values must be input for each parameter: high (+1), middle (0), and low (-1) values. These values may be chosen by the user in any manner. However, if results from a FFD screening experiment are available, it is suggested that the user keep the two previously selected levels from the FFD and select the third level based on those results. If the average objective value for the “high” FFD value is lower than that of the “low” value, then the user should select the “low” FFD value as the BBD (-1) value, the “high” FFD value as the BBD (0) 4 value, and select a higher value for the BBD (+1) value. Conversely if the opposite is true, the average objective value for the “high” FFD value is higher than that of the “low” value, the new added value should be the BBD (-1) value. When all parameters have been submitted, the BBD table can be generated for the experimental design by selecting “Generate BBD.” As with the FFD table, the user may download the table. An example GC-MS data set collected for a BBD surface response experiment has been published and is available for download.[24] 2.4 Optimization The final step is optimization. To do this, the user must follow much of the same procedure as discussed in Section 2.2.4. The user uploads raw data files, has the option to view or download plots, must identify the peaks, and must select the desired objectives. This all parallels the methods in Sections 2.2.1 through 2.2.3. Once the objectives have been properly calculated, the user advances to the Optimization subtab and uploads the BBD table used in data collection. In the same manner as the FFD data, the format of the file is important. The first column should be method number, and the first row should be analyte names. Again, the retention times for each analyte for each method should be filled in accordingly. The user is also advised to input experimental ranges of validity for each parameter in the Physical Limit Input. This is to guarantee that the solution falls within valid experimental or physical ranges for each parameter. After selecting “Optimize,” a data table with the optimal parameter values is displayed. If the optimum solution does not fall within the ranges of validity, a second, bounded solution will be computed. The optimization algorithm used is outlined in Gamble, et al.[1] After gathering experimental data according to the optimal parameter values, the user may return to the program with the final dataset, upload it, view its plot, and calculate the objective values, if desired. 3.0 Conclusion MethodOpt is a GUI for multi-objective, multivariate method optimization relevant for analytical instrumentation. It employs a sophisticated optimization technique that is more robust than conventional method optimization techniques. Minimal coding experience is required to use MethodOpt. It offers experimental design capabilities, plotting tools, and various analysis algorithms that facilitate the entire method optimization process. This program is intuitive for the user and provides a substantial improvement in resource and time costs compared to traditional method optimization techniques. Future upgrades to MethodOpt will likely include capabilities to handle more diverse types of experimental data. References 1. Gamble, S.; Granger, C.; Mannion, J. Advanced Method Optimization for Sampling and Analysis Instrumentation. Anal. Chem. 2024, 96, 29, 11666–11672. 5 2. Chang, W.; Cheng, J.; Allaire, J.; Sievert, C.; Schloerke, B.; Xie, Y.; Allen, J.; McPherson, J.; Dipert, A.; Borges, B. shiny: Web Application Framework for R. 2023; R package version 1.7.5.1. 3. R Core Team R: A Language and Environment for Statistical Computing. R Foundation for Statistical Computing: Vienna, Austria, 2023. 4. Luke, B.; Gamble, S. MethodOpt: Advanced Method Optimization for Spectra- Generating Sampling and Analysis Instrumentation. 2024; R package version 1.0.0. 5. Merlino, A.; Howard, P. shinyFeedback: Display User Feedback in Shiny Apps. 2021; R package version 0.4.0. 6. Attali, D.; Edwards, T. shinyalert: Easily Create Pretty Popup Messages (Modals) in Shiny. 2021; R package version 3.0.0. 7. Grömping, U. R Package FrF2 for Creating and Analyzing Fractional Factorial 2-Level Designs. Journal of Statistical Software 2014, 56, 1.56. 8. Wickham, H. stringr: Simple, Consistent Wrappers for Common String Operations. 2022; R package version 1.5.0. 9. Xie, Y.; Cheng, J.; Tan, X. DT: A Wrapper of the JavaScript Library 'DataTables'. 2023; R package version 0.30. 10. Wickham, H. ggplot2: Elegant Graphics for Data Analysis; Springer-Verlag New York, 2016. 11. Wickham, H.; François, R.; Henry, L.; Müller, K.; Vaughan, D. dplyr: A Grammar of Data Manipulation. 2023; R package version 1.1.3. 12. Attali, D. shinyjs: Easily Improve the User Experience of Your Shiny Apps in Seconds. 2021; R package version 2.1.0. 13. Bailey, E. shinyBS: Twitter Bootstrap Components for Shiny. 2022; R package version 0.61.1. 14. Müller, K.; Wickham, H. tibble: Simple Data Frames. 2023; R package version 3.2.1. 15. Hester, J.; Bryan, J. glue: Interpreted String Literals. 2022; R package version 1.6.2. 16. Henry, L.; Wickham, H. rlang: Functions for Base Types and Core R and 'Tidyverse' Features. 2023; R package version 1.1.2. 17. Groemping, U. DoE.wrapper: Wrapper Package for Design of Experiments Functionality. 2023; R package version 0.12. 18. Warnes, G. R.; Bolker, B.; Lumley, T.; Magnusson, A.; Venables, B.; Ryodan, G.; Moeller, S. gtools: Various R Programming Tools. 2023; R package version 3.9.5. 19. Montgomery, D. C. Design and Analysis of Experiments, John Wiley & Sons, Inc. 2017, 9th ed. ISBN: 9781119113478 20. Gunst, R.F.; Mason, R.L. Fractional Factorial Design. WIREs Comp Stats. 2009. 1 (2), 234-244. DOI: 10.1002/wics.027. 21. Gamble, S.; Granger, C.; Mannion, J. GC-MS Screening Data for Instrument Optimization. figshare. Dataset. 2025. https://doi.org/10.6084/m9.figshare.28635920.v1 22. Fisher, R. A. Statistical Methods for Research Workers, Oliver & Boyd, 1970, 14th ed. DOI: 10.1007/978-1-4612-4380-9_6 23. Box, G.; Behnken, D. Some new three level designs for the study of quantitative variables. Technometrics. 1960, 2:455-475. DOI: 10.2307/1266454 24. Gamble, S.; Granger, C.; Mannion, J. GC-MS Surface Response Data for Instrument Optimization. figshare. Dataset. 2025. https://doi.org/10.6084/m9.figshare.28636013.v1 6