## 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 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 removed in group "a"
filteredPeaks[groups == "a"];
## peaks at mass 5 removed in group "b"
filteredPeaks[groups == "b"];Run the code above in your browser using DataLab