Last data update: 2014.03.03

R: Plotting 'Spectrum' object(s)
plot-methodsR Documentation

Plotting 'Spectrum' object(s)

Description

These method plot mass spectra MZ values against the intensities. Full spectra (using the full parameter) or specific peaks of interest can be plotted using the reporters parameter. If reporters are specified and full is set to 'TRUE', a sub-figure of the reporter ions is inlaid inside the full spectrum.

If an "MSnExp" is provided as argument, all the spectra are aligned vertically. Experiments can be subset to extract spectra of interest using the [ operator or extractPrecSpectra methods.

The methods make use the ggplot2 system. An object of class 'ggplot' is returned invisibly.

If a single "Spectrum2" and a "character" representing a valid peptide sequence are passed as argument, the expected fragement ions are calculated and matched/annotated on the spectum plot.

Arguments

x

Objects of class "Spectrum", "Spectrum2" or "MSnExp" to be plotted.

y

Missing, "Spectrum" or "character".

reporters

An object of class "ReporterIons" that defines the peaks to be plotted. If not specified, full must be set to 'TRUE'.

full

Logical indicating whether full spectrum (respectively spectra) of only reporter ions of interest should be plotted. Default is 'FALSE', in which case reporters must be defined.

centroided.

Logical indicating if spectrum or spectra are in centroided mode, in which case peaks are plotted as histograms, rather than curves.

plot

Logical specifying whether plot should be printed to current device. Default is 'TRUE'.

w1

Width of sticks for full centroided spectra. Default is to use maximum MZ value divided by 500.

w2

Width of histogram bars for centroided reporter ions plots. Default is 0.01.

See below for more details.

Methods

signature(x = "MSnExp", y = "missing", reporters = "ReporterIons", full = "logical", plot = "logical")

Plots all the spectra in the MSnExp object vertically. One of reporters must be defined or full set to 'TRUE'. In case of MSnExp objects, repoter ions are not inlaid when full is 'TRUE'.

signature(x = "Spectrum", y = "missing", reporters = "ReporterIons", full = "logical", centroided. = "logical", plot = "logical", w1, w2)

Displays the MZs against intensities of the Spectrum object as a line plot. At least one of reporters being defined or full set to 'TRUE' is required. reporters and full are used only for "Spectrum2" objects. Full "Spectrum1" spectra are plotted by default.

signature(x = "Spectrum2", y = "character", orientation = "numeric", add = "logical", col = "character", pch, xlab = "character", ylab = "character", xlim = "numeric", ylim = "numeric", tolerance = "numeric", relative = "logical", type = "character", modifications = "numeric", x = "numeric", fragments = "data.frame", fragments.cex = "numeric", ... )

Plots a single MS2 spectrum and annotates the fragment ions based on the matching between the peaks in x and the fragment peaks calculated from the peptide sequence y. The default values are orientation=1, add=FALSE, col="#74ADD1", pch=NA, xlab="m/z", ylab="intensity", ylim=c(0, 1), tolerance=0.1, relative=FALSE, type=c("b", "y"), modifications=c(C=160.030649), z=1, fragments=MSnbase:::calculateFragments_Spectrum2 and fragments.cex=0.75. Additional arguments ... are passed to plot.default.

Author(s)

Laurent Gatto <lg390@cam.ac.uk> and Sebastian Gibb

See Also

calculateFragments to calculate ions produced by fragmentation and plot.Spectrum.Spectrum to plot and compare 2 spectra and their shared peaks.

Examples

data(itraqdata)
## plotting experiments
plot(itraqdata[1:2], reporters = iTRAQ4)
plot(itraqdata[1:2], full = TRUE)
## plotting spectra
plot(itraqdata[[1]],reporters = iTRAQ4, full = TRUE)

itraqdata2 <- pickPeaks(itraqdata)
i <- 14
s <- as.character(fData(itraqdata2)[i, "PeptideSequence"])
plot(itraqdata2[[i]], s, main = s)

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/plot-methods.Rd_%03d_medium.png", width=480, height=480)
> ### Name: plot-methods
> ### Title: Plotting 'Spectrum' object(s)
> ### Aliases: plot,Spectrum-method plot,Spectrum,missing-method
> ###   plot,Spectrum2,character-method plot-methods plot.MSnExp
> ###   plot.Spectrum plot.Spectrum.character plot
> ### Keywords: methods
> 
> ### ** Examples
> 
> data(itraqdata)
> ## plotting experiments
> plot(itraqdata[1:2], reporters = iTRAQ4)
> plot(itraqdata[1:2], full = TRUE)
> ## plotting spectra
> plot(itraqdata[[1]],reporters = iTRAQ4, full = TRUE)
> 
> itraqdata2 <- pickPeaks(itraqdata)
   |                                                                               |                                                                      |   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%
> i <- 14
> s <- as.character(fData(itraqdata2)[i, "PeptideSequence"])
> plot(itraqdata2[[i]], s, main = s)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>