--- title: "Import an MS/MS library" author: "Gonçalo Graça" date: "`r Sys.Date()`" output: BiocStyle::html_document: toc: true toc_float: true number_sections: true vignette: > %\VignetteIndexEntry{Import an MS/MS library} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r options, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ``` # Introduction This vignette illustrates how to convert MS/MS spectra libraries (.msp files) to MetaboAnnotatoR metabolite library entries. # Import .msp library **Load MetaboAnnotatoR library and dependencies** ```{r load_package, eval=TRUE, message=FALSE, warning=FALSE} library(MetaboAnnotatoR) ``` **Get the path to the example .msp MS/MS spectra library file:** Get the path to the example file containing the .msp library. For illustrative purposes, an .msp file containing some MS/MS spectra obtained from MassBank from both positive and negative ionisation modes was used: ```{r filepath, eval=TRUE} msp_path <- system.file("extdata", "MassBank_example.msp", package="MetaboAnnotatoR") ``` **Set a directory to store **Generate library entries imported from the .msp file** For this example a temporary directory will be used, but the user is encouraged to use any other preferred directory. ```{r setwd_to_run, eval=TRUE} LibDir <- tempdir() ``` Use function *mspToLib* to read and convert the spectra records from the .msp files into library entries (.csv files), which will be stored in the user-defined library directory (*LibDir*). A "positive" or "negative" mode suffix will be added to each file name to facilitate the organisation of the custom libraries. Similarly to the function *genFragEntry* this function will attribute occurrence scores to the peaks above *mpeaksThres* threshold ("marker peaks") and above the noise level. The peak-picking parameters *noise* and *mpeaksThres* and the occurrence scores used here are the default parameters. ```{r run_function, eval=TRUE, warning=FALSE} mspToLib(msp_path, LibDir, noise=0.005, mpeaksScore=0.9, mpeaksThres=0.1) ``` # Session Info ```{r sessionInfo} sessionInfo() ```