MultiFlow Shiny App User's Guide

Matthias Kohl

2020-08-28

Introduction

The MultiFlow shiny app (Chang et al. 2020) can be used to analyse images of lateral flow assays and to calculate intensity values for the lines of the photographed strips. The intensity values can be merged with information about the experiment and preprocessed by averaging technical replicates. Finally, one can perform a calibration analysis for the data by arbitrary linear models.

In addition to starting with the images, the app also offers further options. One can also start with intensity data on Tab 3, with merged data (intensity data merged with experiment information) on Tab 4, or with preprocessed data on Tab 5.

Tab 1: Cropping and Segmentation

1) Upload Image or Choose Sample

The first step consists of loading an image of one or several lateral flow strips. For trying out the app one can also load a sample image provided with the package. For the purpose of demonstration we use the sample image provided with the package.

2) Set number of strips and number of lines per strip

In the second step, one needs to select the number of strips shown in the image and the number of lines per strip.

The maximum number of strips per image is 10, but in principle could be extended to a higher number. The only requirements is that the strips are regularly spaced with identical or at least similar spaces between them and between the lines. The minimum number of lines per strip is two, the maximum number of lines per strip is six since we are not aware of any lateral flow assay having more than six lines.

3) Apply Crop

After loading the image and selecting the number of strips as well as lines per strip, one needs to click on the image and drag to generate a rectangular selection region on the image. It is best, if each line is roughly in the middle of a respective segment. In addition, there is a segment between two consecutive bands. This segment should not include any part of a line since it can be used for background correction; see below. An example of a well selected cropping region is shown in the following screenshot.

Clicking "3) APPLY CROP" the original image is cropped to the region selected. An example can be seen in the screenshot below. If you want to change the cropped region after clicking "3) APPLY CROP", you have to upload the original image again.

The cropping was adapted from the shiny app provided by package ShinyImage (Fu, Shin, and Matloff 2017).

4) Segmentation

Clicking "4) APPLY SEGMENTATION" segments the image and changes to the second tab. The segments between the bands are used in our quantile background correction method; see below.

Tab 2: Background

1) Select Strip

If there is more than one strip on the analysed image, one first needs to select, which strip shall be analysed.

Optional: in case of color images

If the image is a color image, it will be transformed to grayscale. By default, we apply the luminance approach, which converts color to grayscale preserving luminance; that is, the grayscale values are obtained by

\[ 0.2126 * R + 0.7152 * G + 0.0722 * B \] where R, G, B stands for the red, green and blue channel of the color image. By selecting mode "gray", the arithmetic mean of the RGB values is used. Furthermore, the selection of mode "red", "green" or "blue" allows a color channel wise analysis of color images.

2) Select threshold method and apply

There are two threshold methods, where the default is Otsu's method (Otsu 1979). Otsu's method returns a single intensity threshold that separates pixels into foreground and background. It is equivalent to k-means clustering of the intensity histogram (Liu and Yu 2009). The quantile method is a simple method that computes the specified quantile of all pixel intensities of the segments lying between the lines (per strip). In most of the images we have analysed so far, Otsu's method performed very well and better than our quantile method. However, in cases where the lines are unsharp and very blurred our quantile method may outperform Otsu's method.

By clicking "2) APPLY TRESHOLD" the selected threshold method is applied to the segemented images of the selected strip. The result is shown in two ways. The first row of images shows the pixels that have intensities above the background. The second row of images shows the images after background subtraction; see the screenshot below.

3) Add to data and go back to 1) or proceed with 4)

Clicking "3) ADD TO DATA" adds the mean and median of the background subtracted intensities of the pixels with intensities above the threshold to the data. Now, one can proceed with the second strip of the image, use a different color conversion mode or go back to Tab 1 and load the next image. When all strips and images are processed one can proceed with 4).

4) Switch To Intensity Data

Clicking "4) SWITCH TO INTENSITY DATA" changes the Tab to Tab 3.

Tab 3: Intensity Data

Refresh and download data

The "REFRESH DATA" button is provided to make sure that the latest version of the generated intensity data is shown in the Tab. By clicking "2) DOWNLOAD DATA" the data can be saved to a standard csv file.

For restart with new data

We also provide a "DELETE DATA" button for restarting with new images or uploading an already existing dataset. To get an empty window again, one needs to click "3) REFRESH DATA".

Instead of 1) and 2) you can also upload existing data

Instead of generating new data, one can also upload already existing intensity data, that may have been generated even with a different software. Hence, this step could also be seen as a second entry point of our app. The screenshot below shows an example of data that were generated with the app saved and then loaded again.

3) Switch To Experiment Info

Clicking "3) SWITCH TO EXPERIMENT INFO" changes the Tab to Tab 4, where information about the experiment can be loaded.

Tab 4: Experiment Info

1) Upload experiment Info or upload existing merged data and go to 5)

One first can either upload information about the experiment in form of a csv file or upload already merged data (intensity data merged with experiment information). An example of a table with information about the experiment is shown in the screenshot below.

This is a third optional starting point of our app. That is, one can also directly start with already merged data and proceed with the calibration analysis.

2) Select ID columns and merge datasets

For merging the intensity data with the information about the experiment, one has to specify the names of the columns on which the merge should take place. The default is "File", as a "File" column is generated when the intensity data is computed with the app. By clicking "2) MERGE WITH INTENSITY DATA" the two datasets will be merged. An example of a table with merged data is shown in the screenshot below.

Refresh and download data

The merged data can be downloaded to a csv file by clicking "4) DOWNLOAD DATA", where one can make sure that the app shows the most current version of the data by clicking "3) REFRESH DATA".

For restart with new data

We again provide a "DELETE DATA" button for restarting with new images, uploading new intensity data on Tab 3 or uploading an already existing merged dataset. To get an empty window again, one needs to click "3) REFRESH DATA".

5) Prepare Calibration

Clicking "5) PREPARE CALIBRATION" changes the Tab to Tab 5, where the data can be further preprocessed and the calibration analysis can be started.

Tab 5: Calibration

1) Select a folder for the analysis results

In the first step, a folder for the analysis results can be selected. If no folder is specified, a new folder "MultiFlow" will be generated in the home directory of the user.

Optional: average technical replicates

If the merged data includes technical replicates, these replicates can be averaged either by the arithmetic mean or the median. For this purpose the name of the column, which enables the identification of the replicates is required. By default we assume that this column is called "Sample". In case there is more than one analyte/color per line, one should set "Number of analytes/colors per line" to the respective number. If this number is larger than 1, an additional field will be shown, where one should enter the name of the column including the analyte/color information.

Optional: reshape data from long to wide

If there is more than one analyte/color per line, one might want to combine both information into one calibration model. For such cases it is useful to reshape the data from long (analyte/color data in the rows) to wide (analyte/color data in the columns).

You can also upload existing preprocessed data.

Instead of generating the preprocessed data with our app, one can also upload preprocessed data and perform the calibration analysis on them. An example of uploaded preprocessed data that were generated with our app and saved to a csv file is shown in the following screenshot.

2) Download preprocessed data

By clicking "2) DOWNLOAD DATA", the preprocessed data can be downloaded to a csv file.

3) Calibration by linear model

In the final step of this Tab, one has to specify the calibration model. This model must be given as a valid R formula for a linear model that will be plugged into R function "lm", which will be applied to fit the respective linear regression model. An example is visible in the following screenshot.

Certain simple errors in the formula will be catched and will be shown on Tab 6. However, more complex errors are very likely to lead to a crash of the app.

Sometimes one only wants to analyse a subset of the data. In such cases the subset can be provided in terms of a logical R expression in the field below "Optional: specify subset (logical R expression)".

By pressing "3) RUN CALIBRATION ANALYSIS" the RData-file "CalibrationData.RData" will be generated and saved in the specified analysis folder. Next, the R markdown file "CalibrationAnalysis.Rmd" will be copied to the same folder and will be rendered into file "CalibrationAnalysis.html" by using R package "rmarkdown" (Allaire et al. 2020). The results of the calibration analysis will be saved in file "CalibrationResults.RData" and will be used to generated a brief overview of the results that will be shown on Tab 6. All four files will remain in the folder selected for the analysis results. That is, one may use and modify these files for an extended analysis.

Tab 6: Results

The final Tab of our app shows a brief overview of the analysis results as shown in the following screenshot.

Open analysis report

By clicking "Open" the full report of the calibration analysis will be opened in the standard browser. The first part of the report is visible in the following screenshot.

Required R packages

Our app requires the following R packages to work properly:

References

Allaire, JJ, Yihui Xie, Jonathan McPherson, Javier Luraschi, Kevin Ushey, Aron Atkins, Hadley Wickham, Joe Cheng, Winston Chang, and Richard Iannone. 2020. Rmarkdown: Dynamic Documents for R. https://github.com/rstudio/rmarkdown.

Attali, Dean. 2020. Shinyjs: Easily Improve the User Experience of Your Shiny Apps in Seconds. https://CRAN.R-project.org/package=shinyjs.

Chang, Winston. 2018. Shinythemes: Themes for Shiny. https://CRAN.R-project.org/package=shinythemes.

Chang, Winston, Joe Cheng, JJ Allaire, Yihui Xie, and Jonathan McPherson. 2020. Shiny: Web Application Framework for R. https://CRAN.R-project.org/package=shiny.

Fu, Alexander, Ariel Shin, and Norm Matloff. 2017. ShinyImage: Image Manipulation, with an Emphasis on Journaling. https://CRAN.R-project.org/package=ShinyImage.

Hester, Jim, and Hadley Wickham. 2020. Fs: Cross-Platform File System Operations Based on ’Libuv’. https://CRAN.R-project.org/package=fs.

Liu, D., and J. Yu. 2009. “Otsu Method and K-means.” In 2009 Ninth International Conference on Hybrid Intelligent Systems, 1:344–49.

Otsu, N. 1979. “A Threshold Selection Method from Gray-Level Histograms.” IEEE Transactions on Systems, Man, and Cybernetics 9 (1): 62–66.

Pau, Gregoire, Florian Fuchs, Oleg Sklyar, Michael Boutros, and Wolfgang Huber. 2010. “EBImage—an R Package for Image Processing with Applications to Cellular Phenotypes.” Bioinformatics 26 (7): 979–81. doi:10.1093/bioinformatics/btq046.

Pedersen, Thomas Lin, Vincent Nijs, Thomas Schaffner, and Eric Nantz. 2020. ShinyFiles: A Server-Side File System Viewer for Shiny. https://CRAN.R-project.org/package=shinyFiles.

R Core Team. 2020. R: A Language and Environment for Statistical Computing. Vienna, Austria: R Foundation for Statistical Computing. https://www.R-project.org/.

Wickham, Hadley. 2016. Ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag New York. https://ggplot2.tidyverse.org.

Xie, Yihui, Joe Cheng, and Xianying Tan. 2020. DT: A Wrapper of the Javascript Library ’Datatables’. https://CRAN.R-project.org/package=DT.