Spectra
MS backend storing data in a SQL database
Source: R/MsBackendSql-functions.R
, R/MsBackendSql.R
MsBackendSql.Rd
The MsBackendSql
is an implementation for the MsBackend()
class for
Spectra()
objects which stores and retrieves MS data from a SQL database.
New databases can be created from raw MS data files using
createMsBackendSqlDatabase()
.
Usage
MsBackendSql()
createMsBackendSqlDatabase(
dbcon,
x = character(),
backend = MsBackendMzR(),
chunksize = 10L,
blob = TRUE,
partitionBy = c("none", "spectrum", "chunk"),
partitionNumber = 10L
)
# S4 method for class 'MsBackendSql'
show(object)
# S4 method for class 'MsBackendSql'
backendInitialize(object, dbcon, data, ...)
# S4 method for class 'MsBackendSql'
dataStorage(object)
# S4 method for class 'MsBackendSql'
x[i, j, ..., drop = FALSE]
# S4 method for class 'MsBackendSql'
peaksData(object, columns = c("mz", "intensity"))
# S4 method for class 'MsBackendSql'
peaksVariables(object)
# S4 method for class 'MsBackendSql'
intensity(object) <- value
# S4 method for class 'MsBackendSql'
mz(object) <- value
# S4 method for class 'MsBackendSql'
x$name <- value
# S4 method for class 'MsBackendSql'
spectraData(object, columns = spectraVariables(object))
# S4 method for class 'MsBackendSql'
reset(object)
# S4 method for class 'MsBackendSql'
spectraNames(object)
# S4 method for class 'MsBackendSql'
spectraNames(object) <- value
# S4 method for class 'MsBackendSql'
filterMsLevel(object, msLevel = uniqueMsLevels(object))
# S4 method for class 'MsBackendSql'
filterRt(object, rt = numeric(), msLevel. = integer())
# S4 method for class 'MsBackendSql'
filterDataOrigin(object, dataOrigin = character())
# S4 method for class 'MsBackendSql'
filterPrecursorMzRange(object, mz = numeric())
# S4 method for class 'MsBackendSql'
filterPrecursorMzValues(object, mz = numeric(), ppm = 20, tolerance = 0)
# S4 method for class 'MsBackendSql'
uniqueMsLevels(object, ...)
# S4 method for class 'MsBackendSql'
backendMerge(object, ...)
# S4 method for class 'MsBackendSql'
precScanNum(object)
# S4 method for class 'MsBackendSql'
centroided(object)
# S4 method for class 'MsBackendSql'
smoothed(object)
# S4 method for class 'MsBackendSql'
tic(object, initial = TRUE)
# S4 method for class 'MsBackendSql'
supportsSetBackend(object, ...)
# S4 method for class 'MsBackendSql'
backendBpparam(object, BPPARAM = bpparam())
# S4 method for class 'MsBackendSql'
dbconn(x)
Arguments
- dbcon
Connection to a database.
- x
For
createMsBackendSqlDatabase()
:character
with the names of the raw data files from which the data should be imported. For other methods anMsqlBackend
instance.- backend
For
createMsBackendSqlDatabase()
: MS backend that can be used to import MS data from the raw files specified with parameterx
.- chunksize
For
createMsBackendSqlDatabase()
:integer(1)
defining the number of input that should be processed per iteration. Withchunksize = 1
each file specified withx
will be imported and its data inserted to the database. Withchunksize = 5
data from 5 files will be imported (in parallel) and inserted to the database. Thus, higher values might result in faster database creation, but require also more memory.- blob
For
createMsBackendSqlDatabase()
:logical(1)
whether individual m/z and intensity values should be stored separately (blob = FALSE
) or if the m/z and intensity values for each spectrum should be stored as a single BLOB SQL data type (blob = TRUE
, the default).- partitionBy
For
createMsBackendSqlDatabase()
:character(1)
defining if and how the peak data table should be partitioned."none"
(default): no partitioning,"spectrum"
: peaks are assigned to the partition based on the spectrum ID (number), i.e. spectra are evenly (consecutively) assigned across partitions. ForpartitionNumber = 3
, the first spectrum is assigned to the first partition, the second to the second, the third to the third and the fourth spectrum again to the first partition."chunk"
: spectra processed as part of the same chunk are placed into the same partition. All spectra from the next processed chunk are assigned to the next partition. Note that this is only available for MySQL/MariaDB databases, i.e., ifcon
is aMariaDBConnection
. See details for more information.- partitionNumber
For
createMsBackendSqlDatabase()
:integer(1)
defining the number of partitions the database table will be partitioned into (only supported for MySQL/MariaDB databases).- object
A
MsBackendSql
instance.- data
For
backendInitialize()
: optionalDataFrame
with the full spectra data that should be inserted into a (new)MsBackendSql
database. If provided, it is assumed thatdbcon
is a (writeable) connection to an empty database into whichdata
should be inserted.data
could be the output ofspectraData
from another backend.- ...
For
[
: ignored. ForbackendInitialize
, if parameterdata
is used: additional parameters to be passed to the function creating the database such asblob
.- i
For
[
:integer
orlogical
to subset the object.- j
For
[
: ignored.- drop
For
[
:logical(1)
, ignored.- columns
For
spectraData()
:character()
optionally defining a subset of spectra variables that should be returned. Defaults tocolumns = spectraVariables(object)
hence all variables are returned. ForpeaksData
accessor: optionalcharacter
with requested columns in the individualmatrix
of the returnedlist
. Defaults tocolumns = c("mz", "intensity")
but all columns listed bypeaksVariables
would be supported.- value
For all setter methods: replacement value.
- name
For
<-
:character(1)
with the name of the spectra variable to replace.- msLevel
For
filterMsLevel()
:integer
specifying the MS levels to filter the data.- rt
For
filterRt()
:numeric(2)
with the lower and upper retention time. Spectra with a retention time>= rt[1]
and<= rt[2]
are returned.- msLevel.
For
filterRt():
integerwith the MS level(s) on which the retention time filter should be applied (all spectra from other MS levels are considered for the filter and are returned *as is*). If not specified, the retention time filter is applied to all MS levels in
object`.- dataOrigin
For
filterDataOrigin()
:character
with data origin values to which the data should be subsetted.- mz
For
filterPrecursorMzRange()
:numeric(2)
with the desired lower and upper limit of the precursor m/z range. ForfilterPrecursorMzValues()
:numeric
with the m/z value(s) to filter the object.- ppm
For
filterPrecursorMzValues()
:numeric
with the m/z-relative maximal acceptable difference for a m/z value to be considered matching. Can be of length 1 or equal tolength(mz)
.- tolerance
For
filterPrecursorMzValues()
:numeric
with the absolute difference for m/z values to be considered matching. Can be of length 1 or equal tolength(mz)
.- initial
For
tic()
:logical(1)
whether the original total ion count should be returned (initial = TRUE
, the default) or whether it should be calculated on the spectras' intensities (initial = FALSE
).- BPPARAM
for
backendBpparam()
:BiocParallel
parallel processing setup. Seebpparam()
for more information.
Details
The MsBackendSql
class is principally a read-only backend but by
extending the MsBackendCached()
backend from the Spectra
package it
allows changing and adding (temporarily) spectra variables without
changing the original data in the SQL database.
Note
The MsBackendSql
backend keeps an (open) connection to the SQL database
with the data and hence does not support saving/loading of a backend to
disk (e.g. using save
or saveRDS
). Also, for the same reason, the
MsBackendSql
does not support parallel processing. The backendBpparam()
method for MsBackendSql
will thus always return a SerialParam()
object.
The MsBackendOfflineSql()
could be used as an alternative as it supports
saving/loading the data to/from disk and supports also parallel processing.
Creation of backend objects
New backend objects can be created with the MsBackendSql()
function.
SQL databases can be created and filled with MS data from raw data files
using the createMsBackendSqlDatabase()
function or using
backendInitialize()
and providing all data with parameter data
. In
addition it is possible to create a database from a Spectra
object
changing its backend to a MsBackendSql
or MsBackendOfflineSql
using
the setBackend()
function.
Existing SQL databases (created previously with
createMsBackendSqlDatabase()
or backendInitialize()
with the data
parameter) can be loaded using the conventional way to create/initialize
MsBackend
classes, i.e. using backendInitialize()
.
createMsBackendSqlDatabase()
: create a database and fill it with MS data. Parameterdbcon
is expected to be a database connection, parameterx
acharacter
vector with the file names from which to import the data. Parameterbackend
is used for the actual data import and defaults tobackend = MsBackendMzR()
hence allowing to import data from mzML, mzXML or netCDF files. Parameterchunksize
allows to define the number of files (x
) from which the data should be imported in one iteration. With the defaultchunksize = 10L
data is imported from 10 files inx
at the same time (ifbackend
supports it even in parallel) and this data is then inserted into the database. Larger chunk sizes will require more memory and also larger disk space (as data import is performed through temporary files) but might eventually be faster. Parameterblob
allows to define whether m/z and intensity values from a spectrum should be stored as a BLOB SQL data type in the database (blob = TRUE
, the default) or if individual m/z and intensity values for each peak should be stored separately (blob = FALSE
). The latter case results in a much larger database and slower performance of thepeaksData
function, but would allow to define custom (manual) SQL queries on individual peak values. While data can be stored in any SQL database, at present it is suggested to use MySQL/MariaDB databases. Fordbcon
being a connection to a MySQL/MariaDB database, the tables will use the ARIA engine providing faster data access and will use table partitioning: tables are splitted into multiple partitions which can improve data insertion and index generation. Partitioning can be defined with the parameterspartitionBy
andpartitionNumber
. By defaultpartitionBy = "none"
no partitioning is performed. Forblob = TRUE
partitioning is usually not required. Only forblob = FALSE
and very large datasets it is suggested to enable table partitioning by selecting eitherpartitionBy = "spectrum"
orpartitionBy = "chunk"
. The first option assignes consecutive spectra to different partitions while the latter puts spectra from files part of the same chunk into the same partition. Both options have about the same performance butpartitionBy = "spectrum"
requires less disk space. Note that, while inserting the data takes a considerable amount of time, also the subsequent creation of database indices can take very long (even longer than data insertion forblob = FALSE
).backendInitialize()
: get access and initialize aMsBackendSql
object. Parameterobject
is supposed to be aMsBackendSql
instance, created e.g. withMsBackendSql()
. Parameterdbcon
is expected to be a connection to an existing MsBackendSql SQL database (created e.g. withcreateMsBackendSqlDatabase()
).backendInitialize()
can alternatively also be used to create a newMsBackendSql
database using the optionaldata
parameter. In this case,dbcon
is expected to be a writeable connection to an empty database anddata
aDataFrame
with the full spectra data to be inserted into this database. The format ofdata
should match the format of theDataFrame
returned by thespectraData()
function and requires columns"mz"
and"intensity"
with the m/z and intensity values of each spectrum. ThebackendInitialize()
call will then create all necessary tables in the database, will fill these tables with the provided data and will return anMsBackendSql
for this database. Thus, theMsBackendSql
supports thesetBackend
method fromSpectra
to change from (any) backend to aMsBackendSql
. Note however that chunk-wise (or parallel) processing needs to be disabled in this case by passing eventuallyf = factor()
to thesetBackend()
call.supportsSetBackend()
: whetherMsBackendSql
supports thesetBackend()
method to change theMsBackend
of aSpectra
object to aMsBackendSql
. ReturnsTRUE
, thus, changing the backend to aMsBackendSql
is supported if a writeable database connection is provided in addition with parameterdbcon
(i.e.setBackend(sps, MsBackendSql(), dbcon = con)
withcon
being a connection to an empty database would store the full spectra data from theSpectra
objectsps
into the specified database and would return aSpectra
object that uses aMsBackendSql
).backendBpparam()
: whether aMsBackendSql
supports parallel processing. Takes aMsBackendSql
and a parallel processing setup (seebpparam()
for details) as input and always returns aSerialParam()
sinceMsBackendSql
does not support parallel processing.dbconn()
: returns the connection to the database.
Subsetting, merging and filtering data
MsBackendSql
objects can be subsetted using the [
function. Internally,
this will simply subset the integer
vector of the primary keys and
eventually cached data. The original data in the database is not
affected by any subsetting operation. Any subsetting operation can be
undone by resetting the object with the reset()
function. Subsetting
in arbitrary order as well as index replication is supported.
Multiple MsBackendSql
objects can also be merged (combined) with the
backendMerge()
function. Note that this requires that all MsBackendSql
objects are connected to the same database. This function is thus
mostly used for combining MsBackendSql
objects that were previously
splitted using e.g. split()
.
In addition, MsBackendSql
supports all other filtering methods available
through MsBackendCached()
. Implementation of filter functions optimized
for MsBackendSql
objects are:
filterDataOrigin()
: filter the object retaining spectra withdataOrigin
spectra variable values matching the provided ones with parameterdataOrigin
. The function returns the results in the order of the values provided with parameterdataOrigin
.filterMsLevel()
: filter the object based on the MS levels specified with parametermsLevel
. The function does the filtering using SQL queries. If"msLevel"
is a local variable stored within the object (and hence in memory) the default implementation inMsBackendCached
is used instead.filterPrecursorMzRange()
: filters the data keeping only spectra with aprecursorMz
within the m/z value range provided with parametermz
(i.e. all spectra with a precursor m/z>= mz[1L]
and<= mz[2L]
).filterPrecursorMzValues()
: filters the data keeping only spectra with precursor m/z values matching the value(s) provided with parameter
mz. Parameters
ppmand
toleranceallow to specify acceptable differences between compared values. Lengths of
ppmand
tolerancecan be either
1or equal to
length(mz)` to use different values for ppm and tolerance for each provided m/z value.filterRt()
: filter the object keeping only spectra with retention times within the specified retention time range (parameterrt
). Optional parametermsLevel.
allows to restrict the retention time filter only on the provided MS level(s) returning all spectra from other MS levels.
Accessing and modifying data
The functions listed here are specifically implemented for MsBackendSql
.
In addition, MsBackendSql
inherits and supports all data accessor,
filtering functions and data manipulation functions from
MsBackendCached()
.
$
,$<-
: access or set (add) spectra variables inobject
. Spectra variables added or modified using the$<-
are cached locally within the object (data in the database is never changed). To restore an object (i.e. drop all cached values) thereset
function can be used.dataStorage()
: returns acharacter
vector same length as there are spectra inobject
with the name of the database containing the data.intensity<-
: not supported.mz<-
: not supported.peaksData()
: returns alist
with the spectras' peak data. The length of the list is equal to the number of spectra inobject
. Each element of the list is amatrix
with columns according to parametercolumns
. For an empty spectrum, amatrix
with 0 rows is returned. UsepeaksVariables(object)
to list supported values for parametercolumns
.peaksVariables()
: returns acharacter
with the available peak variables, i.e. columns that could be queried withpeaksData()
.reset()
: restores anMsBackendSql
by re-initializing it with the data from the database. Any subsetting or cached spectra variables will be lost.spectraData()
: gets general spectrum metadata.spectraData()
returns aDataFrame
with the same number of rows as there are spectra inobject
. Parametercolumns
allows to select specific spectra variables.spectraNames()
,spectraNames<-
: returns acharacter
of length equal to the number of spectra inobject
with the primary keys of the spectra from the database (converted tocharacter
). Replacing spectra names withspectraNames<-
is not supported.uniqueMsLevels()
: returns the unique MS levels of all spectra inobject
.tic()
: returns the originally reported total ion count (forinitial = TRUE
) or calculates the total ion count from the intensities of each spectrum (forinitial = FALSE
).
Implementation notes
Internally, the MsBackendSql
class contains only the primary keys for all
spectra stored in the SQL database. Keeping only these integer
in memory
guarantees a minimal memory footpring of the object. Still, depending of
the number of spectra in the database, this integer
vector might become
very large. Any data access will involve SQL calls to retrieve the data
from the database. By extending the MsBackendCached()
object from the
Spectra
package, the MsBackendSql
supports to (temporarily, i.e. for
the duration of the R session) add or modify spectra variables. These are
however stored in a data.frame
within the object thus increasing the
memory demand of the object.
Examples
####
## Create a new MsBackendSql database
## Define a file from which to import the data
data_file <- system.file("microtofq", "MM8.mzML", package = "msdata")
## Create a database/connection to a database
library(RSQLite)
db_file <- tempfile()
dbc <- dbConnect(SQLite(), db_file)
## Import the data from the file into the database
createMsBackendSqlDatabase(dbc, data_file)
#> Importing data ...
#>
#> [==========================================================] 1/1 (100%) in 1s
#>
#> Creating indices
#> .
#> .
#> .
#> .
#> Done
#> [1] TRUE
dbDisconnect(dbc)
## Initialize a MsBackendSql
dbc <- dbConnect(SQLite(), db_file)
be <- backendInitialize(MsBackendSql(), dbc)
be
#> MsBackendSql with 198 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
#> ... ... ... ...
#> 194 1 NA 1
#> 195 1 NA 1
#> 196 1 NA 1
#> 197 1 NA 1
#> 198 1 NA 1
#> ... 34 more variables/columns.
#> Use 'spectraVariables' to list all of them.
#> Database: /tmp/RtmpqLniVu/filea684cdb5a7b
## Original data source
head(be$dataOrigin)
#> [1] "/__w/_temp/Library/msdata/microtofq/MM8.mzML"
#> [2] "/__w/_temp/Library/msdata/microtofq/MM8.mzML"
#> [3] "/__w/_temp/Library/msdata/microtofq/MM8.mzML"
#> [4] "/__w/_temp/Library/msdata/microtofq/MM8.mzML"
#> [5] "/__w/_temp/Library/msdata/microtofq/MM8.mzML"
#> [6] "/__w/_temp/Library/msdata/microtofq/MM8.mzML"
## Data storage
head(dataStorage(be))
#> [1] "/tmp/RtmpqLniVu/filea684cdb5a7b" "/tmp/RtmpqLniVu/filea684cdb5a7b"
#> [3] "/tmp/RtmpqLniVu/filea684cdb5a7b" "/tmp/RtmpqLniVu/filea684cdb5a7b"
#> [5] "/tmp/RtmpqLniVu/filea684cdb5a7b" "/tmp/RtmpqLniVu/filea684cdb5a7b"
## Access all spectra data
spd <- spectraData(be)
spd
#> DataFrame with 198 rows and 37 columns
#> msLevel rtime acquisitionNum scanIndex mz
#> <integer> <numeric> <integer> <integer> <NumericList>
#> 1 1 0.486 1 1 104.554,106.996,107.966,...
#> 2 1 0.822 2 2 107.960,109.964,112.027,...
#> 3 1 1.159 3 3 107.963,112.021,113.035,...
#> 4 1 1.495 4 4 105.971,109.984,112.028,...
#> 5 1 1.832 5 5 104.474,107.000,109.968,...
#> ... ... ... ... ... ...
#> 194 1 65.4360 194 194 106.992,111.459,112.022,...
#> 195 1 65.7720 195 195 99.0797,109.0031,112.0232,...
#> 196 1 66.1092 196 196 102.927,108.970,112.028,...
#> 197 1 66.4458 197 197 111.058,112.026,113.029,...
#> 198 1 66.7818 198 198 111.044,112.024,112.518,...
#> intensity dataStorage dataOrigin centroided
#> <NumericList> <character> <character> <logical>
#> 1 23,35,50,... /tmp/RtmpqLniVu/file.. /__w/_temp/Library/m.. TRUE
#> 2 35, 24,140,... /tmp/RtmpqLniVu/file.. /__w/_temp/Library/m.. TRUE
#> 3 28,179,350,... /tmp/RtmpqLniVu/file.. /__w/_temp/Library/m.. TRUE
#> 4 25, 28,131,... /tmp/RtmpqLniVu/file.. /__w/_temp/Library/m.. TRUE
#> 5 26,30,25,... /tmp/RtmpqLniVu/file.. /__w/_temp/Library/m.. TRUE
#> ... ... ... ... ...
#> 194 34,24,86,... /tmp/RtmpqLniVu/file.. /__w/_temp/Library/m.. TRUE
#> 195 24, 22,198,... /tmp/RtmpqLniVu/file.. /__w/_temp/Library/m.. TRUE
#> 196 29,22,98,... /tmp/RtmpqLniVu/file.. /__w/_temp/Library/m.. TRUE
#> 197 31,124,189,... /tmp/RtmpqLniVu/file.. /__w/_temp/Library/m.. TRUE
#> 198 67,84,22,... /tmp/RtmpqLniVu/file.. /__w/_temp/Library/m.. TRUE
#> smoothed polarity precScanNum precursorMz precursorIntensity
#> <logical> <integer> <integer> <numeric> <numeric>
#> 1 NA 1 NA NA NA
#> 2 NA 1 NA NA NA
#> 3 NA 1 NA NA NA
#> 4 NA 1 NA NA NA
#> 5 NA 1 NA NA NA
#> ... ... ... ... ... ...
#> 194 NA 1 NA NA NA
#> 195 NA 1 NA NA NA
#> 196 NA 1 NA NA NA
#> 197 NA 1 NA NA NA
#> 198 NA 1 NA NA NA
#> precursorCharge collisionEnergy isolationWindowLowerMz
#> <integer> <numeric> <numeric>
#> 1 NA NA NA
#> 2 NA NA NA
#> 3 NA NA NA
#> 4 NA NA NA
#> 5 NA NA NA
#> ... ... ... ...
#> 194 NA NA NA
#> 195 NA NA NA
#> 196 NA NA NA
#> 197 NA NA NA
#> 198 NA NA NA
#> isolationWindowTargetMz isolationWindowUpperMz peaksCount totIonCurrent
#> <numeric> <numeric> <integer> <numeric>
#> 1 NA NA 1743 97322
#> 2 NA NA 1708 98590
#> 3 NA NA 1708 96425
#> 4 NA NA 1747 97144
#> 5 NA NA 1730 94631
#> ... ... ... ... ...
#> 194 NA NA 2267 142472
#> 195 NA NA 2488 167102
#> 196 NA NA 2324 137565
#> 197 NA NA 2105 113086
#> 198 NA NA 1996 97257
#> basePeakMZ basePeakIntensity ionisationEnergy lowMZ highMZ
#> <numeric> <numeric> <numeric> <numeric> <numeric>
#> 1 144.050 7250 0 104.554 1004.470
#> 2 144.050 7064 0 107.960 1002.799
#> 3 144.050 7124 0 107.963 993.959
#> 4 144.051 7067 0 105.971 986.756
#> 5 144.051 6891 0 104.474 1003.469
#> ... ... ... ... ... ...
#> 194 144.051 4615 0 106.9921 1003.828
#> 195 144.051 3812 0 99.0797 1003.270
#> 196 144.050 3526 0 102.9272 1000.594
#> 197 144.050 3902 0 111.0582 984.228
#> 198 144.051 3587 0 111.0437 1000.851
#> mergedScan mergedResultScanNum mergedResultStartScanNum
#> <integer> <integer> <integer>
#> 1 NA NA NA
#> 2 NA NA NA
#> 3 NA NA NA
#> 4 NA NA NA
#> 5 NA NA NA
#> ... ... ... ...
#> 194 NA NA NA
#> 195 NA NA NA
#> 196 NA NA NA
#> 197 NA NA NA
#> 198 NA NA NA
#> mergedResultEndScanNum injectionTime filterString spectrumId
#> <integer> <numeric> <character> <character>
#> 1 NA 0 NA scan=1
#> 2 NA 0 NA scan=2
#> 3 NA 0 NA scan=3
#> 4 NA 0 NA scan=4
#> 5 NA 0 NA scan=5
#> ... ... ... ... ...
#> 194 NA 0 NA scan=194
#> 195 NA 0 NA scan=195
#> 196 NA 0 NA scan=196
#> 197 NA 0 NA scan=197
#> 198 NA 0 NA scan=198
#> ionMobilityDriftTime scanWindowLowerLimit scanWindowUpperLimit spectrum_id_
#> <numeric> <numeric> <numeric> <integer>
#> 1 NA NA NA 1
#> 2 NA NA NA 2
#> 3 NA NA NA 3
#> 4 NA NA NA 4
#> 5 NA NA NA 5
#> ... ... ... ... ...
#> 194 NA NA NA 194
#> 195 NA NA NA 195
#> 196 NA NA NA 196
#> 197 NA NA NA 197
#> 198 NA NA NA 198
## Available 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" "peaksCount"
#> [21] "totIonCurrent" "basePeakMZ"
#> [23] "basePeakIntensity" "ionisationEnergy"
#> [25] "lowMZ" "highMZ"
#> [27] "mergedScan" "mergedResultScanNum"
#> [29] "mergedResultStartScanNum" "mergedResultEndScanNum"
#> [31] "injectionTime" "filterString"
#> [33] "spectrumId" "ionMobilityDriftTime"
#> [35] "scanWindowLowerLimit" "scanWindowUpperLimit"
#> [37] "spectrum_id_"
## Access mz values
mz(be)
#> NumericList of length 198
#> [[1]] 104.553733825684 106.996170043945 ... 1002.67761230469 1004.47033691406
#> [[2]] 107.959617614746 109.964324951172 ... 991.343811035156 1002.79937744141
#> [[3]] 107.962753295898 112.021392822266 ... 964.238586425781 993.959167480469
#> [[4]] 105.970863342285 109.984230041504 ... 979.084838867188 986.755981445312
#> [[5]] 104.473876953125 106.999610900879 ... 1003.185546875 1003.46936035156
#> [[6]] 102.036674499512 107.963928222656 ... 993.781127929688 994.755920410156
#> [[7]] 104.272621154785 112.024925231934 ... 996.248046875 1001.64440917969
#> [[8]] 98.9297180175781 106.506416320801 ... 991.034484863281 997.045837402344
#> [[9]] 107.966445922852 109.385284423828 ... 995.031494140625 995.600463867188
#> [[10]] 108.965042114258 109.974197387695 ... 982.596313476562 989.777404785156
#> ...
#> <188 more elements>
## Subset the object to spectra in arbitrary order
be_sub <- be[c(5, 1, 1, 2, 4, 100)]
be_sub
#> MsBackendSql with 6 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
#> 6 1 NA 1
#> ... 34 more variables/columns.
#> Use 'spectraVariables' to list all of them.
#> Database: /tmp/RtmpqLniVu/filea684cdb5a7b
## The internal spectrum IDs (primary keys from the database)
be_sub$spectrum_id_
#> [1] 5 1 1 2 4 100
## Add additional spectra variables
be_sub$new_variable <- "B"
## This variable is *cached* locally within the object (not inserted into
## the database)
be_sub$new_variable
#> [1] "B" "B" "B" "B" "B" "B"