Last data update: 2014.03.03

R: Plotting a 'Spectrum' vs another 'Spectrum' object.
plot.Spectrum.Spectrum-methodsR Documentation

Plotting a 'Spectrum' vs another 'Spectrum' object.

Description

These method plot mass spectra MZ values against the intensities as line plots. The first spectrum is plotted in the upper panel and the other in upside down in the lower panel. Common peaks are drawn in a slightly darker colour. If a peptide sequence is provided it automatically calculates and labels the fragments.

Arguments

x

Object of class "Spectrum" .

y

Object of class "Spectrum" .

...

Further arguments passed to internal functions.

Methods

signature(x = "Spectrum", y = "Spectrum", ...)

Plots two spectra against each other. Common peaks are drawn in a slightly darker colour. The ... arguments are passed to the internal functions. Currently tolerance, relative, sequences and most of the plot.default arguments (like xlim, ylim, main, xlab, ylab, ...) are supported. You could change the tolerance (default 25e-6) and decide whether this tolerance should be applied relative (default relative = TRUE) or absolute (relative = FALSE) to find and colour common peaks. Use a character vector of length 2 to provide sequences which would be used to calculate and draw the corresponding fragments. If sequences are given the type argument (default: type=c("b", "y") specify the fragment types which should calculated. Also it is possible to allow some modifications. Therefore you have to apply a named character vector for modifications where the name corresponds to the one-letter-code of the modified amino acid (default: Carbamidomethyl modifications=c(C=160.030649)). See calculateFragments for details.

Author(s)

Sebastian Gibb <mail@sebastiangibb.de>

See Also

More spectrum plotting available in plot.Spectrum.

Examples

## find path to a mzXML file
file <- dir(system.file(package = "MSnbase", dir = "extdata"),
            full.name = TRUE, pattern = "mzXML$")

## create basic MSnExp
msexp <- readMSData(file)

## centroid them
msexp <- pickPeaks(msexp)

## plot the first against the second spectrum
plot(msexp[[1]], msexp[[2]])

## add sequence information
plot(msexp[[1]], msexp[[2]], sequences=c("VESITARHGEVLQLRPK",
                                         "IDGQWVTHQWLKK"))


itraqdata2 <- pickPeaks(itraqdata)
(k <- which(fData(itraqdata2)[, "PeptideSequence"] == "TAGIQIVADDLTVTNPK"))
mzk <- precursorMz(itraqdata2)[k]
zk <- precursorCharge(itraqdata2)[k]
mzk * zk
plot(itraqdata2[[k[1]]], itraqdata2[[k[2]]])

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/plotSpectrumSpectrum-methods.Rd_%03d_medium.png", width=480, height=480)
> ### Name: plot.Spectrum.Spectrum-methods
> ### Title: Plotting a 'Spectrum' vs another 'Spectrum' object.
> ### Aliases: plot.Spectrum.Spectrum plot,Spectrum,Spectrum-method
> ### Keywords: methods
> 
> ### ** Examples
> 
> ## find path to a mzXML file
> file <- dir(system.file(package = "MSnbase", dir = "extdata"),
+             full.name = TRUE, pattern = "mzXML$")
> 
> ## create basic MSnExp
> msexp <- readMSData(file)
Reading 5 MS2 spectra from file dummyiTRAQ.mzXML
   |                                                                               |                                                                      |   0%   |                                                                               |==============                                                        |  20%   |                                                                               |============================                                          |  40%   |                                                                               |==========================================                            |  60%   |                                                                               |========================================================              |  80%   |                                                                               |======================================================================| 100%
Caching...
Creating 'MSnExp' object
> 
> ## centroid them
> msexp <- pickPeaks(msexp)
   |                                                                               |                                                                      |   0%   |                                                                               |==============                                                        |  20%   |                                                                               |============================                                          |  40%   |                                                                               |==========================================                            |  60%   |                                                                               |========================================================              |  80%   |                                                                               |======================================================================| 100%
> 
> ## plot the first against the second spectrum
> plot(msexp[[1]], msexp[[2]])
> 
> ## add sequence information
> plot(msexp[[1]], msexp[[2]], sequences=c("VESITARHGEVLQLRPK",
+                                          "IDGQWVTHQWLKK"))
> 
> 
> 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%
> (k <- which(fData(itraqdata2)[, "PeptideSequence"] == "TAGIQIVADDLTVTNPK"))
[1] 41 42
> mzk <- precursorMz(itraqdata2)[k]
> zk <- precursorCharge(itraqdata2)[k]
> mzk * zk
     X46      X47 
2046.175 2045.169 
> plot(itraqdata2[[k[1]]], itraqdata2[[k[2]]])
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>