Title: | R Toolkit for Mass Spectrometry |
---|---|
Description: | Quickly imports, processes, analyzes, and visualizes mass-spectrometric data. Includes functions for easily extracting specific data and measurements from large (multi-gigabyte) raw Bruker data files, as well as a set of S3 object classes for manipulating and measuring mass spectrometric peaks and plotting peaks and spectra using the 'ggplot2' package. |
Authors: | Mary Ashley Rimmer [aut], Nathaniel Twarog [aut, cre] |
Maintainer: | Nathaniel Twarog <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.2.0 |
Built: | 2025-01-27 02:54:16 UTC |
Source: | https://github.com/cran/rtms |
Produces a sample set (of class rtmsSampleSet
) with no samples but a
specific peaks attribute. Useful for building a sample set one sample at
a time.
emptySampleSet(peaks)
emptySampleSet(peaks)
peaks |
A list of objects of class |
An empty object of class rtmsSampleSet
A subset of an example spectrum depicting turnover from a protein substrate (at 1530.8 m/z) to product (at 1516.8 m/z). While the original spectrum contained nearly 2 million measurements, this spectrum has been trimmed to lie between 1300 m/z and 1600 m/z, with approximately 46000 measurements included.
exampleSpectrum
exampleSpectrum
exampleSpectrum
An object of class rtmsSpectrum
<St. Jude Children's Research Hospital>
Retrieves a table of all metadata values (including instrument data,
acquisition parameters, processing and analysis directives, etc.) from a
Bruker single acquisition BAF directory (represented by an
rtmsBrukerBAFReader
object).
getBrukerBAFAllMetadata(reader)
getBrukerBAFAllMetadata(reader)
reader |
An RTMS reader object of class |
A data frame with all metadata parameters for the acquisition. The
data frame will have five columns: rowIndex
, a numeric index for each
metadata value; parameterName
, the internal identifier of the parameter in
Bruker software systems; parameterGroup
, the group of parameters that each
value belongs to; displayName
, the string used to specify the parameter to
users (i.e. how the parameter would be labelled in a user interface); and
stringValue
, a character column containing the value of each metadata
parameter. Numeric quantities will also be returned as strings, with units
if appropriate.
Retrieves a list of specific metadata values (including instrument data,
acquisition parameters, processing and analysis directives, etc.) from a
Bruker single acquisition BAF directory (represented by an
rtmsBrukerBAFReader
object).
getBrukerBAFMetadata(reader, names)
getBrukerBAFMetadata(reader, names)
reader |
An RTMS reader object of class |
names |
A character vector of metadata names |
A named list of values corresponding to the metadata values specified. All values will be returned as a string, including numeric quantities (with units if appropriate).
Retrieves a table of all metadata values (including instrument data,
acquisition parameters, processing and analysis directives, etc.) for a
specific acquisition from a Bruker multi-acquisition MCF directory
(represented by an rtmsBrukerMCFReader
object).
getBrukerMCFAllMetadata(reader, index)
getBrukerMCFAllMetadata(reader, index)
reader |
An RTMS reader object of class |
index |
A single numeric index specifying which acquisition the sample set should be extracted from |
A data frame with all metadata parameters for the acquisition. The
data frame will have five columns: Index
, the numeric index of the
acquisition; PermanentName
, the internal identifier of the parameter in
Bruker software systems; GroupName
, the group of parameters that each
value belongs to; DisplayName
, the string used to specify the parameter to
users (i.e. how the parameter would be labelled in a user interface); and
Value
, a character column containing the value of each metadata parameter.
Numeric quantities will also be returned as strings, with units if
appropriate.
The size of mass spectrometric data in general, and Bruker MCF directories
specifically, makes the extraction of data a resource intensive and time
consuming process. rtms
as a package is designed to reduce this burden,
but pulling a sample set from an MCF file can (in the event of compressed
spectra) requires reading nearly all data out of a file, which could take an
extremely long time over a network connection. Since peak intensity
(calculated as the sum of local intensity maxima within a given peak width)
is one of the most common measurements used in evaluating spectra, and
because this measure can be extracted without extracting the full spectra,
this function aims to avoid expensive reading time by skipping the creation
of a sample set object and calculating peak intensity directly. Other
measurements are not possible, but full spectra do not have to be read, even
when spectra are compressed, as local maxima are pre-processed and stored
separately in a Bruker MCF file.
getBrukerMCFIntensities(reader, peaks, indices)
getBrukerMCFIntensities(reader, peaks, indices)
reader |
An RTMS reader object of class |
peaks |
A list of peak objects of class |
indices |
A vector of numeric indices specifying which acquisitions the measurements should be taken from |
A data frame containing columns specifying the index of each
acquisition, the name of each acquistion (if indices
is a named vector),
the peak value of the peak measure, the peak name (if peaks
is a named
list), the measure name (which will always be "PeakIntensity"), and the
measured value for that sample and peak. Format matches the output of
measureSampleSet
Retrieves a list of specific metadata values (including instrument data,
acquisition parameters, processing and analysis directives, etc.) for a
specific acquisition from from a Bruker multi-acquisition BAF directory
(represented by an rtmsBrukerBAFReader
object).
getBrukerMCFMetadata(reader, names, index)
getBrukerMCFMetadata(reader, names, index)
reader |
An RTMS reader object of class |
names |
A character vector of metadata names |
index |
A single numeric index specifying which acquisition the sample set should be extracted from |
A named list of values corresponding to the metadata values specified. All values will be returned as a string, including numeric quantities (with units if appropriate).
Assembles a table of all acquisitions in a Bruker MCF file; Bruker measurements are often identified by the metadata parameter "Spot Number", so this function extracts that specific metadata value and joins it with the indices used to pick out spectra in other functions. Also retrieves the timestamp at which acquisition was taken, if acquisitions must be identified by order.
getBrukerMCFSpots(reader) getBrukerMCFIndices(reader)
getBrukerMCFSpots(reader) getBrukerMCFIndices(reader)
reader |
An openRTMS reader object of class |
A data.frame with an Index
column containing the indices of each
acquisition (used by other functions such as getSpectrum
or getSample
),
a SpotNumber
column containing the "Spot Number" metadata value for each
acquisition, and a Timestampe
column containing the time at which each
acquisition was collected by the instrument.
getBrukerMCFIndices()
: Retrieves a vector of all the indices
(beginning with zero) of the acquisitions in the MCF file. Faster than
getBrukerMCFSpots
but contains no metadata or spot names
Fetches an object of class rtmsSample
from the specified object.
getSample(x, peaks, ...)
getSample(x, peaks, ...)
x |
The object from which the sample should be retrieved |
peaks |
A list of objects of class |
... |
Other possible arguments to specify a particular sample to be retrieved |
A sample object of class rtmsSample
Extracts an RTMS sample object (of class rtmsSample
) from a single
acquisition Bruker BAF directory opened using an RTMS reader object (of
class rtmsBrukerBAFReader
). Because a BAF directory only contains one
spectrum, no additional parameters are needed to specify the spectrum from
which to take the sample.
## S3 method for class 'rtmsBrukerBAFReader' getSample(x, peaks, ...) getBrukerBAFSample(reader, peaks)
## S3 method for class 'rtmsBrukerBAFReader' getSample(x, peaks, ...) getBrukerBAFSample(reader, peaks)
x |
The BAF reader object |
peaks |
A list of peak objects of class |
... |
Additional parameters |
reader |
An RTMS reader object of class |
An RTMS sample object of class rtmsSample
getSample(rtmsBrukerBAFReader)
: The S3 method getSample
for objects
of class rtmsBrukerBAFReader
; calls getBrukerBAFSample
Extracts an RTMS sample object (of class rtmsSample
) from a multi-
acquisition Bruker MCF directory opened using an RTMS reader object (of
class rtmsBrukerMCFReader
). A numeric index is used to identify which
acquisition the sample should be extracted from.
## S3 method for class 'rtmsBrukerMCFReader' getSample(x, peaks, ...) getBrukerMCFSample(reader, peaks, index)
## S3 method for class 'rtmsBrukerMCFReader' getSample(x, peaks, ...) getBrukerMCFSample(reader, peaks, index)
x |
The MCF reader object |
peaks |
A list of peak objects of class |
... |
Additional parameters |
reader |
An RTMS reader object of class |
index |
A single numeric index specifying which acquisition the sample set should be extracted from |
An RTMS sample object of class rtmsSample
getSample(rtmsBrukerMCFReader)
: The S3 method getSample
for objects
of class rtmsBrukerMCFReader
; calls getBrukerMCFSample
Extracts a sample object of class rtmsSample
from a single spectrum object
of class rtmsSample
usin g a list of peaks
## S3 method for class 'rtmsSpectrum' getSample(x, peaks, ...) getSampleFromSpectrum(spectrum, peaks, freqSpacing = TRUE, threshold = NULL)
## S3 method for class 'rtmsSpectrum' getSample(x, peaks, ...) getSampleFromSpectrum(spectrum, peaks, freqSpacing = TRUE, threshold = NULL)
x |
The spectrum object |
peaks |
A list of peak objects of class |
... |
Additional parameters |
spectrum |
A full spectrum of class |
freqSpacing |
If TRUE (the default), local maxima (estimated via quadratic interpolation) are calculated in inverse m/z (or frequency) space, as in FTMS spectra. If FALSE, maxima are calculated directy in m/z space |
threshold |
If NULL, all local maxima will be returned for each subsample; if set to particular value, only those maxima above that threshold will be returned. |
An RTMS sample object of class rtmsSample
getSample(rtmsSpectrum)
: The S3 method getSample
for objects
of class rtmsSpectrum
; calls getSampleFromSpectrum
peaks <- rtmsPeakList(c(1516.83,1530.84),peakWidth=0.2,windowWidth = c(5,10)) names(peaks) <- c("Product","Substrate") sample <- getSample(exampleSpectrum,peaks)
peaks <- rtmsPeakList(c(1516.83,1530.84),peakWidth=0.2,windowWidth = c(5,10)) names(peaks) <- c("Product","Substrate") sample <- getSample(exampleSpectrum,peaks)
Fetches an object of class rtmsSampleSet
from the specified object.
getSampleSet(x, peaks, ...)
getSampleSet(x, peaks, ...)
x |
The object from which the sample set should be retrieved |
peaks |
A list of objects of class |
... |
Other possible arguments to specify a particular sample set to be retrieved |
A sample set object of class rtmsSampleSet
Extracts an RTMS sample object (of class rtmsSampleSet
) from a multi-
acquisition Bruker MCF directory opened using an RTMS reader object (of
class rtmsBrukerMCFReader
). A vector numeric indices is used to identify
which acquisitions the sample set should be extracted from.
## S3 method for class 'rtmsBrukerMCFReader' getSampleSet(x, peaks, ...) getBrukerMCFSampleSet(reader, peaks, indices)
## S3 method for class 'rtmsBrukerMCFReader' getSampleSet(x, peaks, ...) getBrukerMCFSampleSet(reader, peaks, indices)
x |
The MCF reader object |
peaks |
A list of peak objects of class |
... |
Additional parameters |
reader |
An RTMS reader object of class |
indices |
A vector of numeric indices specifying which acquisitions the sample set should be extracted from |
An RTMS sample set object of class rtmsSampleSet
getSampleSet(rtmsBrukerMCFReader)
: The S3 method getSample
for objects
of class rtmsBrukerMCFReader
; calls getBrukerMCFSampleSet
Fetches an object of class rtmsSpectrum
from the specified object.
getSpectrum(x, ...)
getSpectrum(x, ...)
x |
The object from which the spectrum should be retrieved |
... |
Other possible arguments to specify a particular spectrum to be retrieved |
An spectrum object of class rtmsSpectrum
Extracts an RTMS spectrum object (of class rtmsSpectrum
) from a single
acquisition Bruker BAF directory opened using an RTMS reader object (of
class rtmsBrukerBAFReader
). Because a BAF directory only contains one
spectrum, no additional parameters are needed to specify the spectrum to be
extracted.
## S3 method for class 'rtmsBrukerBAFReader' getSpectrum(x, ...) getBrukerBAFSpectrum(reader)
## S3 method for class 'rtmsBrukerBAFReader' getSpectrum(x, ...) getBrukerBAFSpectrum(reader)
x |
The BAF reader object |
... |
Additional parameters |
reader |
An RTMS reader object of class |
An RTMS spectrum object of class rtmsSpectrum
getSpectrum(rtmsBrukerBAFReader)
: The S3 method getSpectrum
for objects
of class rtmsBrukerBAFReader
; calls getBrukerBAFSpectrum
Extracts an RTMS spectrum object (of class rtmsSpectrum
) from a multi-
acquisition Bruker MCF directory opened using an RTMS reader object (of
class rtmsBrukerMCFReader
). A numeric index is used to identify which
spectrum should be extracted.
## S3 method for class 'rtmsBrukerMCFReader' getSpectrum(x, ...) getBrukerMCFSpectrum(reader, index)
## S3 method for class 'rtmsBrukerMCFReader' getSpectrum(x, ...) getBrukerMCFSpectrum(reader, index)
x |
The MCF reader object |
... |
Additional parameters |
reader |
An RTMS reader object of class |
index |
A single numeric index specifying which acquisition should be extracted |
An RTMS spectrum object of class rtmsSpectrum
getSpectrum(rtmsBrukerMCFReader)
: The S3 method getSpectrum
for objects
of class rtmsBrukerMCFReader
; calls getBrukerMCFSpectrum
measureSample()
extracts one or more measurements for every peak in
an RTMS sample object (of class rtmsSample
).
measureSample(sample, measure = "PeakIntensity")
measureSample(sample, measure = "PeakIntensity")
sample |
An object of class |
measure |
A character vector of named measurements, or a list of
custom measurement functions. Supported measurement names are
"PeakIntensity", which takes the total of any local maxima within the peak
width, "PeakArea", which takes the area under the intensity curve within the
peak width, and "NumPeaks", which counts the local maxima in the peak window.
If |
A data frame with one row for each peak and measurement in the
sample. The data.frame will have a column named "peakName" with the name of
the relevant peak (if the "peaks" attribute of sample
is a named list);
a column named "peakValue" containing the m/z value at the center of the
relevant peak; a column named "measure" containing the name of the relevant
measure; and a column named "value" containing the numeric value of the
particular measure for that peak.
peaks <- rtmsPeakList(c(1516.83,1530.84),peakWidth=0.2,windowWidth = c(5,10)) names(peaks) <- c("Product","Substrate") sample <- getSample(exampleSpectrum,peaks) measure <- measureSample(sample,c("PeakArea","PeakIntensity")) myFunctions <- list(PeakRawIntensity = function(s) max(s$peakPiece$intensity)) myMeasures <- measureSample(sample,myFunctions)
peaks <- rtmsPeakList(c(1516.83,1530.84),peakWidth=0.2,windowWidth = c(5,10)) names(peaks) <- c("Product","Substrate") sample <- getSample(exampleSpectrum,peaks) measure <- measureSample(sample,c("PeakArea","PeakIntensity")) myFunctions <- list(PeakRawIntensity = function(s) max(s$peakPiece$intensity)) myMeasures <- measureSample(sample,myFunctions)
measureSampleSet()
extracts one or more measurements for every peak in
every sample in an RTMS sample set object (of class rtmsSampleSet
).
measureSampleSet(sampleset, measure = "PeakIntensity")
measureSampleSet(sampleset, measure = "PeakIntensity")
sampleset |
An object of class |
measure |
A character vector of named measurements, or a list of
custom measurement functions. Supported measurement names are
"PeakIntensity", which takes the total of any local maxima within the peak
width, "PeakArea", which takes the area under the intensity curve within the
peak width, and "NumPeaks", which counts the local maxima in the peak window.
If |
A data frame with one row for each sample, peak, and measurement.
The data.frame will have a character column named "sample", containing either
the name of the sample (if the samples in sampleset
are named) or the
index of the sample if they are not (but it will always be a character
column); a column named "peakName" with the name of the relevant peak (if
the "peaks" attribute of sampleset
is a named list); a column named
"peakValue" containing the m/z value at the center of the relevant peak; a
column named "measure" containing the name of the relevant measure; and a
column named "value" containing the numeric value of the particular measure
for that sample and peak.
peaks <- rtmsPeakList(c(1516.83,1530.84),peakWidth=0.2,windowWidth = c(5,10)) names(peaks) <- c("Product","Substrate") sample <- getSample(exampleSpectrum,peaks) sampleSet <- rep(sample,3) names(sampleSet) <- c("A","B","C") measures <- measureSampleSet(sampleSet)
peaks <- rtmsPeakList(c(1516.83,1530.84),peakWidth=0.2,windowWidth = c(5,10)) names(peaks) <- c("Product","Substrate") sample <- getSample(exampleSpectrum,peaks) sampleSet <- rep(sample,3) names(sampleSet) <- c("A","B","C") measures <- measureSampleSet(sampleSet)
Creates an RTMS reader object (of class rtmsBrukerBAFReader
) which can
extract data from a Bruker single acquisition directory (extension ".d")
newBrukerBAFReader(bafdir)
newBrukerBAFReader(bafdir)
bafdir |
A directory (usually with the extension ".d") containing data from a single Bruker acquisition. This directory will contain a file with extension ".baf" that holds the primary raw data, as well as an index and calibration file (see Details). |
Currently, RTMS can create reader objects for two binary Bruker data formats, BAF (presumably standing for "Bruker acquisition format") holding data from a single spectrum acquisition, and MCF (probably "multiacquisition container format") containing data from multiple spectra acquired in a single run. Both formats hold data in a directory marked with the extension ".d". The single acquisition BAF format directory contains three essential data files: the main raw data file with extension ".baf", an index file with extension ".baf_idx", and a calibration data file with extension ".baf_xtr". This function processes the index and calibration files so that raw data can be extracted quickly on demand from the ".baf" file.
An important note: when a MCF multi-acquistion reader is created, it creates
an open connection to the raw data file, which allows for quicker processing
of many spectra in a single file. However, because a BAF file contains only
a single spectrum, there is little advantage to maintaining an open
connection, so the connection is re-opened every time data is read. Thus,
while it is important to close an MCF reader object when all data is
extracted, it is not necessary to close an object of class
rtmsBrukerBAFReader
.
An object of class rtmsBrukerBAFReader
which can extract raw data
from the specified directory
Creates an RTMS reader object (of class rtmsBrukerMCFReader
) which can
extract data from a Bruker multi-acquisition directory (extension ".d")
newBrukerMCFReader(mcfdir)
newBrukerMCFReader(mcfdir)
mcfdir |
A directory (usually with the extension ".d") containing data from a Bruker multi-acquisition run. This directory will contain a files with extenssion ".mcf" and matching index files with extension ".mcf_idx" (see Details). |
Currently, RTMS can create reader objects for two binary Bruker data formats, BAF (presumably standing for "Bruker acquisition format") holding data from a single spectrum acquisition, and MCF (probably "multi-acquisition container format") containing data from multiple spectra acquired in a single run. Both formats hold data in a directory marked with the extension ".d". The multi-acquisition MCF format directory contains four essential data files: the main raw data file ending in "_1" with extension ".mcf", a matching index file with extension ".mcf_idx", and a calibration data file ending in "_2" with extension ".mcf", and the matching calibration index file with extension ".mcf_idx". This function preprocesses the main index file and calibration files so that raw data can be extracted quickly on demand from the main ".mcf" file.
An important note: when a MCF multi-acquisition reader is created, it creates
an open connection to the raw data file, which allows for quicker processing
of many spectra in a single file. This connection will remain open until
the reader is closed with the close
function.
A reader object of class rtmsBrukerMCFReader
with an open
connection to the main ".mcf" data file.
plotRtmsSample()
takes an RTMS sample object and produces a ggplot
object
depicting all extracted peaks, and their context windows if included.
plotRtmsSample(sample, usePeakNames = TRUE, freey = TRUE)
plotRtmsSample(sample, usePeakNames = TRUE, freey = TRUE)
sample |
An object of class |
usePeakNames |
If the list of peaks used to create the sample was a named list, then setting this to TRUE (the default) will use those names to label the facets of the plotted sample. If set to FALSE, the facets will be labelled with the m/z values of each peak. This parameter will be ignored if the peaks are unnamed. |
freey |
If TRUE (the default) the y-axes of each peak's facet will be allowed to vary freely, so different peaks will be plotted on different scales. Setting this to FALSE will fix all peaks with in a sample on the same y-axis scale. |
A ggplot
object depicting the RTMS sample.
peaks <- rtmsPeakList(c(1516.83,1530.84),peakWidth=0.2,windowWidth = c(5,10)) names(peaks) <- c("Product","Substrate") sample <- getSample(exampleSpectrum,peaks) plot1 <- plotRtmsSample(sample) plot2 <- plotRtmsSample(sample,freey=FALSE)
peaks <- rtmsPeakList(c(1516.83,1530.84),peakWidth=0.2,windowWidth = c(5,10)) names(peaks) <- c("Product","Substrate") sample <- getSample(exampleSpectrum,peaks) plot1 <- plotRtmsSample(sample) plot2 <- plotRtmsSample(sample,freey=FALSE)
plotRtmsSampleSet()
takes an RTMS sample set object and produces a ggplot
object depicting all extracted peaks, and their context windows if included.
plotRtmsSampleSet(sampleset, usePeakNames = TRUE, freey = TRUE)
plotRtmsSampleSet(sampleset, usePeakNames = TRUE, freey = TRUE)
sampleset |
An object of class |
usePeakNames |
If the list of peaks used to create the sample set was a named list, then setting this to TRUE (the default) will use those names to label the facets of the plotted sample set. If set to FALSE, the facets will be labelled with the m/z values of each peak. This parameter will be ignored if the peaks are unnamed. |
freey |
If TRUE (the default) the y-axes of each sample and peak's facet will beallowed to vary freely, so different facets will be plotted on different scales. Setting this to FALSE will fix all peaks and samples on the same y-axis scale. |
A ggplot
object depicting the RTMS sample set.
peaks <- rtmsPeakList(c(1516.83,1530.84),peakWidth=0.2,windowWidth = c(5,10)) names(peaks) <- c("Product","Substrate") sample <- getSample(exampleSpectrum,peaks) sampleSet <- rep(sample,3) names(sampleSet) <- c("A","B","C") plot1 <- plotRtmsSampleSet(sampleSet) plot2 <- plotRtmsSampleSet(sampleSet,freey=FALSE) + ggplot2::theme_bw()
peaks <- rtmsPeakList(c(1516.83,1530.84),peakWidth=0.2,windowWidth = c(5,10)) names(peaks) <- c("Product","Substrate") sample <- getSample(exampleSpectrum,peaks) sampleSet <- rep(sample,3) names(sampleSet) <- c("A","B","C") plot1 <- plotRtmsSampleSet(sampleSet) plot2 <- plotRtmsSampleSet(sampleSet,freey=FALSE) + ggplot2::theme_bw()
plotRtmsSpectrum()
takes an RTMS spectrum object and produces a ggplot
object depicting the spectrum
plotRtmsSpectrum(spectrum, limits = NULL)
plotRtmsSpectrum(spectrum, limits = NULL)
spectrum |
An object of class |
limits |
An optional parameter to control the bounds of the m/z x axis.
If set to NULL, the default, the full spectrum will be plotted. Otherwise,
|
Unlike a sample object, an RTMS spectrum is actually quite simple; just a
vector of m/z values and vector of intensities. Ordinarily, this could be
done using standard ggplot2
functions, such as geom_line. However, mass
spectra can often be quite large (on the order of millions of measurements),
and sending all that data to be plotted can be computationally intractable.
plotRtmsSpectrum()
therefore selects a subset of up to 10000 m/z-intensity
pairs from the original spectrum to produce a representative plot without
rendering millions of points. Any points that are sufficiently larger than
their local surroundings (including all relevant peaks) will be included in
this subset, as well as a random sampling of points closer to the baseline.
This ensures that the peaks plotted will always be present. However, there
will be slight differences from one plot to the next in terms of baseline
points plotted. This can be eliminated by fixing the random seed using
set.seed
before plotting.
We also strongly discourage using xlim
or seetting the x-coordinate
boundaries using standard ggplot2
methods, as these will only be applied
after the data has been down-sampled. If you would like to plot a particular
subset of the spectrum, it is recommended that you use the limits
parameter
of this function instead.
A ggplot
object depicting the RTMS spectrum.
plot1 <- plotRtmsSpectrum(exampleSpectrum) plot2 <- plotRtmsSpectrum(exampleSpectrum,limits=c(1500,1550)) + ggplot2::geom_vline(xintercept=c(1516.83,1530.84), colour="red",linetype=2)
plot1 <- plotRtmsSpectrum(exampleSpectrum) plot2 <- plotRtmsSpectrum(exampleSpectrum,limits=c(1500,1550)) + ggplot2::geom_vline(xintercept=c(1516.83,1530.84), colour="red",linetype=2)
An S3 generic function for reopening reader objects that have been close
reopen(x, ...)
reopen(x, ...)
x |
The object to be re-opened |
... |
Other possible arguments for specific object types |
An object of the same type as x
Closes the open connection to the main data file in a Bruker MCF reader object.
## S3 method for class 'rtmsBrukerMCFReader' reopen(x, ...) ## S3 method for class 'rtmsBrukerMCFReader' close(con, ...) closeBrukerMCFReader(reader) reopenBrukerMCFReader(reader)
## S3 method for class 'rtmsBrukerMCFReader' reopen(x, ...) ## S3 method for class 'rtmsBrukerMCFReader' close(con, ...) closeBrukerMCFReader(reader) reopenBrukerMCFReader(reader)
x |
The reader object to reopen |
... |
Included for S3 compatibility |
con |
The reader object to be closed |
reader |
An RTMS reader object of class |
Because Bruker MCF directories contain a potentially large number of
spectra, reopening a connection to the main data file when reading many
spectra or samples from it is inefficient and slow, especially if the file
is being accessed over a network connection. The rtmsBrukerMCFReader
object therefore maintains an open connection to the main binary data file
until it is closed by the user. Of course, the reader object still maintains
all the index and calibration data, making it possible to reopen a
connection to the MCF directory without all the preprocessing required when
first opening. Unfortunately, taking advantage of this fact is a little
tricky.
In most cases, R is a functional language, with limited side effects on R
objects; so it is difficult to alter the state of reader object without
returning it explicitly. However, one of the few cases where side-effects
are quite important is R's management of open file connections, with
functions like close
. Thus, calling closeBrukerMCFReader
(and the S3
function close
which wraps it) will in fact close the connection, but will
not return an altered copy of the reader object reflecting that it is
closed. So if the user wishes to close a reader object with the possibility
of reopening it, they must close the reader AND assign the returned reader
object to the relevant name. This will store the fact the connection has
been closed, and allow the reopen
function to operate correctly.
The same reader object with a closed connection
reopen(rtmsBrukerMCFReader)
: The S3 method close
for objects of class
rtmsBrukerMCFReader
; calls closeBrukerMCFReader
close(rtmsBrukerMCFReader)
: The S3 method reopen
for objects of class
rtmsBrukerMCFReader
; calls reopenBrukerMCFReader
reopenBrukerMCFReader()
: Reopens a file connection to the main
binary data file in a Bruker MCF directgry so that data can be extracted
Generates an object of class rtmsPeak
which contains the m/z values
bounding a spectrometric peak to be measured. A peak object specifies not
only the m/z value at the cetner of the peak, but the upper and lower bounds
within which the peak is to be quantified; it also may optionally include
wider upper and lower bounds used to plot the peak in a wider context of the
spectrum.
rtmsPeak( value, peakWidth = 0.1, windowWidth = NULL, bounds = NULL, window = NULL )
rtmsPeak( value, peakWidth = 0.1, windowWidth = NULL, bounds = NULL, window = NULL )
value |
The m/z value that the peak is intended to measure |
peakWidth |
The width of the peak centered on |
windowWidth |
The width of the optional wider window around |
bounds |
If not null, a two-value numeric vector specifying the lower
and upper m/z bounds of the measured peak. One of |
window |
If not null, a two-value numeric vector specifying the lower
and upper m/z bounds of the wider context window of the peak. If |
An object of class rtmsPeak
, used by RTMS functions to extract
and measure peaks from mass spectra.
peaks <- rtmsPeak(1516.83,peakWidth=0.2,windowWidth = c(5,10))
peaks <- rtmsPeak(1516.83,peakWidth=0.2,windowWidth = c(5,10))
Generates a list of objects of class rtmsPeak
which can be used to extract
a sample or sample set from other RTMS objects.
rtmsPeakList(values, peakWidth = 0.1, windowWidth = NULL)
rtmsPeakList(values, peakWidth = 0.1, windowWidth = NULL)
values |
The m/z values that the peaks is intended to measure |
peakWidth |
The width of each peak centered on |
windowWidth |
The width of each optional wider window around the m/z
values used to show the peaks in context. Operates by the same principles as
|
A list of objects of class rtmsPeak
peaks <- rtmsPeakList(c(1516.83,1530.84),peakWidth=0.2,windowWidth = c(5,10)) names(peaks) <- c("Product","Substrate")
peaks <- rtmsPeakList(c(1516.83,1530.84),peakWidth=0.2,windowWidth = c(5,10)) names(peaks) <- c("Product","Substrate")
Generates an RTMS spectrum object (of class rtmsSpectrum
) from a given
vector of m/z and intensity values.
rtmsSpectrum(mz, intensity)
rtmsSpectrum(mz, intensity)
mz |
A numeric vector of m/z values |
intensity |
A numeric vector of intensity values |
An object of class rtmsSpectrum
with the given m/z and intensity
values
Select a subset of a sample set (returns an rtmsSampleSet
)
## S3 method for class 'rtmsSampleSet' x[i, ...] ## S3 method for class 'rtmsSampleSet' x[[i, ...]] ## S3 replacement method for class 'rtmsSampleSet' x[[i]] <- value ## S3 method for class 'rtmsSampleSet' rep(x, ...) ## S3 method for class 'rtmsSample' rep(x, ...)
## S3 method for class 'rtmsSampleSet' x[i, ...] ## S3 method for class 'rtmsSampleSet' x[[i, ...]] ## S3 replacement method for class 'rtmsSampleSet' x[[i]] <- value ## S3 method for class 'rtmsSampleSet' rep(x, ...) ## S3 method for class 'rtmsSample' rep(x, ...)
x |
An object of class |
i |
A single numeric index of the sample set |
... |
Included for S3 compatibility |
value |
An object of class |
The sample (class rtmsSample
) and sample set (class rtmsSampleSet
)
objects are the core structures used to extract meaningful data from mass
spectographic data. In general, samples and sample sets will be created
automatically from other RTMS objects (such as readers or spectra) but in
the event that one wishes to manipulate them directly, it is important to
understand several details about how they work.
In terms of the data it contains, an object of class rtmsSample
is just a
list of smaller objects (of class rtmsSubsample
); however, each of these
subsamples corresponds to an rtmsPeak
object that was used to extract it;
the rtmsSample
object therefor has a "peaks" attribute, which is a list of
objects of class rtmsPeak
corresponding to the subsamples in the
rtmsSample
object. This attribute is used to determine how measurements
of the sample are reported and how the sample is plotted.
Similarly, the data contained in an object of class rtmsSampleSet
is just
a list of rtmsSample
objects but with an important difference. If many
rtmsSample
objects were arranged into a list, there would be no guarantee
that they contain measurements of the same peaks; such guarantees are
essential for plotting sample sets together or constructing extracted ion
chromatograms. The rtmsSampleSet
therefore strips the "peaks" attribute
from its individual members, and applies a single shared "peaks" attribute
to the entire sample set. Further samples can only be added to the sample
set if their peaks attributes are deemed compatible.
An object of class rtmsSampleSet
An object of class rtmsSample
An object of class rtmsSampleSet
An object of class rtmsSampleSet
An object of class rtmsSampleSet
[[
: Select a single element of a sample set
(returns an rtmsSample
)
`[[`(rtmsSampleSet) <- value
: Insert a sample into a sample set
rep(rtmsSampleSet)
: Repeat a sample set multiple times
rep(rtmsSample)
: Create a sample set by repeating a single
sample (returns an rtmsSampleSet
)