Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

import-functions

Import files


Description

This function provides a general interface to import different file formats into MassSpectrum-class or MassPeaks-class objects.

Usage

import(path, type = "auto", pattern, excludePattern = NULL,
  removeEmptySpectra = TRUE, centroided = FALSE, massRange = c(0,
  Inf), minIntensity = 0, mc.cores = 1L, verbose = interactive(),
  ...)

Arguments

path

character, path to directory or file which should be read in.

type

character, file format. If type is set to “auto” MALDIquant tries to detect the correct file type automatically. It often depends on the file extension (if path is a directory the most represented file extension is used; pattern argument is ignored).

pattern

character, a regular expression to find files in a directory (see details).

excludePattern

character, a regular expression to exclude files in a directory (see details).

removeEmptySpectra

logical, should empty spectra excluded?

centroided

logical, if centroided=FALSE (default) the data are treated as not centroided and a list of MassSpectrum-class objects is returned. Use centroided=TRUE to assume centroided data and get a list of MassPeaks-class objects.

massRange

double, limits of mass import (left/minimal mass, right/maximal mass).

minIntensity

double, minimal intensity to import.

mc.cores

number of cores to use (default 1; only unix-based platforms are supported, see MALDIquantForeign-parallel for details).

verbose

logical, verbose output?

...

arguments to be passed to specific import functions.

Details

Specific import functions:

path: In addition to the above mentioned file types the following (compressed) archives are supported, too: zip, tar, tar.gz, tar.bz2, tar.xz. The archives are uncompressed in a temporary directory. Afterwards the import function is called (with type="auto").

pattern: Sometimes unusual file extensions are used (e.g. "*.xml" for mzXML files). In this case a specific pattern could be defined to import files with an unusual file extension (e.g. pattern="^.*\.xml$" to read all *.xml files in a directory; see regexp for details).

excludePattern: Sometimes some files should be excluded. E.g. to ignore additional aquired Bruker LIFT spectra (MALDI-TOF/TOF; which are not support, yet) you could use excludePattern="([[:digit:]\.]+)LIFT[\\/]1SRef".

Value

a list of MassSpectrum-class or MassPeaks-class objects (depending on the centroided argument).

Author(s)

Sebastian Gibb

References

See Also

Examples

library("MALDIquant")
library("MALDIquantForeign")

## get example directory
exampleDirectory <- system.file("exampledata", package="MALDIquantForeign")

## import mzXML files
s <- import(exampleDirectory, type="mzXML")

## import tab delimited file with different file extension (default: *.tab)
s <- import(exampleDirectory, type="tab", pattern="^.*\\.txt")

## import single mzML file
s <- import(file.path(exampleDirectory, "tiny1.mzML1.1.mzML"))

## import gzipped csv file
s <- import(file.path(exampleDirectory, "compressed", "csv1.csv.gz"))

MALDIquantForeign

Import/Export Routines for 'MALDIquant'

v0.12
GPL (>= 3)
Authors
Sebastian Gibb [aut, cre] (<https://orcid.org/0000-0001-7406-4443>), Pietro Franceschi [ctb]
Initial release
2019-01-30

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.