Description Usage Arguments Value Implementation notes Author(s) Examples
View source: R/peaks-functions.R
These functions map peaks from two spectra with each other if the difference
between their m/z values is smaller than defined with parameters tolerance
and ppm
. All functions take two matrices
joinPeaks
: maps peaks from two spectra allowing to specify the type of
join that should be performed: type = "outer"
each peak in x
will be
matched with each peak in y
, for peaks that do not match any peak in the
other spectra an NA
intensity is returned. With type = "left"
all peaks
from the left spectrum (x
) will be matched with peaks in y
. Peaks in
y
that do not match any peak in x
are omitted. type = "right"
is the
same as type = "left"
only for y
. Only peaks that can be matched
between x
and y
are returned by type = "inner"
, i.e. only
peaks present in both spectra are reported.
1 |
x |
|
y |
|
type |
For |
tolerance |
|
ppm |
|
... |
option parameters. |
All functions return a list
of elements "x"
and "y"
each being a two
column matrix with m/z (first column) and intensity values (second column).
The two matrices contain the matched peaks between input matrices x
and y
and hence have the same number of rows. Peaks present in x
but not in the
y
input matrix have m/z and intensity values of NA
in the result matrix
for y
(and vice versa).
A mapping function must take two numeric matrices x
and y
as input and
must return list
with two elements named "x"
and "y"
that represent
the aligned input matrices. The function should also have ...
in its
definition. Parameters ppm
and tolerance
are suggested but not required.
Johannes Rainer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | x <- cbind(c(31.34, 50.14, 60.3, 120.9, 230, 514.13, 874.1),
1:7)
y <- cbind(c(12, 31.35, 70.3, 120.9 + ppm(120.9, 5),
230 + ppm(230, 10), 315, 514.14, 901, 1202),
1:9)
## No peaks with identical m/z
joinPeaks(x, y, ppm = 0, type = "inner")
## With ppm 10 two peaks are overlapping
joinPeaks(x, y, ppm = 10, type = "inner")
## Outer join: contain all peaks from x and y
joinPeaks(x, y, ppm = 10, type = "outer")
## Left join: keep all peaks from x and those from y that match
joinPeaks(x, y, ppm = 10, type = "left")
## Right join: keep all peaks from y and those from x that match. Using
## a constant tolerance of 0.01
joinPeaks(x, y, tolerance = 0.01, type = "right")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.