knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(maldipickr)
The matrix-assisted laser desorption/ionization-time-of-flight (MALDI-TOF) technology is coupled with mass spectrometry in the Bruker MALDI Biotyper device in order to identify microorganisms. The device generates two types of data:
The following vignette describe how to streamline the import of these two types of data into R using the {maldipickr}
package
The Bruker MALDI Biotyper generates a report via the Compass software summarizing the identification of the microorganisms using its internal database. While the file is separated by semi-colons, it contains no headers. The report has many columns in a wide format to describe the ten hits when identification is feasible, or only a few when no identification was possible. All-in-all, this makes the table import into R and its manipulation relatively painful.
Below is an example of an import of a single Bruker MALDI Biotyper report into a {tibble}
. By default, only the best hit of each colony is reported. All hits can be reported as well, in the long format (long_format = TRUE
), for further explorations with the {tidyverse}
suite.
# Get a example Bruker report biotyper <- system.file("biotyper.csv", package = "maldipickr") # Import the report as a tibble report_tibble <- read_biotyper_report(biotyper) # Display the tibble report_tibble
During large-scale analysis, batches of identification are run and can easily be imported using the read_many_biotyper_reports
function along with their custom-made metadata.
Below is an example of such usage, where one report was artificially extended into multiple reports.
# List of Bruker MALDI Biotyper reports reports_paths <- system.file( c("biotyper.csv", "biotyper.csv", "biotyper.csv"), package = "maldipickr" ) # Read the list of reports and combine them in a single tibble read_many_biotyper_reports( reports_paths, report_ids = c("first", "second", "third"), # Additional metadata below are passed to dplyr::mutate growth_temperature = 37.0 )
Other than the identification reports, the Bruker MALDI Biotyper device outputs the raw data used for the identification (if not the database) in the form of mass spectra.
Thankfully, the {MALDIquant}
and {readBrukerFlexData}
packages help users import and manipulate these data in R.
However, when the Bruker MALDI Biotyper device produces acqus
files (instead of the native acqu
files), the readBrukerFlexDir()
function from the {readBrukerFlexData}
package
will fail with the following error message:
Error in .readAcquFile(fidFile = fidFile, verbose = verbose) : File ‘/data/maldi_dir/targetA/0_D10/1/1SLin/acqu’ doesn't exists!
The following import_biotyper_spectra()
) function used in the example below circumvent this error by creating a symbolic link and conveniently helps removing calibration samples.
The toy dataset bundled with this package is a subset of a dataset in the {MALDIquantExamples}
package and consist here of six spectra:
1 replicate of species 1
2 replicates of species 2
* 3 replicates of species 3
# Get an example directory of six Bruker MALDI Biotyper spectra directory_biotyper_spectra <- system.file( "toy-species-spectra", package = "maldipickr" ) # Import the six spectra spectra_list <- import_biotyper_spectra(directory_biotyper_spectra) # Display the list of spectra spectra_list
Once the spectra are imported, the check_spectra()
function can easily assess whether all the spectra in the list are not empty, of the same length and correspond to profile data.
If some spectra do not satisfy these criteria, the function will exit with a warning and indicate the faulty spectra.
Either way, the function outputs a list of logical vectors (TRUE
or FALSE
) indicating whether each of the spectra are empty (is_empty
), of an odd length (is_outlier_length
) or not a profile spectra (is_not_regular
).
# Get an example directory of six Bruker MALDI Biotyper spectra directory_biotyper_spectra <- system.file( "toy-species-spectra", package = "maldipickr" ) # Import the six spectra spectra_list <- import_biotyper_spectra(directory_biotyper_spectra) # Display the list of checks, with FALSE where no anomaly is detected check_spectra(spectra_list) # The overall sanity can be checked with Reduce Reduce(any, check_spectra(spectra_list)) # Should be FALSE
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.