groupChromPeaks-density {xcms} | R Documentation

## Peak grouping based on time dimension peak densities

### Description

This method performs performs correspondence (chromatographic peak grouping) based on the density (distribution) of identified peaks along the retention time axis within slices of overlapping mz ranges. All peaks (from the same or from different samples) being close on the retention time axis are grouped into a feature (peak group).

The `PeakDensityParam` class allows to specify all settings for the peak grouping based on peak densities along the time dimension. Instances should be created with the `PeakDensityParam()` constructor.

`sampleGroups`,`sampleGroups<-`: getter and setter for the `sampleGroups` slot of the object. Its length should match the number of samples in the experiment and it should not contain `NA`s.

`bw`,`bw<-`: getter and setter for the `bw` slot of the object.

`minFraction`,`minFraction<-`: getter and setter for the `minFraction` slot of the object.

`minSamples`,`minSamples<-`: getter and setter for the `minSamples` slot of the object.

`binSize`,`binSize<-`: getter and setter for the `binSize` slot of the object.

`maxFeatures`,`maxFeatures<-`: getter and setter for the `maxFeatures` slot of the object.

`groupChromPeaks,XCMSnExp,PeakDensityParam`: performs correspondence (peak grouping within and across samples) within in mz dimension overlapping slices of MS data based on the density distribution of the identified chromatographic peaks in the slice along the time axis.

The correspondence analysis can be performed on chromatographic peaks of any MS level (if present and if chromatographic peak detection has been performed for that MS level) defining features combining these peaks. The MS level can be selected with the parameter `msLevel`. By default, calling `groupChromPeaks` will remove any previous correspondence results. This can be disabled with `add = TRUE`, which will add newly defined features to already present feature definitions.

### Usage

    PeakDensityParam(
      sampleGroups = numeric(),
      bw = 30,
      minFraction = 0.5,
      minSamples = 1,
      binSize = 0.25,
      maxFeatures = 50
    )

    ## S4 method for signature 'PeakDensityParam'
    sampleGroups(object)

    ## S4 replacement method for signature 'PeakDensityParam'
    sampleGroups(object) <- value

    ## S4 method for signature 'PeakDensityParam'
    bw(object)

    ## S4 replacement method for signature 'PeakDensityParam'
    bw(object) <- value

    ## S4 method for signature 'PeakDensityParam'
    minFraction(object)

    ## S4 replacement method for signature 'PeakDensityParam'
    minFraction(object) <- value

    ## S4 method for signature 'PeakDensityParam'
    minSamples(object)

    ## S4 replacement method for signature 'PeakDensityParam'
    minSamples(object) <- value

    ## S4 method for signature 'PeakDensityParam'
    binSize(object)

    ## S4 replacement method for signature 'PeakDensityParam'
    binSize(object) <- value

    ## S4 method for signature 'PeakDensityParam'
    maxFeatures(object)

    ## S4 replacement method for signature 'PeakDensityParam'
    maxFeatures(object) <- value

    ## S4 method for signature 'XCMSnExp,PeakDensityParam'
    groupChromPeaks(object, param, msLevel = 1L, add = FALSE)

### Arguments

`sampleGroups` | A vector of the same length than samples defining the sample group assignments (i.e. which samples belong to which sample group). This parameter is mandatory for the `PeakDensityParam` and has to be provided also if there is no sample grouping in the experiment (in which case all samples should be assigned to the same group).
`bw` | `numeric(1)` defining the bandwidth (standard deviation ot the smoothing kernel) to be used. This argument is passed to the [density() method.
`minFraction` | `numeric(1)` defining the minimum fraction of samples in at least one sample group in which the peaks have to be present to be considered as a peak group (feature).
`minSamples` | `numeric(1)` with the minimum number of samples in at least one sample group in which the peaks have to be detected to be considered a peak group (feature).
`binSize` | `numeric(1)` defining the size of the overlapping slices in mz dimension.
`maxFeatures` | `numeric(1)` with the maximum number of peak groups to be identified in a single mz slice.
`object` | For `groupChromPeaks`: an XCMSnExp object containing the results from a previous peak detection analysis (see `findChromPeaks()`).
    For all other methods: a `PeakDensityParam` object.
`value` | The value for the slot.
`param` | A `PeakDensityParam` object containing all settings for the peak grouping algorithm.
`msLevel` | `integer(1)` (default `msLevel = 1L`) defining the MS level on which the correspondence should be performed. It is required that chromatographic peaks of the respective MS level are present.
`add` | `logical(1)` (default `add = FALSE`) allowing to perform an additional round of correspondence (e.g. on a different MS level) and add features to the already present feature definitions.

### Value

The `PeakDensityParam` function returns a `PeakDensityParam` class instance with all of the settings specified for chromatographic peak alignment based on peak densities. Note that argument `sampleGroups` is mandatory and should represent either the sample grouping in the experiment. It's length has to match the number of sample in the experiments.

For `groupChromPeaks`: a XCMSnExp object with the results of the correspondence analysis. The definition of the resulting mz-rt features can be accessed with the `featureDefinitions()` method

### Slots

`sampleGroups,bw,minFraction,minSamples,binSize,maxFeatures`

  See corresponding parameter above.

### Note

These methods and classes are part of the updated and modernized `xcms` user interface. All of the settings to the algorithm can be passed with a `PeakDensityParam` object.

### Author(s)

Colin Smith, Johannes Rainer

### References

Colin A. Smith, Elizabeth J. Want, Grace O'Maille, Ruben Abagyan and Gary Siuzdak. "XCMS: Processing Mass Spectrometry Data for Metabolite Profiling Using Nonlinear Peak Alignment, Matching, and Identification" Anal. Chem. 2006, 78:779-787.

### See Also

The `do_groupChromPeaks_density()` core API function and `group.density()` for the old user interface.

`plotChromPeakDensity()` to plot peak densities and evaluate different algorithm settings.

`featureDefinitions()` and `featureValues()` for methods to access the features (i.e. the peak grouping results).

XCMSnExp for the object containing the results of the correspondence.

`plotChromPeakDensity()` for plotting chromatographic peak density with the possibility to test different parameter settings.

Other peak grouping methods: `groupChromPeaks-mzClust`, `groupChromPeaks-nearest`, `groupChromPeaks()`

### Examples

    ## Create a PeakDensityParam object
    p <- PeakDensityParam(binSize = 0.05, sampleGroups = c(1, 1, 2, 2))
    ## Change hte minSamples slot
    minSamples(p) <- 3
    p

    ##############################
    ## Chromatographic peak detection and grouping.
    ##
    ## Load a test data set with detected peaks
    data(faahko_sub)
    ## Update the path to the files for the local system
    dirname(faahko_sub) <- system.file("cdf/KO", package = "faahKO")

    ## Disable parallel processing for this example
    register(SerialParam())

    res <- faahko_sub

    head(chromPeaks(res))
    ## The number of peaks identified per sample:
    table(chromPeaks(res)[, "sample"])

    ## Performing the chromatographic peak grouping. Assigning all samples to
    ## the same sample group.
    fdp <- PeakDensityParam(sampleGroups = rep(1, length(fileNames(res))))
    res <- groupChromPeaks(res, fdp)

    ## The definition of the features (peak groups):
    featureDefinitions(res)

    ## Using the featureValues method to extract a matrix with the
    ## intensities of the features per sample.
    head(featureValues(res, value = "into"))

    ## The process history:
    processHistory(res)

[Package xcms version 3.16.1 Index]