BuildRawDataMatrix: Build a raw data matrix (spectra) from spectra of unequal...

Description Usage Arguments Value Author(s) Examples

View source: R/BuildRawDataMatrix.R

Description

This function can be used to build a data matrix from ill aligned spectra or of spectra of unequal length. the result is a matrix whereby the first column matches (approximately) with a sinle left ppm value and the last column matches (approxiamtely) with a single right ppm value. Crucial is that the sample rates of the machine are the same this should be always the case otherwise comparing intensities becomes meaningless. Note that, as standard in NMR spectra, the highest ppm value is on the left

Usage

1
BuildRawDataMatrix(spectrum.list, ppm.list = NULL, ppm.edges.matrix = NULL)

Arguments

spectrum.list

A list of the spectra (y-values). Since by definition some of these differ in length this has to be in list form with a single spectrum per list item.

ppm.list

The list of corresponding ppm values (x-values) with the highest ppm-value at the begining (left) as is the convention for NMR spectra. (This our ppm.edges.matrix has to be provided).

ppm.edges.matrix

The list with the starting and ending ppm values (highest ppm-value on the left/in the beginning). This or ppm.list has to be provided.

Value

SpectraAndPPM A list with 2 elements, the DataMatrix and the ppmMatrix.

Author(s)

Charlie Beirnaert, charlie.beirnaert@uantwerpen.be

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# this is an example for 3 meaningless spectra
lengths_of_spectra <- c(100,150,120)
measurement_distance <- 0.01
starting_ppm_values <- c(8.7, 9.0, 9.0)
spectra <- list()
ppm_values <- list()
for (k in 1:3) {
    spectra[[k]] <- runif(lengths_of_spectra[k], min = 0, max = 10)
    
    # note the minus sign in the 'by' statement
    ppm_values[[k]] <- seq(from = starting_ppm_values[k], by = -measurement_distance, 
                           length.out = lengths_of_spectra[k])  
}
new.Data <- BuildRawDataMatrix(spectrum.list = spectra, ppm.list = ppm_values)
spectraMatrix <- new.Data$DataMatrix
ppmMatrix <- new.Data$ppmMatrix

speaq2 documentation built on May 6, 2017, 4:09 a.m.