Categories
R

BAT

Some years ago, I developed an R script for analysing growth curves from Bioscreen C MBR machines. The script, called BAT (an acronym for Bioscreen Analysis Tool), has been used to analyse Bioscreen data in several labs across the globe – for instance in the work leading up to our paper on reversion of antibiotic resistance, published last year. It allows the user to quickly compute the growth rates and doubling times in hundreds of growth curves. BAT 1.0 worked just fine most of the time, but required the user to learn a little bit of R. That threshold was too high for some users, and so I’ve thought about creating a more user-friendly version of the script for a while now. I’ve finally gotten around to doing just that, creating a version that can be run directly in any modern browser, by using a wonderful tool called Shiny. Users can now use BAT to analyse Bioscreen growth curves in their web browsers, without installing or knowing how to use R. It’s free, and always will be. And so, without further ado, I present to you:

BAT 2.0

Still reading? Well, in that case, I’m happy to tell you a little bit more about what BAT 2.0 does and how to use it. Some background Bioscreen machines, manufactured by Oy Growth Curves Ab Ltd, can be used to measure the growth of all kinds of microorganisms – bacteria, amoebae, fungi, yeast, algea, bacteriophages and so on – in different media (BAT was originally developed to analyse bacterial growth, which may be evident in some of the terminology used below). It measures growth in terms of changes in optical density (OD). Growth curves are what we get when we plot the growth against time, as in this figure, showing the growth of E. coli in a rich medium (Müller-Hinton broth):

Notice that I’ve plotted the logarithm of the OD along the y-axis, which allows us to visually identify the log phase of the bacterial growth as a straight line (shown in red). By fitting a straight line to the log phase, we can find the doubling time of the growth. So how can we use BAT to plot curves like this and fit lines, and to find growth rates and doubling times?


Tab: Data When you start BAT 2.0 you’ll see the following:

Notice that there are several tabs in the menu. When using BAT, we always start with the leftmost tab (Data) and gradually work our way further right (all the way to Results). The first thing to do is to upload the csv file containing the results from your Bioscreen run. You can think of csv files as a mixture between text files and Excel spreadsheets. To view your data, you can open them in Excel, but LibreOffice Calc is much better at handling them. Unfortunately, csv files from different machines don’t always look the same. First of all, the character encoding will differ depending on your computer (language settings, operating system, etc.). Second, the different columns of the csv file can be separated either by a comma, a semicolon or a tab. In order for BAT to read the file properly, you need to tell it the encoding of your file, and how it is separated. Once you’ve given BAT the right settings, the first few lines of your file will be displayed in the right panel. Here’s an example csv file that you can try: a comma-separated csv file encoded with UTF-8. So, how do you find out what encoding your file uses? If you’re a Linux user, you can open a terminal and type

cd ~/path/to/your/file
file -i

to find the encoding, and if you’re using macOS, open a terminal and type

cd ~/path/to/your/file
file -I

If you’re using Windows, have a look here instead. Is your file in an encoding not included in the list in BAT? You can either try changing the encoding or send me an email, so that I can add it to the list. Once your data is shown correctly to the right, as in the figure below, you’re ready to proceed to the next tab.

Tab: Blank wells ‘Blank’ wells, i.e. wells only containing the medium, can (and should!) be used to adjust for changes in OD not caused by microbial growth. Check the boxes corresponding to the blank wells on your plate. Here’s an example of what your blank wells can look like:

If you don’t have any blank wells, uncheck all boxes and move to the next tab, where you then will need to select No adjustment (expect to see error messages in red prior to checking the No adjustment box – that’s normal and nothing to worry about). (If you are using the example csv file, wells 141-144 should be blank.) Tab: Reference wells The first thing to do on this tab is to select which method to use for using the blank wells to adjust the OD measurements for the remaining wells:

  • Method 1: the average OD of the blank wells during the entire run is subtracted from the OD measurements.
  • Method 2: the average OD of the blank wells at each time point is subtracted from the OD measurements at that same time point. This is the recommended method, as it captures the changes in OD not due to microbial growth at each time point.
  • No adjustment: no adjustments are made. Use at your own risk.

After that, you should select the wells containing your reference strain. Relative growth rates will be computed with respect to this strain. If you don’t have a reference strain and only are interested in absolute growth rate (i.e. the doubling times), simply pick one of your strains to use as a reference. Tab: Other wells BAT is now almost ready to compute the growth rates in your wells. It will attempt to find the log phase, but you’ll need to provide a little more information first: where the log phase can be found, how many replicates of each strain you have and what you consider to be an acceptable fit:

  • Masking intervall: this sets the OD levels between which BAT will look for the log phase. In the plots to the right, this is the interval between the blue lines. Use the default settings or adjust them until the interval in the plots to the right seems appropriate for most wells.
  • Number of replicates: if you have replicates of your strains, you can set the number of replicates here. Replicates are assumed to be located in consecutive wells (e.g. wells 105, 106 and 107). BAT will then compute the mean and standard deviation of the growth rate of the strain.
  • Minimum R value: the R value is the linear correlation between time and log(OD) for the fitted line. If the R value for the line fitted in the masking interval is less than the value you set here, BAT will conclude that it’s failed to find the log phase, and will ask you to manually adjust the settings for that particular well in the next tab. In theory, the R value should be 1 during the log phase, but in practice it is always lower because of small measurement errors. A lot of the time, you can expect R to be greater than 0.999 during the log phase, but for some runs there will be more noise, in which case you may need to set a lower minimum R value.

Here’s an example of what you should be seeing:

In addition to this, you can also choose which wells to analyse. The default is to analyse all wells – simply uncheck the boxes for the wells that you do not wish to analyse. Once satisfied with your settings, click Save results and proceed to the next tab. Tab: Manual fitting If there were some wells for which BAT failed to fit a line with an acceptable R value, you will be asked to change the interval in which BAT looks for the log phase. You can do this either by choosing a vertical masking interval (where you pick which log(OD) values to look for the log phase among) or a horizontal masking interval (where you choose between which time points to look for the log phase). Your chosen interval is shown in the plot to the right. Once you’ve found an interval with a sufficiently high R value, click Save results. Here’s an example showing a horizontal masking interval:

BAT will prompt you to repeat this procedure for all wells with too low an R value. If you get stuck on a well and simply can’t find an interval where you get a sufficiently high R value, choose horizontal masking and put the two sliders very close, so that only two points are used for the estimate. Then R will always be 1 and you can continue (but don’t trust the growth rate estimate for that well!). Alternatively, you can go back to Other wells and uncheck the box for that well. Tab: Results To the right, you will see a table showing the results for your data. This includes the slope of the fitted lines (fittedValue), doubling times (doubTime) and relative growth rates (growthRate) for each well, as well as averages and standard deviations for each strain. The mean doubling time for the strain is called groupMeanDoubTime, the mean relative growth rate is called groupMeanGrowthRate and the standard deviation for the relative growth rate is called groupGrowthRateSD. Here’s an example of what the results may look like:

If you are satisfied with the results, you can also download this table as a csv file (comma-separated with UTF-8 encoding) and download the plots showing the growth curves and the fitted lines for all wells in a pdf file. If not, you can go back to previous tabs and change the settings.


Citations If you use BAT for your research, please use the following citation: Thulin, M. (2018). BAT: an online tool for analysing growth curves. Retrieved from http://www.mansthulin.se/bat/


For frequent users If you are planning on using BAT extensively, I highly recommend that you install it on your computer rather than running the online version. It will still look the same and you’ll still use it in exactly the same way. There are two reasons for installing it:

  • BAT will run much faster on your computer.
  • BAT is currently hosted on Shinyapps.io’s free server, meaning that it’s limited to being using 25 hours per month. If you use it a lot, you’ll block others from using it.

To install and run BAT on your computer, follow these five easy steps:

  1. Download RStudio (choose the free desktop version) and install it.
  2. Download the source code for BAT from gitHub: click Clone or download and then Download ZIP. Unzip the downloaded file in a folder of your choice.
  3. Open the file app.R in RStudio.
  4. Click Run App.
  5. Click Show in browser.

You’ll then be running BAT in your browser just as before, only now it’s your computer rather than the server that’s doing the computations.


Frequently asked questions

Alright, I’ll admit it: since BAT 2.0 is a brand new thing, nobody has actually asked me these questions yet. But you ought to, so I’ll put them here just in case.

Q: BAT’s not working for me – what should I do?
A: First of all, carefully follow the steps outlined above. If it’s still not working, please send me an email at mans@statistikkonsult.com. Attach your csv file and describe what the problem seems to be. I’ll see if I can help.

Q: I have growth curves measured by something else than a Bioscreen. Can I still use BAT to analyse them?
A: Absolutely. If you format your data in a csv file to look like the output from a Bioscreen, BAT can do the same type of analysis for your data.

Q: Can you add feature X or add option Y?
A: Maybe. Contact me at mans@statistikkonsult.com and we can talk about it!

Q: Can you make a custom BAT with features X and Y for my lab?
A: Possibly! Contact me at mans@statistikkonsult.com and we can talk about it.

Q: I know R and want to contribute feature X to BAT.
A: That’s a statement and not a question, but OK…! You can find the source code for BAT on gitHub. Feel free to play around with it, and if your feature X seems useful I’ll be happy to add it to the online version of BAT!

Q: I’ve run lots of Bioscreens and analysed them using BAT. I have so much data now! But I’m not sure how to proceed with further statistical analyses of it. What should I do?
A: Great to hear that you have so much data! As it happens, I’m a statistical consultant with a lot of experience from growth curve data. Why don’t you send me an email at mans@statistikkonsult.com, to see if I can help?

Q: So, I hear that you’re a statistical consultant… I have all these other data that I also need help analysing!
A: Also a statement rather than a question, but never mind… Email me at mans@statistikkonsult.com with a description of the data you have, how you have collected it and – most importantly – why you have collected it (what is the question that you are trying to answer?). If I’m able to help, I’ll get back to you with a quote.