createMSP,purityA-method {msPurity} | R Documentation

## Using a purityA object, create an MSP file of fragmentation spectra

### Description

General

Create an MSP file for all the fragmentation spectra that has been linked to an XCMS feature via frag4feature. Can export all the associated scans individually or the averaged fragmentation spectra can be exported.

Additional metadata can be included in a dataframe (each column will be added to metadata of the MSP spectra). The dataframe must contain the column "grpid" corresponding to the XCMS grouped feature.

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 -> averageIntraFragSpectra -> averageIntraFragSpectra -> createMSP -> (MSP file)

### Usage

    ## S4 method for signature 'purityA'
    createMSP(pa, msp_file_pth = NULL, metadata = NULL,
      metadata_cols = NULL, xcms_groupids = NULL, method = "all",
      adduct_split = TRUE, filter = TRUE, msp_schema = "massbank",
      intensity_ra = "intensity_ra")

### Arguments

`pa` | object; purityA object
`msp_file_pth` | character; Name of the output msp file, if NULL the file "frag_spectra_time stamp.msp" will be created in the current directory
`metadata` | data.frame; Data frame with additional coumpound infomation to include in msp output
`metadata_cols` | vector; Column names of meta data to incorporate into name
`xcms_groupids` | vector; XCMS group id's to extract ms/ms data for
`method` | character; "all" will export all matching ms/ms spectra to xcms features, "max" will use spectra with the highest inensity, "av_intra" will use the intra file averaged spectra (within file), "av_inter" will use the inter file (across file) averaged spectra, "av_all" will use the averaged spectra (ignoring inter and intra)
`adduct_split` | boolean; If either "adduct" or MS$FOCUSED_ION: PRECURSOR_TYPE column is in metadata then each adduct will have it's own MSP spectra. (Useful, if the MSP file will be used for further annotation)
`filter` | boolean; TRUE if filtered peaks are to be removed
`msp_schema` | character; Either MassBank (Europe) or MoNA style of MSP file format to be used ('massbank' or 'mona')
`intensity_ra` | character; Either 'intensity', 'ra' (relative abundance) or 'intensity_ra' (intensity and relative abundance) to be written to the MSP file

### Value

Returns a MSP file with the selected spectra and metadata

### Examples

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

    #pa  <- purityA(msmsPths)
    #pa <- frag4feature(pa, xset)
    #pa <- averageAllFragSpectra(pa)
    pa <- readRDS(system.file("extdata", "tests", "purityA", "9_averageAllFragSpectra_with_filter_pa.rds", package="msPurity"))
    createMSP(pa)

[Package msPurity version 1.10.0 Index]