Skip to contents

Divides each sample in a peak table or list of chromatograms by its value in a column of the sample metadata or of the peak table. For normalization by sample metadata, the metadata must first be attached to the peak_table using attach_metadata.

Usage

normalize_data(
  peak_table,
  column,
  chrom_list = NULL,
  what = c("peak_table", "chrom_list"),
  by = NULL,
  on_invalid = c("warn", "error", "silent")
)

Arguments

peak_table

A peak_table object.

column

The name of the column to be used for normalization.

chrom_list

List of chromatograms for normalization. Its names must match the sample names of the peak_table, in the same order. If omitted, it is retrieved using the name stored in the peak_table.

what

Output type to return: either "peak_table" (default) or "chrom_list".

by

Whether to normalize by a column in sample metadata ("meta") or by a column in the peak table ("peak"). By default, it is inferred from where column is found, and an error is raised if it is found in both.

on_invalid

How to handle invalid normalization values (i.e. zero, negative, or NA values). One of "warn" (the default), "silent", or "error". Invalid values are replaced with NA unless "error" is chosen.

Value

Either a normalized peak_table object or a normalized chrom_list, depending on the value of what.

Author

Ethan Bass

Examples

data(pk_tab)
path <- system.file("extdata", "Sa_metadata.csv", package = "chromatographR")
meta <- read.csv(path)

# normalize by sample mass
pk_tab <- attach_metadata(peak_table = pk_tab, metadata = meta, column="vial")
norm <- normalize_data(pk_tab, "mass", what = "peak_table")

# normalize by internal standard
norm <- normalize_data(pk_tab, column = "V14", by = "peak")