filterPeaks | R Documentation |
This function removes infrequently occuring peaks in a list of
MassPeaks
objects.
filterPeaks(l, minFrequency, minNumber, labels, mergeWhitelists=FALSE)
l |
|
minFrequency |
|
minNumber |
|
labels |
|
mergeWhitelists |
|
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.
Returns a list
of filtered
MassPeaks
objects.
Sebastian Gibb mail@sebastiangibb.de
intensityMatrix
,
MassPeaks
Website: https://strimmerlab.github.io/software/maldiquant/
## load package
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"]
## apply different minFrequency arguments to each group
groups <- 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 mergeWhitelists
groups <- factor(c("a", "a", "b", "b"), levels=c("a", "b"))
## default behaviour
filteredPeaks <- 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.