--- title: "Generate metabolite library entries" author: "Gonçalo Graça" date: "`r Sys.Date()`" output: BiocStyle::html_document: toc: true toc_float: true number_sections: true vignette: > %\VignetteIndexEntry{Generate metabolite library entries} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r options, include=FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ``` # Introduction This vignette illustrates how to generate a metabolite library entry from an experimental MS/MS spectrum. # Generate a library entry Load library and dependencies: ```{r load_package, eval=TRUE, message=FALSE, warning=FALSE} library(MetaboAnnotatoR) ``` **Read the MS/MS spectrum:** Create a spectrum as data frame into R. In this example we will use the MS/MS spectrum of D-Pantothenic Acid [M+H]+ adduct from MassBank, accession code: MSBNK-RIKEN-PR100295. ```{r import_spectrum, eval=TRUE} specObject <- data.frame(V1=c(70.0298, 85.0652, 90.0556, 98.024, 116.0353, 124.0766, 184.0981, 202.1085, 220.1185), V2=c(13.965907, 13.534607, 100.0, 26.165537, 15.383036, 25.231054, 28.578764, 43.017047, 64.962005)) ``` **Define a folder to store the library entry result** ```{r set_lib_dir, eval=TRUE} LibDir <- tempdir() ``` **Generate library entry:** We can then convert the spectra into a library entry by using the function *genFragEntry*. This function will attribute occurrence scores to the peaks above *mpeaksThres* threshold ("marker peaks") and above the noise level. Note that metabolite name, adduct name, accurate adduct m/z and output filename need to be explicitly defined. The peak-picking parameters *noise* and *mpeaksThres* and the occurrence scores used here are the default parameters. ```{r run_function, eval=TRUE} genFragEntry(specObject, "Pantothenic acid", "[M+H]+", 220.1179, DirPath=LibDir, "Pantothenic_acid_pos", noise=0.005, mpeaksScore=0.9, mpeaksThres=0.1, mzTol=0.01) ``` A file named *Pantothenic_acid_pos.csv* will be saved in the folder specified by the user. # Session Info ```{r sessionInfo} sessionInfo() ```