importSpectra {ASICS} | R Documentation

## Import metabolomic spectra

### Description

Import spectra from text or CSV, fid or 1r (preprocessed spectrum) files. (optional) Spectra are baseline corrected, aligned and normalised during the importation.

### Usage

    importSpectra(
      name.dir = NULL,
      name.file = NULL,
      type.import,
      baseline.correction = FALSE,
      alignment = FALSE,
      normalisation = TRUE,
      ncores = 1,
      verbose = TRUE,
      ...
    )

### Arguments

`name.dir` | Path of the folder containing the spectra. Each subfolder contains the fid or the 1r (preprocessed spectrum) files of this sample if `type = "fid"` or `type = "1r"`.
`name.file` | Name of the txt or csv file containing the spectra in columns (spectrum names in the first line and ppm grid in the first column).
`type.import` | Type of import. Either `"txt"`, `"csv"`, `"fid"` or `"1r"`.
`baseline.correction` | Logical. If `TRUE` a baseline correction is applied for each spectrum. Default to `FALSE`.
`alignment` | Logical. If `TRUE` a peak alignment is applied between all spectra. Default to `FALSE`.
`normalisation` | Logical. If `TRUE` a normalisation is applied for each spectrum (see `normaliseSpectra` for details). Default to `TRUE`.
`ncores` | Number of cores used in parallel evaluation. Default to `1`.
`verbose` | A boolean value to allow print out process information.
`...` | Further arguments to be passed to the functions `read.table`, `importSpectraBruker`, `Normalization` (`PepsNMR-package`), `alignSpectra` or `normaliseSpectra` for specifying the parameters of the algorithm, if necessary.

### Details

Some preprocessing steps are included during the importation. First, spectra are baseline corrected if `baseline.correction = TRUE`. Then, all spectrum definition domains are aligned to a unique one (either the one specified in `ppm.grid` or the grid of the default library). Finally, all spectra are normalised if `normalisation = TRUE` and aligned if `alignment = TRUE`.

### Value

A data frame with spectra in columns and chemical shifts (in ppm) in rows.

### References

Wang, K.C., Wang, S.Y., Kuo, C.H., Tseng Y.J. (2013). Distribution-based classification method for baseline correction of metabolomic 1D proton nuclear magnetic resonance spectra. Analytical Chemistry, 85(2), 1231-1239.

### See Also

`importSpectraBruker` `normaliseSpectra` `alignSpectra`

### Examples

    ## Import from txt file
    current_path <- system.file("extdata", package = "ASICS")
    spectra_data <- importSpectra(name.dir = current_path,
                         name.file = "spectra_example.txt", type.import = "txt")

    ## Import from fid file
    current_path <- system.file("extdata", "example_spectra", package = "ASICS")
    spectra_data <- importSpectra(name.dir = current_path, type.import = "fid",
                                 subdirs = TRUE, dirs.names = TRUE)

    ## Import from txt file
    current_path <- system.file("extdata", "example_spectra", package = "ASICS")
    spectra_data <- importSpectra(name.dir = current_path, type.import = "1r")

[Package ASICS version 2.3.1 Index]