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.

### Usage

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

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

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

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

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

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

  See corresponding parameter above. `.__classVersion__` stores the version from the class. Slots values should exclusively be accessed via the corresponding getter and setter methods listed above.

### Note

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

Calling `groupChromPeaks` on an `XCMSnExp` object will cause all eventually present previous correspondence results to be dropped.

### 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,XCMSnExp-method` for methods to access the features (i.e. the peak grouping results).

`XCMSnExp` for the object containing the results of the correspondence.

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.
    ##
    ## Below we perform first a peak detection (using the matchedFilter
    ## method) on some of the test files from the faahKO package followed by
    ## a peak grouping using the density method.
    library(faahKO)
    library(MSnbase)
    fls <- dir(system.file("cdf/KO", package = "faahKO"), recursive = TRUE,
               full.names = TRUE)

    ## Reading 2 of the KO samples
    raw_data <- readMSData(fls[1:2], mode = "onDisk")

    ## Perform the chromatographic peak detection using the matchedFilter method.
    mfp <- MatchedFilterParam(snthresh = 20, binSize = 1)
    res <- findChromPeaks(raw_data, param = mfp)

    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.2.0 Index]