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 minNumberMassPeaks
objects. It is an absolute threshold.
labels: factor, (one for each MassPeaks object) to do groupwise filtering. The levels of the factor label define the groups. If not specified a single group is assumed.
mergeWhitelists: logical, if FALSE the filtering criteria are applied groupwise. If TRUE peaks that survive the filtering in one group (level of labels) these peaks are also kept in other groups even if their frequencies are below minFrequency.
Details
For mergeWhitelists=FALSE the filtering uses a separate peak whitelist for each group specified by labels, and is done independently in each group. For mergeWhitelists=TRUE the peak whitelists are combined, which means that peaks that occur frequently in at least one group are also kept in all other groups.
If both minFrequency and minNumber arguments are specified the more stringent threshold is used.
## load packagelibrary("MALDIquant")## create four MassPeaks objects and add them to the listp <- 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 objectsfilteredPeaks <- filterPeaks(p, minFrequency=1)## compare resultintensities <- intensityMatrix(filteredPeaks)## peaks at mass 3,4,5 are removedall(dim(intensities)== c(4,2))# TRUEall(intensities[,1]==1)# TRUEall(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 groupgroups <- 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"]## apply different minFrequency arguments to each groupgroups <- factor(c("a","a","b","b","b"), levels=c("a","b"))filteredPeaks <- filterPeaks(c(p, p[[3]]), minFrequency=c(1,2/3), labels=groups)intensityMatrix(filteredPeaks)# 1 2 3 4#[1,] 1 2 NA NA#[2,] 1 2 NA NA#[3,] 1 2 3 4#[4,] 1 2 3 4#[4,] 1 2 3 4## demonstrate the use of mergeWhitelistsgroups <- factor(c("a","a","b","b"), levels=c("a","b"))## default behaviourfilteredPeaks <- filterPeaks(p, minNumber=2, labels=groups)intensityMatrix(filteredPeaks)# 1 2 3 4#[1,] 1 2 NA NA#[2,] 1 2 NA NA#[3,] 1 2 3 4#[4,] 1 2 3 4## use mergeWhitelists=TRUE to keep peaks of group "a" that match all filtering## criteria in group "b"## (please note that mass == 3 is not removed in the second MassPeaks object)filteredPeaks <- filterPeaks(p, minNumber=2, labels=groups, mergeWhitelists=TRUE)intensityMatrix(filteredPeaks)# 1 2 3 4#[1,] 1 2 NA NA#[2,] 1 2 3 NA#[3,] 1 2 3 4#[4,] 1 2 3 4