frag4feature,purityA-method {msPurity} | R Documentation

## Using a purityA object, link MS/MS data to XCMS features

### Description

#### General

Assign fragmentation spectra (MS/MS) stored within a purityA class object to grouped features within an XCMS xset object.

XCMS calculates individual chromatographic peaks for each mzML file (saved in xset@peaks), these are then grouped together (using xcms.group). Ideally the mzML files that contain the MS/MS spectra also contain sufficient MS1 scans for XCMS to detect MS1 chromatographic features. If this is the case, to determine if a MS2 spectra is to be linked to an XCMS grouped feature, the associated acquisition time of the MS/MS event has to be within the retention time window defined for the individual peaks associated for each file. The precursor m/z value also has to be within the user ppm tolerance to XCMS feature.

See below for representation of the linking (the * —— * represent a many-to-many relationship) e.g. 1 or more MS/MS events can be linked to 1 or more individual feature and an individual XCMS feature can be linked to 1 or more grouped XCMS features

- [grouped XCMS feature - across files] * —— * [individual XCMS feature - per file] * —— * [MS/MS spectra]

Alternatively, if the "useGroup" argument is set to TRUE, the full width of the grouped peak (determined as the minimum rtmin and maximum rtmax of the all associated individual peaks) will be used. This option should be used if the mzML file with MS/MS has very limited MS1 data and so individual chromatographic peaks might not be detected with the mzML files containing the MS/MS data. However, it should be noted this may lead to potential inaccurate linking.

- [grouped XCMS peaks] * —— * [MS/MS spectra]

#### Example LC-MS/MS processing workflow

The purityA object can be used for further processing including linking the fragmentation spectra to XCMS features, averaging fragmentation, database creation and spectral matching (from the created database). See below for an example 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)

#### Additional notes

- If using only a single file, then grouping still needs to be performed within XCMS before frag4feature can be used.

- Fragmentation spectra below a certain precursor ion purity can be be removed (see plim argument).

- A SQLite database can be created directly here but the functionality has been deprecated and the createDatabase function should now be used

- Can experience some problems when using XCMS version < 3 and obiwarp retention time correction.

### Usage

    ## S4 method for signature 'purityA'
    frag4feature(
      pa,
      xset,
      ppm = 5,
      plim = NA,
      intense = TRUE,
      convert2RawRT = TRUE,
      useGroup = FALSE,
      create_db = FALSE,
      out_dir = ".",
      db_name = NA,
      grp_peaklist = NA,
      use_group = NA
    )

### Arguments

`pa` | object; purityA object
`xset` | object; xcmsSet object derived from the same files as those used to create the purityA object
`ppm` | numeric; ppm tolerance between precursor mz and XCMS feature mz
`plim` | numeric; minimum purity of precursor to be included
`intense` | boolean; If TRUE the most intense precursor will be used. If FALSE the precursor closest to the center of the isolation window will be used
`convert2RawRT` | boolean; If retention time correction has been used in XCMS set this to TRUE
`useGroup` | boolean; Ignore individual peaks and just find matching fragmentation spectra within the (full) rtmin rtmax of each grouped feature
`create_db` | boolean; (Deprecated, to be removed - use createDatabase function) SQLite database will be created of the results
`out_dir` | character; (Deprecated, to be removed - use createDatabase function) Path where database will be created
`db_name` | character; (Deprecated, to be removed - use createDatabase function) If create_db is TRUE, a custom database name can be used, default is a time stamp
`grp_peaklist` | dataframe; (Deprecated, to be removed - use createDatabase function) Can use any peak dataframe to add to databse. Still needs to be derived from the xset object though
`use_group` | boolean; (Deprecated, to be removed - replaced with useGroup argument for style consistency)

### Value

Returns a purityA object (pa) with the following slots populated:

- pa@grped_df: A dataframe of the grouped XCMS features linked to the associated fragmentation spectra precursor details is recorded here

- pa@grped_ms2: A list of fragmentation spectra associated with each grouped XCMS feature is recorded here

- pa@f4f_link_type: The linking method is recorded here (e.g. individual peaks or grouped - "useGroup=TRUE")

### 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)

[Package msPurity version 1.14.1 Index]