correlate-Chromatogram: Correlate chromatograms

Description Usage Arguments Value Author(s) Examples

Description

Correlate intensities of two chromatograms with each other. If the two Chromatogram objects have different retention times they are first aligned to match data points in the first to data points in the second chromatogram. See align() for more details.

If correlate is called on a single MChromatograms() object a pairwise correlation of each chromatogram with each other is performed and a matrix with the correlation coefficients is returned.

Note that the correlation of two chromatograms depends also on their order, e.g. correlate(chr1, chr2) might not be identical to correlate(chr2, chr1). The lower and upper triangular part of the correlation matrix might thus be different.

For correlating elements of a MChromatograms with each other it might be sufficient to calculate just the upper triangular matrix. This can be done by setting full = FALSE.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## S4 method for signature 'Chromatogram,Chromatogram'
correlate(
  x,
  y,
  use = "pairwise.complete.obs",
  method = c("pearson", "kendall", "spearman"),
  align = c("matchRtime", "approx"),
  ...
)

## S4 method for signature 'MChromatograms,missing'
correlate(
  x,
  y = NULL,
  use = "pairwise.complete.obs",
  method = c("pearson", "kendall", "spearman"),
  align = c("matchRtime", "approx"),
  full = TRUE,
  ...
)

## S4 method for signature 'MChromatograms,MChromatograms'
correlate(
  x,
  y = NULL,
  use = "pairwise.complete.obs",
  method = c("pearson", "kendall", "spearman"),
  align = c("matchRtime", "approx"),
  ...
)

Arguments

x

Chromatogram() or MChromatograms() object.

y

Chromatogram() or MChromatograms() object.

use

character(1) passed to the cor function. See cor() for details.

method

character(1) passed to the cor function. See cor() for details.

align

character(1) defining the alignment method to be used. See align() for details. The value of this parameter is passed to the method parameter of align.

...

optional parameters passed along to the align method.

full

logical(1) for correlate on a single MChromatograms object: whether the full correlation matrix should be calculated (default) or just the upper triangular matrix (and diagonal).

Value

numeric(1) or matrix (if called on MChromatograms objects) with the correlation coefficient. If a matrix is returned, the rows represent the chromatograms in x and the columns the chromatograms in y.

Author(s)

Michael Witting, Johannes Rainer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
chr1 <- Chromatogram(rtime = 1:10 + rnorm(n = 10, sd = 0.3),
    intensity = c(5, 29, 50, NA, 100, 12, 3, 4, 1, 3))
chr2 <- Chromatogram(rtime = 1:10 + rnorm(n = 10, sd = 0.3),
    intensity = c(80, 50, 20, 10, 9, 4, 3, 4, 1, 3))
chr3 <- Chromatogram(rtime = 3:9 + rnorm(7, sd = 0.3),
    intensity = c(53, 80, 130, 15, 5, 3, 2))

chrs <- MChromatograms(list(chr1, chr2, chr3))

correlate(chr1, chr2)
correlate(chr2, chr1)

correlate(chrs, chrs)

xcms documentation built on Nov. 8, 2020, 5:13 p.m.