createDatabase {msPurity} | R Documentation

## Create database

### Description

** General **

Create and SQLite database of an LC-MS(/MS) experiment (replaces the create_database function).

Schema details can be found here.

Example LC-MS/MS processing workflow

- Purity assessments

  - (mzML files) -> purityA -> (pa)

- XCMS processing

  - (mzML files) -> xcms.xcmsSet -> xcms.merge -> xcms.group -> xcms.retcor -> xcms.group -> (xset)

- Fragmentation processing

  - (xset, pa) -> frag4feature -> filterFragSpectra -> averageAllFragSpectra -> createDatabase -> spectralMatching -> (sqlite spectral database)

### Usage

    createDatabase(pa, xset, xsa = NULL, outDir = ".", grpPeaklist = NA,
      dbName = NA, metadata = NA)

### Arguments

`pa` | purityA object; Needs to be the same used for frag4feature function
`xset` | xcms object; Needs to be the same used for frag4feature function (this will be ignored when using xsa parameter)
`xsa` | CAMERA object (optional); if CAMERA object is used, we ignore the xset parameter input and obtain all information from the xset object nested with the CAMERA xsa object. Adduct and isotope information will be included into the database when using this parameter. The underlying xset object must be the one used for the frag4feature function
`outDir` | character; Out directory for the SQLite result database
`grpPeaklist` | dataframe (optional); Can use any peak dataframe. Still needs to be derived from the xset object though
`dbName` | character (optional); Name of the result database
`metadata` | list; A list of metadata to add to the s_peak_meta table

### Value

path to SQLite database and database name

### Examples

    #msmsPths <- list.files(system.file("extdata", "lcms", "mzML", package="msPurityData"), full.names = TRUE, pattern = "MSMS")
    #xset <- xcms::xcmsSet(msmsPths)
    #xset <- xcms::group(xset)
    #xset <- xcms::retcor(xset)
    #xset <- xcms::group(xset)

    #pa  <- purityA(msmsPths)
    #pa <- frag4feature(pa, xset)
    #pa <- filterFragSpectra(pa, allfrag=TRUE)
    #pa <- averageAllFragSpectra(pa)
    #dbPth <- createDatabase(pa, xset, metadata=list('polarity'='positive', 'instrument'='Q-Exactive'))

    # Run from previously generated data:
    pa <- readRDS(system.file("extdata", "tests", "purityA", "9_averageAllFragSpectra_with_filter_pa.rds", package="msPurity"))
    xset <- readRDS(system.file("extdata","tests", "xcms", "msms_only_xset.rds", package="msPurity"))
    msmsPths <- list.files(system.file("extdata", "lcms", "mzML", package="msPurityData"), full.names = TRUE, pattern = "MSMS")
    pa@fileList[1] <- msmsPths[basename(msmsPths)=="LCMSMS_1.mzML"]
    pa@fileList[2] <- msmsPths[basename(msmsPths)=="LCMSMS_2.mzML"]
    xset@filepaths[1] <- msmsPths[basename(msmsPths)=="LCMSMS_1.mzML"]
    xset@filepaths[2] <- msmsPths[basename(msmsPths)=="LCMSMS_2.mzML"]
    td <- tempdir()
    db_pth = createDatabase(pa, xset, outDir = td)

[Package msPurity version 1.10.0 Index]