Description Usage Arguments Value Supported Backend functions Not supported Backend functions Retrieving compound annotations for spectra Author(s) Examples
View source: R/MsBackendMassbankSql-functions.R
The MsBackendMassbankSql
provides access to mass spectrometry data from
MassBank by directly accessing its
MySQL/MariaDb database. In addition it supports adding new spectra variables
or locally changing spectra variables provided by MassBank (without
changing the original values in the database).
Note that MsBackendMassbankSql
requires a local installation of the
MassBank database since direct database access is not supported for the
main MassBank instance.
Also, some of the fields in the MassBank database are not directly compatible
with Spectra
, such as the collision energy which is not available as a
numeric value. The collision energy as available in MassBank is reported as
spectra variable "collision_energy_text"
. Also, precursor m/z values
reported for some spectra can not be converted to a numeric
and hence NA
is reported with the spectra variable precursorMz
for these spectra. The
variable "precursor_mz_text"
can be used to get the original precursor
m/z reported in MassBank.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | MsBackendMassbankSql()
## S4 method for signature 'MsBackendMassbankSql'
show(object)
## S4 method for signature 'MsBackendMassbankSql'
backendInitialize(object, dbcon, ...)
## S4 method for signature 'MsBackendMassbankSql'
acquisitionNum(object)
## S4 method for signature 'MsBackendMassbankSql'
peaksData(object)
## S4 method for signature 'MsBackendMassbankSql'
centroided(object)
## S4 replacement method for signature 'MsBackendMassbankSql'
centroided(object) <- value
## S4 method for signature 'MsBackendMassbankSql'
collisionEnergy(object)
## S4 replacement method for signature 'MsBackendMassbankSql'
collisionEnergy(object) <- value
## S4 method for signature 'MsBackendMassbankSql'
dataOrigin(object)
## S4 replacement method for signature 'MsBackendMassbankSql'
dataOrigin(object) <- value
## S4 method for signature 'MsBackendMassbankSql'
dataStorage(object)
## S4 method for signature 'MsBackendMassbankSql'
intensity(object)
## S4 replacement method for signature 'MsBackendMassbankSql'
intensity(object) <- value
## S4 method for signature 'MsBackendMassbankSql'
ionCount(object)
## S4 method for signature 'MsBackendMassbankSql'
isEmpty(x)
## S4 method for signature 'MsBackendMassbankSql'
isolationWindowLowerMz(object)
## S4 replacement method for signature 'MsBackendMassbankSql'
isolationWindowLowerMz(object) <- value
## S4 method for signature 'MsBackendMassbankSql'
isolationWindowTargetMz(object)
## S4 replacement method for signature 'MsBackendMassbankSql'
isolationWindowTargetMz(object) <- value
## S4 method for signature 'MsBackendMassbankSql'
isolationWindowUpperMz(object)
## S4 replacement method for signature 'MsBackendMassbankSql'
isolationWindowUpperMz(object) <- value
## S4 method for signature 'MsBackendMassbankSql'
length(x)
## S4 method for signature 'MsBackendMassbankSql'
msLevel(object)
## S4 method for signature 'MsBackendMassbankSql'
mz(object)
## S4 replacement method for signature 'MsBackendMassbankSql'
mz(object) <- value
## S4 method for signature 'MsBackendMassbankSql'
lengths(x, use.names = FALSE)
## S4 method for signature 'MsBackendMassbankSql'
polarity(object)
## S4 replacement method for signature 'MsBackendMassbankSql'
polarity(object) <- value
## S4 method for signature 'MsBackendMassbankSql'
precursorCharge(object)
## S4 method for signature 'MsBackendMassbankSql'
precursorIntensity(object)
## S4 method for signature 'MsBackendMassbankSql'
precursorMz(object)
## S4 method for signature 'MsBackendMassbankSql'
reset(object)
## S4 method for signature 'MsBackendMassbankSql'
rtime(object)
## S4 replacement method for signature 'MsBackendMassbankSql'
rtime(object) <- value
## S4 method for signature 'MsBackendMassbankSql'
scanIndex(object)
## S4 method for signature 'MsBackendMassbankSql'
selectSpectraVariables(object, spectraVariables = spectraVariables(object))
## S4 method for signature 'MsBackendMassbankSql'
smoothed(object)
## S4 replacement method for signature 'MsBackendMassbankSql'
smoothed(object) <- value
## S4 method for signature 'MsBackendMassbankSql'
spectraData(object, columns = spectraVariables(object))
## S4 replacement method for signature 'MsBackendMassbankSql'
spectraData(object) <- value
## S4 method for signature 'MsBackendMassbankSql'
spectraNames(object)
## S4 replacement method for signature 'MsBackendMassbankSql'
spectraNames(object) <- value
## S4 method for signature 'MsBackendMassbankSql'
spectraVariables(object)
## S4 method for signature 'MsBackendMassbankSql'
tic(object, initial = TRUE)
## S4 method for signature 'MsBackendMassbankSql'
x[i, j, ..., drop = FALSE]
## S4 method for signature 'MsBackendMassbankSql'
x$name
## S4 replacement method for signature 'MsBackendMassbankSql'
x$name <- value
## S4 method for signature 'Spectra'
compounds(object, ...)
## S4 method for signature 'MsBackendMassbankSql'
compounds(object, ...)
|
object |
Object extending |
dbcon |
For |
... |
Additional arguments. |
value |
replacement value for |
x |
Object extending |
use.names |
For |
spectraVariables |
For |
columns |
For |
initial |
For |
i |
For |
j |
For |
drop |
For |
name |
For |
See documentation of respective function.
The following functions are supported by the MsBackendMassbankSqlMassbankDb
.
[
: subset the backend. Only subsetting by element (row/i
) is
allowed
$
, $<-
: access or set/add a single spectrum variable (column) in the
backend.
acquisitionNum
: returns the acquisition number of each
spectrum. Returns an integer
of length equal to the number of
spectra (with NA_integer_
if not available).
peaksData
returns a list
with the spectras' peak data. The length of
the list is equal to the number of spectra in object
. Each element of
the list is a matrix
with columns "mz"
and "intensity"
. For an empty
spectrum, a matrix
with 0 rows and two columns (named mz
and
intensity
) is returned.
backendInitialize
: initialises the backend by retrieving the IDs of all
spectra in the database. Parameter dbcon
with the connection to the
MassBank MySQL database is required.
dataOrigin
: gets a character
of length equal to the number of spectra
in object
with the data origin of each spectrum. This could e.g. be
the mzML file from which the data was read.
dataStorage
: returns "<MassBank>"
for all spectra.
centroided
, centroided<-
: gets or sets the centroiding
information of the spectra. centroided
returns a logical
vector of length equal to the number of spectra with TRUE
if a
spectrum is centroided, FALSE
if it is in profile mode and NA
if it is undefined. See also isCentroided
for estimating from
the spectrum data whether the spectrum is centroided. value
for centroided<-
is either a single logical
or a logical
of
length equal to the number of spectra in object
.
collisionEnergy
, collisionEnergy<-
: gets or sets the
collision energy for all spectra in object
. collisionEnergy
returns a numeric
with length equal to the number of spectra
(NA_real_
if not present/defined), collisionEnergy<-
takes a
numeric
of length equal to the number of spectra in object
. Note that
the collision energy description from MassBank are provided as spectra
variable "collisionEnergyText"
.
intensity
: gets the intensity values from the spectra. 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
.
ionCount
: returns a numeric
with the sum of intensities for
each spectrum. If the spectrum is empty (see isEmpty
),
NA_real_
is returned.
isCentroided
: a heuristic approach assessing if the spectra in
object
are in profile or centroided mode. The function takes
the qtl
th quantile top peaks, then calculates the difference
between adjacent m/z value and returns TRUE
if the first
quartile is greater than k
. (See Spectra:::.isCentroided
for
the code.)
isEmpty
: checks whether a spectrum in object
is empty
(i.e. does not contain any peaks). Returns a logical
vector of
length equal number of spectra.
isolationWindowLowerMz
, isolationWindowLowerMz<-
: gets or sets the
lower m/z boundary of the isolation window.
isolationWindowTargetMz
, isolationWindowTargetMz<-
: gets or sets the
target m/z of the isolation window.
isolationWindowUpperMz
, isolationWindowUpperMz<-
: gets or sets the
upper m/z boundary of the isolation window.
isReadOnly
: returns a logical(1)
whether the backend is read
only or does allow also to write/update data.
length
: returns the number of spectra in the object.
lengths
: gets the number of peaks (m/z-intensity values) per
spectrum. Returns an integer
vector (length equal to the
number of spectra). For empty spectra, 0
is returned.
msLevel
: gets the spectra's MS level. Returns an integer
vector (of length equal to the number of spectra) with the MS
level for each spectrum (or NA_integer_
if not available).
mz
: gets the mass-to-charge ratios (m/z) from the
spectra. Returns a NumericList()
or length equal to the number of
spectra, each element a numeric
vector with the m/z values of
one spectrum.
polarity
, polarity<-
: gets or sets the polarity for each
spectrum. polarity
returns an integer
vector (length equal
to the number of spectra), with 0
and 1
representing negative
and positive polarities, respectively. polarity<-
expects an
integer vector of length 1 or equal to the number of spectra.
precursorCharge
, precursorIntensity
, precursorMz
,
precScanNum
, precAcquisitionNum
: get the charge (integer
),
intensity (numeric
), m/z (numeric
), scan index (integer
)
and acquisition number (interger
) of the precursor for MS level
2 and above spectra from the object. Returns a vector of length equal to
the number of spectra in object
. NA
are reported for MS1
spectra of if no precursor information is available.
reset
: restores the backend to its original state, i.e. deletes all
locally modified data and reinitializes the backend to the full data
available in the database.
rtime
, rtime<-
: gets or sets the retention times for each
spectrum (in seconds). rtime
returns a numeric
vector (length equal to
the number of spectra) with the retention time for each spectrum.
rtime<-
expects a numeric vector with length equal to the
number of spectra.
scanIndex
: returns an integer
vector with the scan index
for each spectrum. This represents the relative index of the
spectrum within each file. Note that this can be different to the
acquisitionNum
of the spectrum which is the index of the
spectrum as reported in the mzML file.
selectSpectraVariables
: reduces the information within the backend to
the selected spectra variables.
smoothed
,smoothed<-
: gets or sets whether a spectrum is
smoothed. smoothed
returns a logical
vector of length equal
to the number of spectra. smoothed<-
takes a logical
vector
of length 1 or equal to the number of spectra in object
.
spectraData
: gets general spectrummetadata (annotation, also called
header). spectraData
returns a DataFrame
. Note that replacing the
spectra data with spectraData<-
is not supported.
spectraNames
: returns a character
vector with the names of
the spectra in object
.
spectraVariables
: returns a character
vector with the
available spectra variables (columns, fields or attributes)
available in object
. This should return all spectra variables which
are present in object
, also "mz"
and "intensity"
(which are by
default not returned by the spectraVariables,Spectra
method).
tic
: gets the total ion current/count (sum of signal of a
spectrum) for all spectra in object
. By default, the value
reported in the original raw data file is returned. For an empty
spectrum, NA_real_
is returned.
The following functions are not supported by the MsBackendMassbankSql
since
the original data can not be changed.
backendMerge
, export
, filterDataStorage
, filterPrecursorScan
,
peaksData<-
, filterAcquisitionNum
, intensity<-
, mz<-
, precScanNum
,
spectraData<-
, spectraNames<-
.
While compound annotations are also provided via the spectraVariables
of
the backend, it would also be possible to use the compounds
function on
a Spectra
object (that uses a MsBackendMassbankSql
backend) to retrieve
compound annotations for the specific spectra.
Johannes Rainer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | ## Create a connection to a database with MassBank data - in the present
## example we connect to a tiny SQLite database bundled in this package
## as public access to the MassBank MySQL is not (yet) supported. See the
## vignette for more information on how to install MassBank locally and
## enable MySQL database connections
library(RSQLite)
con <- dbConnect(SQLite(), system.file("sql/minimassbank.sql",
package = "MsBackendMassbank"))
## Given that we have the connection to a MassBank databas we can
## initialize the backend:
be <- backendInitialize(MsBackendMassbankSql(), dbcon = con)
be
## Access MS level
msLevel(be)
be$msLevel
## Access m/z values
be$mz
## Access the full spectra data (including m/z and intensity values)
spectraData(be)
## Add a new spectra variable
be$new_variable <- "b"
be$new_variable
## Subset the backend
be_sub <- be[c(3, 1)]
spectraNames(be)
spectraNames(be_sub)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.