Last data update: 2014.03.03

R: Removes low intensity peaks
removePeaks-methodsR Documentation

Removes low intensity peaks

Description

This method sets low intensity peaks from individual spectra (Spectrum instances) or whole experiments (MSnExp instances) to 0. The intensity threshold is set with the t parameter. Default is the "min" character. The threshold is then set as the non-0 minimum intensity found in the spectrum. Any other numeric values is valid. All peaks with maximum intensity smaller or equal to t are set to 0.

If the spectrum is in profile mode, ranges of successive non-0 peaks <= t are set to 0. If the spectrum is centroided, then individual peaks <= t are set to 0. See the example below for an illustration.

Note that the number of peaks is not changed; the peaks below the threshold are set to 0 and the object is not cleanded out (see clean). An illustrative example is shown below.

Methods

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

Removes low intensity peaks of all spectra in MSnExp object. t sets the minimum peak intensity. Default is "min", i.e the smallest intensity in each spectrum. Other numeric values are valid. Displays a control bar if verbose set to TRUE (default). Returns a new MSnExp instance.

signature(object = "Spectrum", t)

Removes low intensity peaks of Spectrum object. t sets the minimum peak intensity. Default is "min", i.e the smallest intensity in each spectrum. Other numeric values are valid. Returns a new Spectrum instance.

Author(s)

Laurent Gatto <lg390@cam.ac.uk>

See Also

clean and trimMz for other spectra processing methods.

Examples

int <- c(2,0,0,0,1,5,1,0,0,1,3,1,0,0,1,4,2,1)
sp1 <- new("Spectrum2",
           intensity=int,
           mz=1:length(int))
sp2 <- removePeaks(sp1) ## no peaks are removed here
                        ## as min intensity is 1 and
                        ## no peak has a max int <= 1
sp3 <- removePeaks(sp1,3)
intensity(sp1)
intensity(sp2)
intensity(sp3)

peaksCount(sp1) == peaksCount(sp2)
peaksCount(sp3) <= peaksCount(sp1)

data(itraqdata)
itraqdata2 <- removePeaks(itraqdata, t = 2.5e5)
table(unlist(intensity(itraqdata)) == 0)
table(unlist(intensity(itraqdata2)) == 0)
processingData(itraqdata2)

## difference between centroided and profile peaks

int <- c(104, 57, 32, 33, 118, 76, 38, 39, 52, 140, 52, 88, 394, 71,
         408, 94, 2032)
sp <- new("Spectrum2",
          intensity = int,
          centroided = FALSE,
          mz = seq_len(length(int)))

## unchanged, as ranges of peaks <= 500 considered
intensity(removePeaks(sp, 500))


centroided(sp) <- TRUE
## different!
intensity(removePeaks(sp, 500))

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(MSnbase)
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

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

The following objects are masked from 'package:stats':

    IQR, mad, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
    get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
    match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
    rbind, rownames, sapply, setdiff, sort, table, tapply, union,
    unique, unsplit

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: BiocParallel
Loading required package: ProtGenerics

This is MSnbase version 1.20.7 
  Read '?MSnbase' and references therein for information
  about the package and how to get started.


Attaching package: 'MSnbase'

The following object is masked from 'package:stats':

    smooth

The following object is masked from 'package:base':

    trimws

> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/MSnbase/removePeaks-methods.Rd_%03d_medium.png", width=480, height=480)
> ### Name: removePeaks-methods
> ### Title: Removes low intensity peaks
> ### Aliases: removePeaks-methods removePeaks
> ### Keywords: methods
> 
> ### ** Examples
> 
> int <- c(2,0,0,0,1,5,1,0,0,1,3,1,0,0,1,4,2,1)
> sp1 <- new("Spectrum2",
+            intensity=int,
+            mz=1:length(int))
> sp2 <- removePeaks(sp1) ## no peaks are removed here
>                         ## as min intensity is 1 and
>                         ## no peak has a max int <= 1
> sp3 <- removePeaks(sp1,3)
> intensity(sp1)
 [1] 2 0 0 0 1 5 1 0 0 1 3 1 0 0 1 4 2 1
> intensity(sp2)
 [1] 2 0 0 0 1 5 1 0 0 1 3 1 0 0 1 4 2 1
> intensity(sp3)
 [1] 0 0 0 0 1 5 1 0 0 0 0 0 0 0 1 4 2 1
> 
> peaksCount(sp1) == peaksCount(sp2)
[1] TRUE
> peaksCount(sp3) <= peaksCount(sp1)
[1] TRUE
> 
> data(itraqdata)
> itraqdata2 <- removePeaks(itraqdata, t = 2.5e5)
   |                                                                               |                                                                      |   0%   |                                                                               |=                                                                     |   2%   |                                                                               |===                                                                   |   4%   |                                                                               |====                                                                  |   5%   |                                                                               |=====                                                                 |   7%   |                                                                               |======                                                                |   9%   |                                                                               |========                                                              |  11%   |                                                                               |=========                                                             |  13%   |                                                                               |==========                                                            |  15%   |                                                                               |===========                                                           |  16%   |                                                                               |=============                                                         |  18%   |                                                                               |==============                                                        |  20%   |                                                                               |===============                                                       |  22%   |                                                                               |=================                                                     |  24%   |                                                                               |==================                                                    |  25%   |                                                                               |===================                                                   |  27%   |                                                                               |====================                                                  |  29%   |                                                                               |======================                                                |  31%   |                                                                               |=======================                                               |  33%   |                                                                               |========================                                              |  35%   |                                                                               |=========================                                             |  36%   |                                                                               |===========================                                           |  38%   |                                                                               |============================                                          |  40%   |                                                                               |=============================                                         |  42%   |                                                                               |===============================                                       |  44%   |                                                                               |================================                                      |  45%   |                                                                               |=================================                                     |  47%   |                                                                               |==================================                                    |  49%   |                                                                               |====================================                                  |  51%   |                                                                               |=====================================                                 |  53%   |                                                                               |======================================                                |  55%   |                                                                               |=======================================                               |  56%   |                                                                               |=========================================                             |  58%   |                                                                               |==========================================                            |  60%   |                                                                               |===========================================                           |  62%   |                                                                               |=============================================                         |  64%   |                                                                               |==============================================                        |  65%   |                                                                               |===============================================                       |  67%   |                                                                               |================================================                      |  69%   |                                                                               |==================================================                    |  71%   |                                                                               |===================================================                   |  73%   |                                                                               |====================================================                  |  75%   |                                                                               |=====================================================                 |  76%   |                                                                               |=======================================================               |  78%   |                                                                               |========================================================              |  80%   |                                                                               |=========================================================             |  82%   |                                                                               |===========================================================           |  84%   |                                                                               |============================================================          |  85%   |                                                                               |=============================================================         |  87%   |                                                                               |==============================================================        |  89%   |                                                                               |================================================================      |  91%   |                                                                               |=================================================================     |  93%   |                                                                               |==================================================================    |  95%   |                                                                               |===================================================================   |  96%   |                                                                               |===================================================================== |  98%   |                                                                               |======================================================================| 100%
> table(unlist(intensity(itraqdata)) == 0)

FALSE  TRUE 
45628 60661 
> table(unlist(intensity(itraqdata2)) == 0)

FALSE  TRUE 
10280 96009 
> processingData(itraqdata2)
- - - Processing information - - -
Data loaded: Wed May 11 18:54:39 2011 
Curves <= 250000 set to '0': Wed Jul  6 01:10:31 2016 
 MSnbase version: 1.1.22 
> 
> ## difference between centroided and profile peaks
> 
> int <- c(104, 57, 32, 33, 118, 76, 38, 39, 52, 140, 52, 88, 394, 71,
+          408, 94, 2032)
> sp <- new("Spectrum2",
+           intensity = int,
+           centroided = FALSE,
+           mz = seq_len(length(int)))
> 
> ## unchanged, as ranges of peaks <= 500 considered
> intensity(removePeaks(sp, 500))
 [1]  104   57   32   33  118   76   38   39   52  140   52   88  394   71  408
[16]   94 2032
> 
> 
> centroided(sp) <- TRUE
> ## different!
> intensity(removePeaks(sp, 500))
 [1]    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
[16]    0 2032
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>