Learn R Programming

ChemoSpec (version 4.1.15)

sortCrossPeaks: Sort Rows of a Covariance Matrix of a Spectra Object

Description

Given a covariance matrix, the maximum absolute value of each row is computed after excluding values near the diagonal. By default, the results are ordered by the absolute value of the covariance, or optionally by frequency. The results may be limited to a selected quantile of top results.

Usage

sortCrossPeaks(spectra, V = NULL, window = NULL, Quan = NULL,
byFreq = FALSE, freqThres = 0.01, ...)

Arguments

spectra
An object of S3 class Spectra.
V
A numeric covariance matrix, corresponding to cov(spectra$data)..
window
Numeric. A value in the interval (0...1). This is converted to a number of data points near the diagonal which will be removed. If NULL, the default, approximately 10 percent of the points are removed.
Quan
Numeric. A value in the interval (0...1) giving the quantile to be selected. For instance, Quan = 0.1 selects the top 10 percent of the returned values.
byFreq
Logical. Shall the results be sorted by frequency? Only applies if Quan != NULL. Frequencies closer than freqThres will be collapsed and replaced with their average.
freqThres
Numeric. Only relevant if Quan != NULL and byFreq = TRUE. Frequencies closer than freqThres will be collapsed and replaced with their average.
...
Arguments to be passed down stream. In particular, you may wish to set verbose = TRUE which will pass through to collapseRowsOrCols and give information about which rows and columns which are collapsed if Quan != NULL

Value

  • A data frame containing the frequencies from the Spectra object, the maximum covariance at that frequency, the absolute value of the maximum covariance, and the relative absolute maximum covariance.

Details

The diagonal of a covariance matrix holds the variances, which are by definition the largest value in the row. Because of the shape of an NMR peak, values near the diagonal essentially represent the variance as well. We are interested in the values of the cross peaks, hence it is necessary to remove a number of data points near the diagonal from the computations. The exact number to remove is subject to experimentation.

If the data were sorted by frequency without selecting the top values (i.e. Quan = NULL), there would be no point in collapsing the values as they are all equally spaced. But when you have selected the top covariance values, the frequencies are no longer consecutive and equally spaced, so collapsing them replaces trivially close values with their averages.

References

https://github.com/bryanhanson/ChemoSpec

Examples

Run this code
data(metMUD1)
V <- cov(metMUD1$data)
# Look at the top 1%
res <- sortCrossPeaks(metMUD1, V, Quan = 0.01)
res

Run the code above in your browser using DataLab