averageAllFragSpectra-purityA-method: Using a purityA object, average and filter MS/MS spectra for...

averageAllFragSpectra,purityA-methodR Documentation

Using a purityA object, average and filter MS/MS spectra for each XCMS feature within and across MS data files (ignoring intra and inter relationships)

Description

General

Average and filter fragmentation spectra for each XCMS feature within and across MS data files (ignoring intra and inter relationships).

The averaging is performed using hierarchical clustering of the m/z values of each peaks, where m/z values within a set ppm tolerance will be clustered. The clustered peaks are then averaged (or summed).

The fragmentation can be filtered on the averaged spectra (with the arguments snr, rsd, minfrac, ra)

Example LC-MS/MS processing workflow

  • Purity assessments

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

  • XCMS processing

    • (mzML files) -> xcms.findChromPeaks -> (optionally) xcms.adjustRtime -> xcms.groupChromPeaks -> (xcmsObj)

    • Older versions of XCMS — (mzML files) -> xcms.xcmsSet -> xcms.group -> xcms.retcor -> xcms.group -> (xcmsObj)

  • Fragmentation processing

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

Usage

## S4 method for signature 'purityA'
averageAllFragSpectra(
  pa,
  minfrac = 0.5,
  minnum = 1,
  ppm = 5,
  snr = 0,
  ra = 0,
  av = "median",
  sumi = TRUE,
  rmp = FALSE,
  cores = 1
)

Arguments

pa

object; purityA object

minfrac

numeric;minimum ratio of the peak fraction (peak count / total peaks) across all (ignoring intra and inter relationships)

minnum

numeric; minimum number of times peak is present across all fragmentation spectra (ignoring intra and inter relationships)

ppm

numeric; ppm threshold to average across all scans (ignoring intra and inter relationships)

snr

numeric; minimum signal-to-noise of the peak across all (ignoring intra and inter relationships)

ra

numeric; minimum relative abundance of the peak fraction across all (ignoring intra and inter relationships)

av

character; type of averaging to use (median or mean)

sumi

boolean; TRUE if the intensity for each peak is summed across averaged spectra

rmp

boolean; TRUE if peaks are to be removed that do not meet the threshold criteria. Otherwise they will just be flagged

cores

numeric; Number of cores for multiprocessing

Value

Returns a purityA object (pa) with the following slots now with data

  • pa@av_spectra: the average spectra is recorded here stored as a list. E.g. pa@av_spectra$1$av_all would give the average spectra for grouped feature 1.

  • pa@av_all_params: The parameters used are recorded here

Each spectra in the av_spectra list contains the following columns:

  • cl: id of clustered (averaged) peak

  • mz: average m/z

  • i: average intensity

  • snr: average signal to noise ratio

  • rsd: relative standard deviation

  • count: number of clustered peaks

  • total: total number of potential scans to be used for averaging

  • inPurity: average precursor ion purity

  • ra: average relative abundance

  • frac: the fraction of clustered peaks (e.g. the count/total)

  • snr_pass_flag: TRUE if snr threshold criteria met

  • minfrac_pass_flag: TRUE if minfrac threshold criteria

  • ra_pass_flag: TRUE if ra threshold criteria met

  • pass_flag: TRUE if all threshold criteria met

Examples


#====== XCMS ===================================
## Read in MS data
#msmsPths <- list.files(system.file("extdata", "lcms", "mzML",
#           package="msPurityData"), full.names = TRUE, pattern = "MSMS")
#ms_data = readMSData(msmsPths, mode = 'onDisk', msLevel. = 1)

## Find peaks in each file
#cwp <- CentWaveParam(snthresh = 5, noise = 100, ppm = 10, peakwidth = c(3, 30))
#xcmsObj  <- xcms::findChromPeaks(ms_data, param = cwp)

## Optionally adjust retention time
#xcmsObj  <- adjustRtime(xcmsObj , param = ObiwarpParam(binSize = 0.6))

## Group features across samples
#pdp <- PeakDensityParam(sampleGroups = c(1, 1), minFraction = 0, bw = 30)
#xcmsObj <- groupChromPeaks(xcmsObj , param = pdp)

#====== msPurity ================================
#pa  <- purityA(msmsPths)
#pa <- frag4feature(pa, xcmsObj)
#pa <- filterFragSpectra(pa)
#pa <- averageAllFragSpectra(pa)

## Run from previously generated data
pa <- readRDS(system.file("extdata", "tests", "purityA",
                          "3_filterFragSpectra_pa.rds", package="msPurity"))
pa <- averageAllFragSpectra(pa)



Viant-Metabolomics/msPurity documentation built on May 13, 2024, 8:23 a.m.