msImport: Mass Spectra Data Import

Description Usage Arguments Details Value See Also Examples

Description

Imports data from (multiple) mass spectrum file(s) and compiles them into an object of msList, i.e., a list of two-column matrices.

Usage

1
2
msImport(path, label="unclassified", type="ASCII",
    pattern="", ...)

Arguments

path

A single character string or a vector of character strings. Each character string can either be a path to the directory containing the mass spectra files (i.e., directory path) or a path to a mass spectra file (i.e., file path). In the case of a vector of character strings, the paths should be either all directory paths or all file paths.

...

Additional arguments. See importData for details.

label

A single character string or a vector of character strings defining the classification label(s) for the spectra to be imported. The length of label must be equal to the number of elements in the path argument. The labels will be used in mass spectra classification but not in processing. Default: "unclassified".

pattern

A character string denoting the pattern to use in filtering the list of files in the path directory. Default: "" (all files in path).

type

A single character string or a vector of character strings specifying the input data file type(s). The length of type must be equal to the number of elements in the path variable, otherwise the first entry is replicated accordingly. This argument may be any of the supported types in the importData function or type "CiphergenXML", which represents a Ciphergen XML mass spectrometry data file. Default: "ASCII".

Details

Each data file has two columns defined by m/z and intensity values. This function also checks if the following conditions hold:

1

the m/z values are distinct;

2

the m/z values are positive;

3

the m/z values are the same across spectra;

4

the lengths of each spectra are the same.

and issues warning messages if not.

Value

An object of msList, which is a list of two-column matrices, one matrix for each imported file. The first column is named "mz" and contains m/z values. The second column is named "intensity" and contains the intensity values. The list has an attribute named "type", which is a factor and contains the classification labels for the imported spectra.

See Also

msImportCiphergenXML.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## create faux MS data files 
n.file <- 10
files <- file.path(getwd(), paste("ms", seq(n.file), ".csv", sep=""))

for (i in seq(n.file)) {
    ms <- data.frame("m/z"=(1:5), intensity=(6:10)+i)
    if (is.R())
      write.table(ms, file=files[i])
    else
      write.table(ms, file=files[i], dimnames="colnames")
}

## load the mass spectra files into a list of 
## two-column matrices 
msImport(path=files)

## do the same except use the path and pattern 
## arguments 
msImport(path=getwd(), pattern=".csv" )

## remove the files 
unlink(files)

zeehio/msProcess documentation built on May 4, 2019, 10:15 p.m.