filter_peaks_by_blank: Filter features by blank samples

View source: R/filters.R

filter_peaks_by_blankR Documentation

Filter features by blank samples

Description

Metabolomics datasets often contain many features of non-biological origin e.g. those associated with extraction and analysis solvents. This tool facilitates the removal of such features from the data matrix, as defined using an appropriate blank sample.

Usage

filter_peaks_by_blank(
  df,
  fold_change,
  classes,
  blank_label,
  qc_label = NULL,
  remove_samples = TRUE,
  remove_peaks = TRUE,
  fraction_in_blank = 0
)

Arguments

df

A matrix-like (e.g. an ordinary matrix, a data frame) or RangedSummarizedExperiment-class object with all values of class numeric() or integer() of peak intensities, areas or other quantitative characteristic.

fold_change

numeric(1), fold_change minimum fold change between analytical and blank samples.

classes

character(), vector of class labels. Must be the same length as the number of sample in the input peak table. If input is SummarizedExperiment object, use SummarizedExperiment_object$meta_data_column_name.

blank_label

character(1), class label used to identify blank samples.

qc_label

character(1) or NULL, class label used to identify QC samples.

remove_samples

logical(1), remove blank samples from peak matrix or not.

remove_peaks

logical(1), remove filtered features from peak matrix or not.

fraction_in_blank

numeric(1), value between 0 to 1 to specify fraction in how many blanks peaks should be present.

Details

If parameter qc_label is not NULL, QC samples which will be used to calculate the median signal intensity.

Value

Object of class SummarizedExperiment. If input data are a matrix-like (e.g. an ordinary matrix, a data frame) object, function returns numeric() matrix-like object of filtered data set. Function flags are added to the object attributes and is a DataFrame-class with five columns. The same DataFrame object containing flags is added to rowData() element of SummarizedExperiment object as well.

Columns in rowData() or flags element contain:
median_non_blanks median intensities of features of non-blank samples;
median_blanks median intensities of features of blank samples;
fold_change fold change between analytical and blank samples;
blank_flags integer(), if 0 feature is flagged to be removed;
blank_fraction_flags numeric(), fraction in how many blank samples peaks is present.

Examples

df <- MTBLS79[ ,MTBLS79$Batch == 1]
df$Class[1:2] <- "Blank"
out <- filter_peaks_by_blank(df=df, fold_change=1.2, 
   classes=df$Class, blank_label="Blank", qc_label=NULL, 
   remove_samples=FALSE, remove_peaks=TRUE, fraction_in_blank=0)


computational-metabolomics/pmp documentation built on March 9, 2024, 4:25 p.m.