The MsBackendTimsTof class supports Bruker TimsTOF data files. New objects are created with the MsBackendTimsTof function. To ensure a small memory footprint, only general information is kept in memory (such as number of frames and scans) and all data (specifically the peaks data) is retrieved from the original file on-the-fly.

MsBackendTimsTof()

# S4 method for MsBackendTimsTof
backendInitialize(object, files, ..., BPPARAM = bpparam())

# S4 method for MsBackendTimsTof
length(x)

# S4 method for MsBackendTimsTof
peaksData(object, columns = c("mz", "intensity"))

# S4 method for MsBackendTimsTof
mz(object)

# S4 method for MsBackendTimsTof
intensity(object)

# S4 method for MsBackendTimsTof
rtime(object)

# S4 method for MsBackendTimsTof
[(x, i, j, ..., drop = FALSE)

# S4 method for MsBackendTimsTof
dataStorage(object)

# S4 method for MsBackendTimsTof
spectraVariables(object)

# S4 method for MsBackendTimsTof
spectraData(object, columns = spectraVariables(object))

# S4 method for MsBackendTimsTof
show(object)

# S4 method for MsBackendTimsTof
msLevel(object, ...)

# S4 method for MsBackendTimsTof
$(x, name)

Arguments

object

MsBackendTimsTof object.

files

character specifying TimsTOF ’*.d’ folders names.

...

Additional arguments.

BPPARAM

Parameter object defining the parallel processing setup to import data in parallel. Defaults to BPPARAM = bpparam(). See bpparam() for more information.

x

MsBackendTimsTof object.

columns

For spectraData: names of the spectra variables to extract from object. For peaksData: names of the peak variables to extract. Defaults to columns = c("mz", "intensity").

i

For [: integer, logical to subset the object.

j

For [: not supported.

drop

For [: not considered.

name

For $: the name of the variable to access.

Available methods

The following methods are implemented:

  • $: access any of the spectraVariables of the backend.

  • [: subset the backend. Only subsetting by element (row/i) is allowed. First the @indices slot of object is subsetted and then the frames and fileNames slots are subsetted accordingly. Note that [ does not update the values of frames variables (such as "MaxIntensity", "SummedIntensities", "NumScans" and "NumPeaks").

  • backendInitialize: initializes object (the MsBackendTimsTof object) using TimsTOF data files whose path is specified by files. This method is supposed to be called right after creating a MsBackendTimsTof object with MsBackendTimsTof function.

  • dataStorage: gets a character of length equal to the number of spectra in object with the names of the '*.d' folders where each spectrum is stored.

  • intensity: gets the intensity values from the spectra in the backend. Returns a NumericList() of numeric vectors (intensity values for each spectrum). The length of the list is equal to the number of spectra in object.

  • msLevel: gets the spectra MS level. Returns an integer vector (of length equal to the number of spectra) with the MS level for each spectrum.

  • mz: gets the mass-to-charge ratios (m/z) from the spectra in the backend. Returns a NumericList() of numeric vectors (m/z values for each spectrum). The length of the list is equal to the number of spectra in object.

  • peaksData: gets the peak matrices of the spectra in the backend. Returns a list of matrix with columns defined by parameter columns (which defaults to columns = c("mz", "intensity"). The length of the list is equal to the number of spectra in object.

  • rtime: gets the retention times for each spectrum. Returns a numeric vector (length equal to the number of spectra) with the retention time for each spectrum.

  • spectraData: gets spectra variables (specified by columns) from object.

  • spectraVariables: returns a character vector with the spectra variables names of core spectra variables defined in the Spectra package and other additional variables contained in object. Note that also "mz" and "intensity" (which are by default not returned by the spectraVariables,Spectra method) are returned.

Author

Andrea Vicini, Johannes Rainer

Examples


## Load the opentimsr package to retrieve the required shared library
## from Bruker.
so_folder <- tempdir()
library(opentimsr)
so_file <- download_bruker_proprietary_code(so_folder, method = "wget")
#> [1] "Downloading 64-bit Linux binary."
#> [1] "Downloading from: https://raw.githubusercontent.com/MatteoLacki/opentims_bruker_bridge/main/opentims_bruker_bridge/libtimsdata.so"
setup_bruker_so(so_file)
path_d_folder <- system.file("ddaPASEF.d",
                             package = "MsBackendTimsTof")

## Define the test file
fl <- system.file("ddaPASEF.d", package = "MsBackendTimsTof")

## Create a MsBackend instance for that file
be <- backendInitialize(MsBackendTimsTof(), fl)
be
#> MsBackendTimsTof with 9120 spectra
#>        msLevel precursorMz  polarity
#>      <integer>   <numeric> <integer>
#> 1            1          NA         1
#> 2            1          NA         1
#> 3            1          NA         1
#> 4            1          NA         1
#> 5            1          NA         1
#> ...        ...         ...       ...
#> 9116         1          NA         1
#> 9117         1          NA         1
#> 9118         1          NA         1
#> 9119         1          NA         1
#> 9120         1          NA         1
#>  ... 35 more variables/columns.
#>  Use  'spectraVariables' to list all of them.

## Available spectra variables
spectraVariables(be)
#>  [1] "msLevel"                 "rtime"                  
#>  [3] "acquisitionNum"          "scanIndex"              
#>  [5] "mz"                      "intensity"              
#>  [7] "dataStorage"             "dataOrigin"             
#>  [9] "centroided"              "smoothed"               
#> [11] "polarity"                "precScanNum"            
#> [13] "precursorMz"             "precursorIntensity"     
#> [15] "precursorCharge"         "collisionEnergy"        
#> [17] "isolationWindowLowerMz"  "isolationWindowTargetMz"
#> [19] "isolationWindowUpperMz"  "tof"                    
#> [21] "inv_ion_mobility"        "frameId"                
#> [23] "ScanMode"                "MsMsType"               
#> [25] "TimsId"                  "MaxIntensity"           
#> [27] "SummedIntensities"       "NumScans"               
#> [29] "NumPeaks"                "MzCalibration"          
#> [31] "T1"                      "T2"                     
#> [33] "TimsCalibration"         "PropertyGroup"          
#> [35] "AccumulationTime"        "RampTime"               
#> [37] "Pressure"                "file"                   

## Subset to 10 randomly selected spectra.
be_sub <- be[sort(sample(seq_along(be), 10))]
rtime(be_sub)
#>  [1] 0.218626 1.264748 1.395106 1.395106 1.527225 1.783703 1.916259 3.703421
#>  [9] 4.315153 6.781203

pd <- peaksData(be_sub, columns = c("mz", "intensity", "tof", "inv_ion_mobility"))