aa_baseline_correction: Amino Acid Isotopic Baseline Correction

View source: R/aa_baseline_correction.R

aa_baseline_correctionR Documentation

Amino Acid Isotopic Baseline Correction

Description

Corrects isotopic ratios by subtracting a source amino acid baseline (e.g., Phe or Lys) to isolate trophic enrichment. Automatically handles both raw data and averaged (Mean/SD) data, applying exact quadrature error propagation for standard deviations.

Usage

aa_baseline_correction(
  data,
  references = "Phe",
  invert = "Thr",
  drop_ref = TRUE
)

Arguments

data

A data frame containing isotopic ratios.

references

Character vector of the amino acid(s) to use as the baseline. If multiple are provided (e.g., c("Phe", "Lys")), their row-wise mean is used.

invert

Character vector of amino acids that undergo inverse trophic fractionation (typically "Thr"). The baseline will be added to these instead of subtracted.

drop_ref

Logical. If TRUE, the reference AA columns are removed from the final dataset. Default is TRUE.

Value

A data.frame of the same class as data with baseline-corrected isotopic values. For raw datasets, ratios are updated in place; for averaged datasets, means and standard deviations are updated with propagated quadrature errors. If drop_ref = TRUE, columns corresponding to references are omitted.

Examples

# Example using raw isotopic ratio data
raw_df <- data.frame(
  R_Phe = c(5.1, 5.3, 5.0),
  R_Glu = c(15.2, 16.0, 15.5),
  R_Thr = c(-2.1, -2.5, -2.0)
)
aa_baseline_correction(raw_df, references = "Phe", invert = "Thr")


OceanTracer documentation built on Oct. 15, 2026, 5:09 p.m.