The 'MSnExp' Class for MS Data And Meta-Data
MSnExp-class.RdThe MSnExp class encapsulates data and meta-data for mass
spectrometry experiments, as described in the slots
section. Several data files (currently in mzXML) can be loaded
together with the function readMSData.
This class extends the virtual "pSet" class.
In version 1.19.12, the polarity slot had been added to the
"Spectrum" class (previously in
"Spectrum1"). Hence, "MSnExp" objects
created prior to this change will not be valid anymore, since all MS2
spectra will be missing the polarity slot. Object can be
appropriately updated using the updateObject method.
The feature variables in the feature data slot will depend on the
file. See also the documentation in the mzR package that parses
the raw data files and produces these data.
Objects from the Class
Objects can be created by calls of the form
new("MSnExp",...). However, it is preferred to use the
readMSData function that will read raw mass
spectrometry data to generate a valid "MSnExp" instance.
Slots
assayData:Object of class
"environment"containing the MS spectra (see"Spectrum1"and"Spectrum2"). Slot is inherited from"pSet".phenoData:Object of class
"AnnotatedDataFrame"containing experimenter-supplied variables describing sample (i.e the individual tags for an labelled MS experiment) SeephenoDatafor more details. Slot is inherited from"pSet".featureData:Object of class
"AnnotatedDataFrame"containing variables describing features (spectra in our case), e.g. identificaiton data, peptide sequence, identification score,... (inherited from"eSet"). SeefeatureDatafor more details. Slot is inherited from"pSet".experimentData:Object of class
"MIAPE", containing details of experimental methods. SeeexperimentDatafor more details. Slot is inherited from"pSet".protocolData:Object of class
"AnnotatedDataFrame"containing equipment-generated variables (inherited from"eSet"). SeeprotocolDatafor more details. Slot is inherited from"pSet".processingData:Object of class
"MSnProcess"that records all processing. Slot is inherited from"pSet"..__classVersion__:Object of class
"Versions"describing the versions of R, the Biobase package,"pSet"andMSnExpof the current instance. Slot is inherited from"pSet". Intended for developer use and debugging (inherited from"eSet").
Extends
Class "pSet", directly.
Class "VersionedBiobase", by class "pSet", distance 2.
Class "Versioned", by class "pSet", distance 3.
Methods
See the "pSet" class for documentation on
accessors inherited from pSet, subsetting and general attribute
accession.
- bin
signature(object = "MSnExp"): Bins spectra. Seebindocumentation for more details and examples.- clean
signature(object = "MSnExp"): Removes unused 0 intensity data points. Seecleandocumentation for more details and examples.- compareSpectra
signature(x = "Spectrum", y = "missing"): Compares spectra. SeecompareSpectradocumentation for more details and examples.- extractPrecSpectra
signature(object = "MSnExp", prec = "numeric"): extracts spectra with precursor MZ value equal toprecand returns an object of class 'MSnExp'. SeeextractPrecSpectradocumentation for more details and examples.
% \item{extractSpectra}{\code{signature(object = "MSnExp", selected =
% "logical")}: extracts spectra corresponding to 'TRUE' in
% \code{selected}.
% See \code{\link{extractSpectra}} documentation for more details
% and examples. }
- pickPeaks
signature(object = "MSnExp"): Performs the peak picking to generate centroided spectra. ParametermsLevel.allows to restrict peak picking to spectra of certain MS level(s). SeepickPeaksdocumentation for more details and examples.- estimateNoise
signature(object = "MSnExp"): Estimates the noise in all profile spectra ofobject. SeeestimateNoisedocumentation for more details and examples.- plot
signature(x = "MSnExp", y = "missing"): Plots theMSnExpinstance. Seeplot.MSnExpdocumentation for more details.- plot2d
signature(object = "MSnExp", ...): Plots retention time against precursor MZ forMSnExpinstances. Seeplot2ddocumentation for more details.- plotDensity
signature(object = "MSnExp", ...): Plots the density of parameters of interest. instances. SeeplotDensitydocumentation for more details.- plotMzDelta
signature(object = "MSnExp", ...): Plots a histogram of the m/z difference betwee all of the highest peaks of all MS2 spectra of an experiment. SeeplotMzDeltadocumentation for more details.- quantify
signature(object = "MSnExp"): Performs quantification for all the MS2 spectra of theMSnExpinstance. Seequantifydocumentation for more details. Also forOnDiskMSnExpobjects.- removePeaks
signature(object = "MSnExp"): Removes peaks lower that a thresholdt. SeeremovePeaksdocumentation for more details and examples.- removeReporters
signature(object = "MSnExp", ...): Removes reporter ion peaks from all MS2 spectra of an experiment. SeeremoveReportersdocumentation for more details and examples.- smooth
signature(x = "MSnExp"): Smooths spectra. Seesmoothdocumentation for more details and examples.- addIdentificationData
signature(object = "MSnExp", ...): Adds identification data to an experiment. SeeaddIdentificationDatadocumentation for more details and examples.- removeNoId
signature(object = "MSnExp", fcol = "pepseq", keep = NULL): Removes non-identified features. SeeremoveNoIddocumentation for more details and examples.- removeMultipleAssignment
signature(object = "MSnExp", fcol = "nprot"): Removes protein groups (or feature belong to protein groups) with more than one member. The latter is defined by extracting a feature variable (default is"nprot"). Also removes non-identified features.- idSummary
signature(object = "MSnExp", ...): Prints a summary that lists the percentage of identified features per file (calledcoverage).- show
signature(object = "MSnExp"): Displays object content as text.- isolationWindow
signature(object = "MSnExp", ...): Returns the isolation window offsets for the MS2 spectra. SeeisolationWindowin themzRpackage for details.- trimMz
signature(object = "MSnExp"): Trims the MZ range of all the spectra of theMSnExpinstance. SeetrimMzdocumentation for more details and examples.isCentroided(object, k = 0.025, qtl = 0.9, verbose = TRUE)A heuristic assessing if the spectra in the
objectare in profile or centroided mode. The function takes theqtlth quantile top peaks, then calculates the difference between adjacent M/Z value and returnsTRUEif the first quartile is greater thank. (SeeMSnbase:::.isCentroidedfor the code.) Ifverbose(default), a table indicating mode for all MS levels is printed.The function has been tuned to work for MS1 and MS2 spectra and data centroided using different peak picking algorithms, but false positives can occur. See https://github.com/lgatto/MSnbase/issues/131 for details. For whole experiments, where all MS1 and MS2 spectra are expected to be in the same, albeit possibly different modes, it is advised to assign the majority result for MS1 and MS2 spectra, rather than results for individual spectra. See an example below.
- as
signature(object = "MSnExp", "data.frame"): Coerces theMSnExpobject to a four-columndata.framewith columns"file"(file index inobject),"rt"(retention time),"mz"(m/z values) and"i"(intensity values).- as
signature(object = "MSnExp", "MSpectra"): Coerces theMSnExpobject to aMSpectraobject with all feature annotations added as metadata columns (mcols).
Clarifications regarding scan/acquisition numbers and indices:
A spectrumId (or spectrumID) is a vendor specific
field in the mzML file that contains some information about the
run/spectrum, e.g.: controllerType=0 controllerNumber=1
scan=5281 file=2.
acquisitionNum is a more a less sanitize spectrum id
generated from the spectrumId field by mzR (see
https://github.com/sneumann/mzR/blob/master/src/pwiz/data/msdata/MSData.cpp#L552-L580).
scanIndex is the mzR generated sequence number of the
spectrum in the raw file (which doesn't have to be the same as the
acquisitionNum).
See also this issue: https://github.com/lgatto/MSnbase/issues/525.
Filtering and subsetting functions:
- filterRt
signature(object = "MSnExp", rt = "numeric", msLevel. = "numeric"): Retains MS spectra of levelmsLevel.with a retention times withinrt[1]andrt[2].- filterMsLevel
signature(object = "MSnExp", msLevel. = "numeric"): Retains MS spectra of levelmsLevel..- filterPolarity
signature(object = "MSnExp", polarity. = "numeric"): Retains MS spectra of polaritypolarity..- filterMz
signature(object = "MSnExp", mz = "numeric", msLevel. = "numeric"). SeefilterMzfor details.- filterFile
signature(object = "MSnExp", file): Retains MS data of files matching the file index or file name provided with parameterfile.- filterAcquisitionNum
- filterEmptySpectra
signature(object = "MSnExp"): Remove empty spectra fromobject(seeisEmpty).- filterPrecursorScan
signature(object = "MSnExp", acquisitionNum = "numeric"): Retain parent (e.g. MS1) and children scans (e.g. MS2) ofacquisitionNum. SeeOnDiskMSnExpfor an example.- splitByFile
signature(object = "MSnExp", f = "factor"): split aMSnExpobject by file into alistofMSnExpobjects given the grouping infactorf.- filterPrecursorMz
signature(object = "MSnExp", mz, ppm = 10): retain spectra with a precursor m/z equal or similar to the one defined with parametermz. Parameterppmallows to define an accepted difference between the provided m/z and the spectrum's m/z.- filterIsolationWindow
signature(object = "MSnExp", mz): retain spectra with isolation windows that contain (which m/z range contain) the specified m/z.
References
Information about the mzXML format as well converters from vendor specific formats to mzXML: http://tools.proteomecenter.org/wiki/index.php?title=Formats:mzXML.
See also
"pSet" and readMSData for loading
mzXML, mzData or mzML files to generate an
instance of MSnExp.
The "OnDiskMSnExp" manual page contains further
details and examples.
chromatogram to extract chromatographic data from a
MSnExp or OnDiskMSnExp object.
write for the function to write the data to mzML or
mzXML file(s).
Examples
mzxmlfile <- dir(system.file("extdata",package="MSnbase"),
pattern="mzXML",full.names=TRUE)
msnexp <- readMSData(mzxmlfile)
msnexp
#> MSn experiment data ("MSnExp")
#> Object size in memory: 0.18 Mb
#> - - - Spectra data - - -
#> MS level(s): 2
#> Number of spectra: 5
#> MSn retention times: 25:01 - 25:02 minutes
#> - - - Processing information - - -
#> Data loaded: Tue Aug 26 11:37:36 2025
#> MSnbase version: 2.35.2
#> - - - Meta data - - -
#> phenoData
#> rowNames: dummyiTRAQ.mzXML
#> varLabels: sampleNames
#> varMetadata: labelDescription
#> Loaded from:
#> dummyiTRAQ.mzXML
#> protocolData: none
#> featureData
#> featureNames: F1.S1 F1.S2 ... F1.S5 (5 total)
#> fvarLabels: spectrum
#> fvarMetadata: labelDescription
#> experimentData: use 'experimentData(object)'