Home Using Shiny apps for statistical analyses and laboratory workflows
Article Open Access

Using Shiny apps for statistical analyses and laboratory workflows

  • Julian E. Gebauer ORCID logo EMAIL logo , Jakob Adler and On behalf of the DGKL working group “Digital Competence”
Published/Copyright: May 19, 2023
Become an author with De Gruyter Brill

Abstract

In many areas of healthcare, digitization has progressed only slowly so far. The SARS-CoV-2 pandemic in particular has shown how valuable software solutions that are deployable at short notice, can be. In this review we present some selected possibilities of the easy-to-learn programming language R and demonstrate potential applications of the package Shiny in the fields of statistical analysis and laboratory medicine. In addition to a brief tabular overview of published applications, we present two examples of their use in routine laboratory workflows. The first example demonstrates how a Shiny app can be used to estimate the minimal difference (MD) of laboratory analytes, while the second example illustrates how pre- and post-analytical processing steps can be integrated into a fully automated workflow using R and the Shiny package.

Introduction

Few topics are as important in the healthcare sector as digitization. The SARS-CoV-2 pandemic, in particular, highlighted the fact that many structures in the German healthcare system have not yet been digitized, and were unable to quickly transition from analog to digital solutions. Especially when solutions need to be implemented quickly, open-source software or open-source programming languages such as R or Python can help to map new workflows quickly and provide helpful tools in the short term until professional solutions have been developed. In this article, we introduce the programming language R, which is easy to learn, and the R package Shiny, which can be used to create user-friendly applications, commonly referred to as ‘Shiny apps’. We provide an overview of existing Shiny applications used in laboratory medicine. Additionally, we will present a Shiny App for calculating the Minimal Difference (MD) of laboratory analytes and illustrate the use of R in a routine laboratory workflow as simple examples of our own work.

What is R and Shiny?

R is an open-source programming language widely used for statistical computations. It is an interpreter-based language which supports procedural as well as object-oriented programming (https://www.r-project.org/). Additionally, there is a large community providing over 10,000 libraries (so-called packages), offering specific functionalities and interfaces for every conceivable programming task with a particular emphasis on statistical analysis and modeling. One of these packages is Shiny (https://shiny.rstudio.com/). It enables even novice programmers to create interactive web applications with minimal coding effort.

How to develop Shiny apps?

Shiny apps consist of a user interface definition and an underlying server logic. Both are well-documented and easy to learn. Once the app has been coded, there are various options of deployment. The simplest option is running the app locally. One can launch the app with a single click using an R script. More sophisticated approaches are running the app on a server environment (e.g., shinyapps.io), which makes the application available where ever it is needed. In a restricted environment the app can be hosted locally, which makes it easily accessible, while keeping the data safe.

How to get started?

R and its integrated user environment RStudio can be downloaded as open-source software for free from the internet and installed on a computer with just a few clicks. The Shiny package can also be installed easily either via the RStudio user interface or by using the command ‘install.packages (‘Shiny’)’. This provides the prerequisites for running Shiny apps locally. Figure 1 shows a Shiny app, which only needs a few lines of code to create an interactive application. The underlying code and a guide how to run it locally with just a few clicks is shown in the Appendix and in Supplementary Figure A. Furthermore, both R and Shiny have a beginner-friendly syntax that does not require complex definitions or rigid indentation. For those new to R, we highly recommend the tutorial by A. Kassambara (http://www.sthda.com/english/wiki/r-basics-quick-and-easy), which presents not only the basics, but also simple solutions for statistical problems and data visualization in an accessible manner. The official and interactive tutorial for Shiny is also an excellent starting point (https://shiny.rstudio.com/tutorial/). Lastly, the official R manuals page (https://cran.r-project.org/manuals.html) presents the basics of R clearly.

Figure 1: 
Example of a simple Shiny app.
Figure 1:

Example of a simple Shiny app.

Overview of published R-packages or Shiny apps for laboratory medicine

With respect to laboratory medicine, a small but significant number of Shiny apps have been published. Table 1 gives a brief overview. Functionalities range from simple method comparison tools to AI-based expert level interpretation.

Table 1:

Overview of published Shiny apps for laboratory medicine.

Author Name Content
Chabrun [1] SPECTR AI-based expert level interpretation of serum electrophoresis
Bahar [2] Method comparison Easy-to-use and interactive website for evaluating the relative performance of two analytical methods using different regressions models. Generates downloadable reports in PDF or HTML format
Song [3] ceRNAshiny Interactive and easy-to-use computational methods and databases to provide and visualize the construction and analysis of the competing endogenous RNA (ceRNA) network, including differential gene analysis and functional annotation
Beuchel [4] Metabolite-investigator Scalable analysis workflow for quantitative metabolomics data from multiple studies, including all aspects of data pre-processing and multiple analysis methods including uni- and multivariable factor-metabolite associations, network analysis and factor prioritization in one or more cohorts
Sharma [5] ShinyArchR.UiO Single-cell Assay for Transposase-Accessible Chromatin sequencing (scATAC-seq) data accessibility and visualization in a user-friendly, interactive and open-source web interface
Zhang [6] DiffNetFDR R package and easy to use app for identification biological network rewiring under different conditions using two methods developed for testing the difference in different Gaussian graphical models
Nieuwenhuijse [7] viromeBrowser Comparison and extraction of annotation data and sequences from virome sequencing analysis results using an interactive app without necessary data science background
Klawitter [8] Zlog_AdRI Easy-to-use Zlog-based plausibility check of reference intervals with focus on their age dependence

Application example 1: Shiny app minimal difference

The Minimal Difference (MD) is a useful statistical indicator to specify the permissible measurement uncertainty of a measurand at a boundary (upper or lower reference limit, clinical decision limit, upper or lower therapeutic limit) in absolute terms. Thus, measured values in the range of the limit can be interpreted with respect to the measurement uncertainty as “lying within the range of the measurement uncertainty” or “actually increased or decreased”. In this way, the MD can also be an interpretation aid for clinical colleagues in the case of borderline results. Regarding the calculation of the MD, we refer to the relevant work of Keutmann et al. [9]. The guideline of the German Diabetes Society (DDG) on the definition, classification and diagnosis of diabetes mellitus also refers to the MD and points out that the MD can be obtained from the respective laboratory of the sending physician [10]. Since we are not aware of any commercial or publicly available solution for calculating the MD, we present here a Shiny app for this purpose. Using the quality control data collected daily in laboratory routine (mean and coefficient of variation), the MD can be calculated at the mean values of the quality controls. By means of a linear regression, a straight line can be derived for which the corresponding y (MD at the limit value) can be read off for each x (limit value) (Figure 2). The results of the MD calculation can be downloaded at the end of each run as a PDF report. In the spirit of open-source collaboration, readers are encouraged to review the code and provide feedback regarding the usability of the app. The app is hosted on shinyapps.io and is free to use (https://adlermds.shinyapps.io/AdlerMDS_MinimalDifference/). The app’s code has been published on GitHub (https://github.com/Bussard91/2021_AdlerMDS_MinimalDifference).

Figure 2: 
Estimation of minimal difference (MD) at a given cut-off for plasma glucose using a Shiny web app, blue dots indicating the MDs of the quality controls, the black line shows the linear regression model, the red dot indicates the MD at the given cut-off.
Figure 2:

Estimation of minimal difference (MD) at a given cut-off for plasma glucose using a Shiny web app, blue dots indicating the MDs of the quality controls, the black line shows the linear regression model, the red dot indicates the MD at the given cut-off.

Application example 2: PCR-automation

In the beginning of the SARS-CoV-2 pandemic, there were numerous analytical and organizational bottlenecks in PCR testing. Driven by the emergence of SARS-CoV-2, our laboratory was forced to rapidly develop an in-house solution that meets the requirements of cost effectiveness, scalability and flexibility with respect to future challenges. From the sparse literature sources, we selected a classical RNA-extraction with separate real-time PCR-detection workflow. However, the initial workflow included multiple tedious and error prone steps of manual work, like labeling of secondary tubes, sample transfer and manual result entry into the LIS. Due to the high demand for PCR testing, rapid automation was necessary. As a solution, we implemented automation of sample transfer using a Pipetting Robot. To further streamline the workflow and achieve digital and paperless integration of sample handling and LIS results transmission, we developed a Shiny app that generates an RT-qPCR cycler compliant work list based on scanned barcode labels, and an R script that processes the PCR results into an LIS-compliant format. Additionally, processing of pooled samples is possible. The R code used for automation is published on GitHub (https://github.com/gebauerj/pcr_automation/).

Use in laboratory medicine and legal implications

Most published Shiny apps so far focus either on data analysis for scientific information gain such as ceRNAshiny [3] and Metabolite-Investigator [4] or in-house validation, such as method comparison [2] and Zlog_AdRI [8]. Their user-friendly interfaces invite even inexperienced users to experiment with their own data. However, the rigidly specified data input format can pose difficulties, depending on the origin of the primary data. Common sources of errors include country-specific character encoding (UTF-8 vs. ISO 8859-1) or the different use of separators, especially by using the decimal point or decimal comma. Reformatting is relatively easy in most cases, e.g., with a suitable text editor. In addition, the mostly open-source published source codes also offer the possibility to perform analyses and generate reports automatically or even display them live in the form of a dashboard. However, this requires a deeper understanding of the programming language, in this case R.

A special case is the SPECTR tool [1], which might be used for in vitro diagnostics from its basic function. However, the authors explicitly prohibited this use. While scientific use and internal laboratory validation are not affected by the In Vitro Diagnostics Regulation (IVDR) in our opinion, the IVDR represents a major obstacle for use beyond this. Initially, it would be conceivable to support the use of new tools as supplementary information for (bio)medical validation by laboratory professionals. Beyond that, we consider an IVDR-compliant application of such tools to be technically feasible. However, such validation requires a significant amount of effort.

Whether an application such as the one shown in example 2 falls under the IVDR can be a matter of controversial debate. A strict interpretation would argue that this software only modifies data formatting, without performing any evaluation or providing new information. In this case, it would not fall under the IVDR [11]. However, there can be different opinions on this matter. In our situation, manual data entry would have been the only feasible alternative. Therefore, the laboratory is ultimately responsible for ensuring the accuracy of the results.

Conclusions

There is a tremendous wealth of functionality in statistics software and in R in particular, but it is only through tools like Shiny that they become accessible to a wide range of users as intuitive software solutions. In laboratory medicine, the programming of such apps is still in its infancy, and we believe that there is a significant opportunity to advance this technology in order to promote statistical and digital literacy in the field.


Corresponding author: Julian E. Gebauer, Elblandkliniken Stiftung und Co KG, Elblab GmbH, Nassauweg 7, 01662 Meissen, Germany, E-mail:

Acknowledgments

German Society of Clinical Chemistry and Laboratory Medicine (DGKL).

  1. Research funding: None declared.

  2. Author contributions: All authors have accepted responsibility for the entire content of this manuscript and approved its submission.

  3. Competing interests: All authors state no conflict of interest.

  4. Informed consent: Not applicable.

  5. Ethical approval: Not applicable.

Appendix

Learning Shiny is very simple. For a demo application you need only three steps (Figure A):

  1. Open RStudio and create a new file as “Shiny Web App” (above).

  2. Give your application a name (e.g., Demo1) and click on “Create” (middle).

  3. Click “Run App” to see a prebuilt sample app with a slider and histogram.

To generate the app shown in Figure 1 with a histogram for normally distributed random values of sodium, replace the prebuilt sample text by the following code:

In this code, ui stands for the user interface, which contains a sidebar panel with five input fields (two for text and three for numbers) and a main panel with the histogram plot. The server function uses this input to create a rendered plot as output, and the last line of code runs the shiny app as a web application, using ui as input and server as output.

References

1. Chabrun, F, Dieu, X, Ferre, M, Gaillard, O, Mery, A, Chao de la Barca, JM, et al.. Achieving expert-level interpretation of serum protein electrophoresis through deep learning driven by human reasoning. Clin Chem 2021;67:1406–14. https://doi.org/10.1093/clinchem/hvab133.Search in Google Scholar PubMed

2. Bahar, B, Tuncel, AF, Holmes, EW, Holmes, DT. An interactive website for analytical method comparison and bias estimation. Clin Biochem 2017;50:1025–9. https://doi.org/10.1016/j.clinbiochem.2017.08.008.Search in Google Scholar PubMed

3. Song, Y, Li, J, Mao, Y, Zhang, X. ceRNAshiny: an interactive R/shiny app for identification and analysis of ceRNA regulation. Front Mol Biosci 2022;9:865408. https://doi.org/10.3389/fmolb.2022.865408.Search in Google Scholar PubMed PubMed Central

4. Beuchel, C, Kirsten, H, Ceglarek, U, Scholz, M. Metabolite-Investigator: an integrated user-friendly workflow for metabolomics multi-study analysis. Bioinformatics 2021;37:2218–20. https://doi.org/10.1093/bioinformatics/btaa967.Search in Google Scholar PubMed PubMed Central

5. Sharma, A, Akshay, A, Rogne, M, Eskeland, R. ShinyArchR.UiO: user-friendly, integrative and open-source tool for visualization of single-cell ATAC-seq data using ArchR. Bioinformatics 2022;38:834–6. https://doi.org/10.1093/bioinformatics/btab680.Search in Google Scholar PubMed PubMed Central

6. Zhang, XF, Ou-Yang, L, Yang, S, Hu, X, Yan, H. DiffNetFDR: differential network analysis with false discovery rate control. Bioinformatics 2019;35:3184–6. https://doi.org/10.1093/bioinformatics/btz051.Search in Google Scholar PubMed

7. Nieuwenhuijse, DF, Oude Munnink, BB, Koopmans, MPG. viromeBrowser: a shiny app for browsing virome sequencing analysis results. Viruses 2021;13:437. https://doi.org/10.3390/v13030437.Search in Google Scholar PubMed PubMed Central

8. Klawitter, S, Hoffmann, G, Holdenrieder, S, Kacprowski, T, Klawonn, F. A zlog-based algorithm and tool for plausibility checks of reference intervals. Clin Chem Lab Med 2022;61:260–5. https://doi.org/10.1515/cclm-2022-0688.Search in Google Scholar PubMed

9. Keutmann, S, Zylla, S, Dahl, M, Friedrich, N, Landgraf, R, Heinemann, L, et al.. Measurement uncertainty impacts diagnosis of diabetes mellitus: reliable minimal difference of plasma glucose results. Diabetes Ther 2020;11:293–303. https://doi.org/10.1007/s13300-019-00740-w.Search in Google Scholar PubMed PubMed Central

10. Petersmann, A, Müller-Wieland, D, Müller, UA, Landgraf, R, Nauck, M, Freckmann, G, et al.. Definition, classification and diagnosis of diabetes mellitus. Exp Clin Endocrinol Diabetes 2019;127:S1–7. https://doi.org/10.1055/a-1018-9078.Search in Google Scholar PubMed

11. van Deutekom, HWM, Haitjema, S. Recommendations for IVDR compliant in-house software development in clinical practice: a how-to paper with three use cases. Clin Chem Lab Med 2022;60:982–8. https://doi.org/10.1515/cclm-2022-0278.Search in Google Scholar PubMed


Supplementary Material

This article contains supplementary material (https://doi.org/10.1515/labmed-2023-0020).


Received: 2023-02-16
Accepted: 2023-05-02
Published Online: 2023-05-19
Published in Print: 2023-08-28

© 2023 the author(s), published by De Gruyter, Berlin/Boston

This work is licensed under the Creative Commons Attribution 4.0 International License.

Downloaded on 21.9.2025 from https://www.degruyterbrill.com/document/doi/10.1515/labmed-2023-0020/html?lang=en
Scroll to top button