Learn R Programming

MALDIquant (version 1.7)

filterPeaks: Removes less frequently peaks.

Description

This function removes infrequently peaks from a list of MassPeaks objects.

Usage

filterPeaks(l, minFrequency, minNumber, labels)

Arguments

l
list, list of MassPeaks objects.
minFrequency
double, remove all peaks which occur in less than minFrequency*length(l) MassPeaks objects. It is a relative threshold.
minNumber
double, remove all peaks which occur in less than minNumber MassPeaks objects. It is an absolute threshold.
labels
list, list of factors (one for each MassPeaks object) to do groupwise filtering.

Value

  • Returns a list of filtered MassPeaks objects.

Details

If labels argument is given all peaks which occur in less than minFrequency*n MassPeaks are removed (n is the number of MassPeaks objects in each level).

If minFrequency and minNumber arguments are given the highest of minFrequency*n (n is the number of MassPeaks) and minNumber is chosen.

References

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

See Also

intensityMatrix, MassPeaks

Examples

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

## create four MassPeaks objects and add them to the list
p <- list(createMassPeaks(mass=1:2, intensity=1:2),
          createMassPeaks(mass=1:3, intensity=1:3),
          createMassPeaks(mass=1:4, intensity=1:4),
          createMassPeaks(mass=1:5, intensity=1:5))

## only keep peaks which occur in all MassPeaks objects
filteredPeaks <- filterPeaks(p, minFrequency=1)

## compare result
intensities <- intensityMatrix(filteredPeaks)

## peaks at mass 3,4,5 are removed
all(dim(intensities) == c(4, 2)) # TRUE
all(intensities[,1] == 1)        # TRUE
all(intensities[,2] == 2)        # TRUE

## only keep peaks which occur in all MassPeaks objects in a group
## (e.g. useful for technical replicates)
groups <- factor(c("a", "a", "b", "b"), levels=c("a", "b"))
filteredPeaks <- filterPeaks(p, minFrequency=1, labels=groups)

## peaks at mass 3 were removed in group "a"
filteredPeaks[groups == "a"]

## peaks at mass 5 were removed in group "b"
filteredPeaks[groups == "b"]

## only keep peaks which occur at least twice in a group
groups <- factor(c("a", "a", "b", "b", "b"), levels=c("a", "b"))
filteredPeaks <- filterPeaks(c(p, p[[3]]), minNumber=2, labels=groups)

## peaks at mass 3 were removed in group "a"
filteredPeaks[groups == "a"]

## peaks at mass 5 were removed in group "b"
filteredPeaks[groups == "b"]

Run the code above in your browser using DataLab