Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

clean-methods

Clean 'MSnExp', 'Spectrum' or 'Chromatogram' instances


Description

This method cleans out individual spectra (Spectrum instances), chromatograms (Chromatogram instances) or whole experiments (MSnExp instances) of 0-intensity peaks. Unless all is set to FALSE, original 0-intensity values are retained only around peaks. If more than two 0's were separating two peaks, only the first and last ones, those directly adjacent to the peak ranges are kept. If two peaks are separated by only one 0-intensity value, it is retained. An illustrative example is shown below.

Methods

signature(object = "MSnExp", all = "logical", verbose = "logical")

Cleans all spectra in MSnExp object. Displays a control bar if verbose set to TRUE (default). Returns a cleaned MSnExp instance.

signature(object = "Spectrum", all = "logical", msLevel. = "numeric")

Cleans the Spectrum object. Returns a cleaned Spectrum instance. If all = TRUE, then all zeros are removed. msLevel. defines the level of the spectrum, and if msLevel(object) != msLevel., cleaning is ignored. Only relevant when called from OnDiskMSnExp and is only relevant for developers.

signature(object = "Chromatogram", all = "logical", na.rm = "logical")

Cleans the Chromatogram instance and returns a cleaned Chromatogram object. If na.rm is TRUE (default is FALSE) all NA intensities are removed before cleaning the chromatogram.

Author(s)

Laurent Gatto <lg390@cam.ac.uk>

See Also

removePeaks and trimMz for other spectra processing methods.

Examples

int <- c(1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0)
sp1 <- new("Spectrum2",
           intensity=int,
           mz=1:length(int))
sp2 <- clean(sp1) ## default is all=FALSE
intensity(sp1)
intensity(sp2)
intensity(clean(sp1, all = TRUE))

mz(sp1)
mz(sp2)
mz(clean(sp1, all = TRUE))

data(itraqdata)
itraqdata2 <- clean(itraqdata)
sum(peaksCount(itraqdata))
sum(peaksCount(itraqdata2))
processingData(itraqdata2)

## Create a simple Chromatogram object
chr <- Chromatogram(rtime = 1:12,
                    intensity = c(0, 0, 20, 0, 0, 0, 123, 124343, 3432, 0, 0, 0))

## Remove 0-intensity values keeping those adjacent to peaks
chr <- clean(chr)
intensity(chr)

## Remove all 0-intensity values
chr <- clean(chr, all = TRUE)
intensity(chr)

## Clean a Chromatogram with NAs.
chr <- Chromatogram(rtime = 1:12,
                    intensity = c(0, 0, 20, NA, NA, 0, 123, 124343, 3432, 0, 0, 0))
chr <- clean(chr, all = FALSE, na.rm = TRUE)
intensity(chr)

MSnbase

Base Functions and Classes for Mass Spectrometry and Proteomics

v2.16.1
Artistic-2.0
Authors
Laurent Gatto, Johannes Rainer and Sebastian Gibb with contributions from Guangchuang Yu, Samuel Wieczorek, Vasile-Cosmin Lazar, Vladislav Petyuk, Thomas Naake, Richie Cotton, Arne Smits, Martina Fisher, Ludger Goeminne, Adriaan Sticker and Lieven Clement.
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.