MSnExp-class: The 'MSnExp' Class for MS Data And Meta-Data

Description Objects from the Class Slots Extends Methods Author(s) References See Also Examples


The 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.



Object of class "environment" containing the MS spectra (see "Spectrum1" and "Spectrum2"). Slot is inherited from "pSet".


Object of class "AnnotatedDataFrame" containing experimenter-supplied variables describing sample (i.e the individual tags for an labelled MS experiment) See phenoData for more details. Slot is inherited from "pSet".


Object of class "AnnotatedDataFrame" containing variables describing features (spectra in our case), e.g. identificaiton data, peptide sequence, identification score,... (inherited from "eSet"). See featureData for more details. Slot is inherited from "pSet".


Object of class "MIAPE", containing details of experimental methods. See experimentData for more details. Slot is inherited from "pSet".


Object of class "AnnotatedDataFrame" containing equipment-generated variables (inherited from "eSet"). See protocolData for more details. Slot is inherited from "pSet".


Object of class "MSnProcess" that records all processing. Slot is inherited from "pSet".


Object of class "Versions" describing the versions of R, the Biobase package, "pSet" and MSnExp of the current instance. Slot is inherited from "pSet". Intended for developer use and debugging (inherited from "eSet").


Class "pSet", directly. Class "VersionedBiobase", by class "pSet", distance 2. Class "Versioned", by class "pSet", distance 3.


See the "pSet" class for documentation on accessors inherited from pSet, subsetting and general attribute accession.


signature(object = "MSnExp"): Bins spectra. See bin documentation for more details and examples.


signature(object = "MSnExp"): Removes unused 0 intensity data points. See clean documentation for more details and examples.


signature(object1 = "Spectrum", object2 = "missing"): Compares spectra. See compareSpectra documentation for more details and examples.


signature(object = "MSnExp", prec = "numeric"): extracts spectra with precursor MZ value equal to prec and returns an object of class 'MSnExp'. See extractPrecSpectra documentation for more details and examples.


signature(object = "MSnExp"): Performs the peak picking to generate centroided spectra. Parameter msLevel. allows to restrict peak picking to spectra of certain MS level(s). See pickPeaks documentation for more details and examples.


signature(object = "MSnExp"): Estimates the noise in all profile spectra of object. See estimateNoise documentation for more details and examples.


signature(x = "MSnExp", y = "missing"): Plots the MSnExp instance. See plot.MSnExp documentation for more details.


signature(object = "MSnExp", ...): Plots retention time against precursor MZ for MSnExp instances. See plot2d documentation for more details.


signature(object = "MSnExp", ...): Plots the density of parameters of interest. instances. See plotDensity documentation for more details.


signature(object = "MSnExp", ...): Plots a histogram of the m/z difference betwee all of the highest peaks of all MS2 spectra of an experiment. See plotMzDelta documentation for more details.


signature(object = "MSnExp"): Performs quantification for all the MS2 spectra of the MSnExp instance. See quantify documentation for more details. Also for OnDiskMSnExp objects.


signature(object = "MSnExp"): Removes peaks lower that a threshold t. See removePeaks documentation for more details and examples.


signature(object = "MSnExp", ...): Removes reporter ion peaks from all MS2 spectra of an experiment. See removeReporters documentation for more details and examples.


signature(x = "MSnExp"): Smooths spectra. See smooth documentation for more details and examples.


signature(object = "MSnExp", ...): Adds identification data to an experiment. See addIdentificationData documentation for more details and examples.


signature(object = "MSnExp", fcol = "pepseq", keep = NULL): Removes non-identified features. See removeNoId documentation for more details and examples.


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.


signature(object = "MSnExp", ...): Prints a summary that lists the percentage of identified features per file (called coverage).


signature(object = "MSnExp"): Displays object content as text.


signature(object = "MSnExp", ...): Returns the isolation window offsets for the MS2 spectra. See isolationWindow in the mzR package for details.


signature(object = "MSnExp"): Trims the MZ range of all the spectra of the MSnExp instance. See trimMz documentation for more details and examples.

isCentroided(object, k = 0.025, qtl = 0.9, verbose = TRUE)

A heuristic assessing if the spectra in the object are in profile or centroided mode. The function takes the qtlth quantile top peaks, then calculates the difference between adjacent M/Z value and returns TRUE if the first quartile is greater than k. (See MSnbase:::.isCentroided for the code.) If verbose (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 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.


signature(object = "MSnExp", "data.frame"): Coerces the MSnExp object to a four-column data.frame with columns "file" (file index in object), "rt" (retention time), "mz" (m/z values) and "i" (intensity values).


signature(object = "MSnExp", "MSpectra"): Coerces the MSnExp object to a MSpectra object with all feature annotations added as metadata columns (mcols).

Filtering and subsetting functions:


signature(object = "MSnExp", rt = "numeric", msLevel. = "numeric"): Retains MS spectra of level msLevel. with a retention times within rt[1] and rt[2].


signature(object = "MSnExp", msLevel. = "numeric"): Retains MS spectra of level msLevel..


signature(object = "MSnExp", polarity. = "numeric"): Retains MS spectra of polarity polarity..


signature(object = "MSnExp", mz = "numeric", msLevel. = "numeric"). See filterMz for details.


signature(object = "MSnExp", file): Retains MS data of files matching the file index or file name provided with parameter file.


signature(object = "MSnExp"): Remove empty spectra from object (see isEmpty).


signature(object = "MSnExp", acquisitionNum = "numeric"): Retain parent (e.g. MS1) and children scans (e.g. MS2) of acquisitionNum. See OnDiskMSnExp for an example.


signature(object = "MSnExp", f = "factor"): split a MSnExp object by file into a list of MSnExp objects given the grouping in factor f.


signature(object = "MSnExp", mz, ppm = 10): retain spectra with a precursor m/z equal or similar to the one defined with parameter mz. Parameter ppm allows to define an accepted difference between the provided m/z and the spectrum's m/z.


signature(object = "MSnExp", mz): retain spectra with isolation windows that contain (which m/z range contain) the specified m/z.


Laurent Gatto <>


Information about the mzXML format as well converters from vendor specific formats to 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).


mzxmlfile <- dir(system.file("extdata",package="MSnbase"),
msnexp <- readMSData(mzxmlfile)

Example output

Loading required package: BiocGenerics
Loading required package: parallel

Attaching package:BiocGenericsThe following objects are masked frompackage:parallel:

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked frompackage:stats:

    IQR, mad, sd, var, xtabs

The following objects are masked frompackage:base:

    anyDuplicated, append,, basename, cbind, colnames,
    dirname,, duplicated, eval, evalq, Filter, Find, get, grep,
    grepl, intersect, is.unsorted, lapply, Map, mapply, match, mget,
    order, paste, pmax,, pmin,, Position, rank,
    rbind, Reduce, rownames, sapply, setdiff, sort, table, tapply,
    union, unique, unsplit, which.max, which.min

Loading required package: Biobase
Welcome to Bioconductor

    Vignettes contain introductory material; view with
    'browseVignettes()'. To cite Bioconductor, see
    'citation("Biobase")', and for packages 'citation("pkgname")'.

Loading required package: mzR
Loading required package: Rcpp
Loading required package: S4Vectors
Loading required package: stats4

Attaching package:S4VectorsThe following object is masked frompackage:base:


Loading required package: ProtGenerics

Attaching package:ProtGenericsThe following object is masked frompackage:stats:


This is MSnbase version 2.16.0 
  Visit to get started.

Attaching package:MSnbaseThe following object is masked frompackage:base:


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:1 - 25:2 minutes
- - - Processing information - - -
Data loaded: Fri Apr  9 17:48:19 2021 
 MSnbase version: 2.16.0 
- - - Meta data  - - -
  rowNames: dummyiTRAQ.mzXML
  varLabels: sampleNames
  varMetadata: labelDescription
Loaded from:
protocolData: none
  featureNames: F1.S1 F1.S2 ... F1.S5 (5 total)
  fvarLabels: spectrum
  fvarMetadata: labelDescription
experimentData: use 'experimentData(object)'

MSnbase documentation built on Jan. 23, 2021, 2 a.m.