Learn R Programming

MALDIquant (version 1.2)

binPeaks: Align Peaks into discrete bins.

Description

This function looks for similar peaks (mass) across MassPeaks objects and equalizes their mass.

Usage

binPeaks(l, tolerance=0.002)

Arguments

l
list, list of MassPeaks objects.
tolerance
double, maximal deviation of a peak position (mass) to be considered as identical.

Value

  • Returns a list of mass adjusted MassPeaks objects.

Details

The algorithm is based on the following workflow:
  1. Put all mass in a sorted vector.
Calculate differences between each neighbor. Divide the mass vector at the largest gap (largest difference) and form a left and a right bin. Rerun step 3 for the left and/or the right bin if they don't fulfill the two criteria:
  • The bin doesn't contain two or more peaks of the same sample.
All peaks in a bin are near to the mean (abs(mass-meanMass)/meanMass < tolerance).

References

See website: http://strimmerlab.org/software/maldiquant/

See Also

intensityMatrix, MassPeaks

Examples

Run this code
## load library
library("MALDIquant");

## create two MassPeaks objects
p <- list(createMassPeaks(mass=seq(100, 500, 100),
                          intensity=1:5),
          createMassPeaks(mass=c(seq(100.2, 300.2, 100), 395),
                          intensity=1:4));

## only keep peaks which occur in all MassPeaks objects
binnedPeaks <- binPeaks(p, tolerance=0.002);

## compare result
iM1 <- intensityMatrix(p);
iM2 <- intensityMatrix(binnedPeaks);

all(dim(iM1) == c(2, 9)); # TRUE
all(dim(iM2) == c(2, 6)); # TRUE

show(iM2);

## increase tolerance
binnedPeaks <- binPeaks(p, tolerance=0.1);

iM3 <- intensityMatrix(binnedPeaks);

all(dim(iM3) == c(2, 5)); # TRUE

show(iM3);

Run the code above in your browser using DataLab