applyPeaksFilter-msi.dataset-method: Apply the results of a peaks filter.

applyPeaksFilter,msi.dataset-methodR Documentation

Apply the results of a peaks filter.

Description

applyPeaksFilter select the peaks returned by a peak filter. Custom filters can be created passing a named array of selected peak indices to createPeaksFilter. Names correspond to the m/z values of the selected peaks and must coincide with those of the MS dataset.

Usage

## S4 method for signature 'msi.dataset'
applyPeaksFilter(object, peakFilter)

Arguments

object

msi.dataset-class object.

peakFilter

peaks filter results.

Value

msi.dataset-class object with only selected peaks.

Examples

## Load package
library("SPUTNIK")

## Mass spectrometry intensity matrix
X <- matrix(rnorm(16000), 400, 40)
X[X < 0] <- 0

## Print original dimensions
print(dim(X))

## m/z vector
mzVector <- seq(600, 900, by = (900 - 600) / 39)

## Read the image size
imSize <- c(20, 20)

## Construct the ms.dataset object
msiX <- msiDataset(X, mzVector, imSize[1], imSize[2])

## Calculate the p-values using the Clark Evans test, then apply Benjamini-
## Hochberg correction.
csr <- CSRPeaksFilter(
  msiData = msiX, method = "ClarkEvans",
  calculateCovariate = FALSE, adjMethod = "BH"
)

## Print selected peaks
print(csr$q.value)

## Create a new filter selecting corrected p-values < 0.001
selIdx <- which(csr$q.value < 0.001)
csrFilter <- createPeaksFilter(selIdx)

paoloinglese/SPUTNIK documentation built on April 18, 2024, 8:56 p.m.