read_lib: Read msp/mgf mass spectral libraries

View source: R/read_libraries.R

read_libR Documentation

Read msp/mgf mass spectral libraries

Description

read_lib offers a way to read mass spectral libraries into R for further processing.

Usage

read_lib(
  file,
  format = "msp",
  type = "MS2",
  remove_ri = TRUE,
  remove_rt = TRUE
)

Arguments

file

Mass spectral library in msp or mgf format.

format

The format of the library, either msp or mgf.

type

The type of the library, either EI or MS2.

remove_ri

A logical scalar only used in case of EI mass spectral library. Should retention index (RI) be removed? TRUE or FALSE

remove_rt

A logical scalar only used in case of MS2 mass spectral library. Should retention time (RT) be removed? TRUE or FALSE

Details

This is a generic function to read either EI or MS2 mass spectral libraries. The library can be either in msp or mgf form. For this reason, it is required to set the format and the type of the input library. The default is MS2 in msp format. In the case of EI mass spectral library, an additional Boolean parameter remove_ri can be set to remove or keep the retention index (RI). In the case of MS2 mass spectral library, an additional Boolean parameter remove_rt can be set to remove or keep the retention time (RT). This function supports parallel computing making use of the future.apply. Please see the vignette for more details.

Value

A list with each spectral entry as a list element for further processing.

Examples

# The first 2 lines only indicate the location where the example files are
# stored. You might not need them.
EI_file <- system.file("EI.msp", package = "mspcompiler")
MS2_mgf_file <- system.file("MS2.mgf", package = "mspcompiler")

EI <- read_lib(file = EI_file, format = "msp", type = "EI", remove_ri = FALSE)
MS2_mgf <- read_lib(file = MS2_mgf_file, format = "mgf", type = "MS2")

QizhiSu/mspcompiler documentation built on May 7, 2024, 4:25 a.m.