correct_database_rt: Correct Retention Time (RT) in a Spectral Database

View source: R/11_rtCorrection.R

correct_database_rtR Documentation

Correct Retention Time (RT) in a Spectral Database

Description

This function corrects the retention time (RT) information in a spectral database using a reference table of internal standards from an experiment and a corresponding table from the database. The correction can be performed using different methods such as polynomial fitting or loess smoothing.

Usage

correct_database_rt(
  experiment.is.table,
  database.is.table,
  database,
  method = c("polyline", "loess"),
  poly = c(1, 2, 3, 4, 5),
  degree = c(1, 2),
  path = "."
)

Arguments

experiment.is.table

A data frame containing the internal standards (IS) information from the experiment. It should include columns for retention time (RT) and other relevant information.

database.is.table

A data frame containing the internal standards (IS) information from the database. It should include retention time (RT) values corresponding to the database spectra.

database

A 'databaseClass' object that contains the database to be corrected.

method

A character string specifying the method for RT correction. Options are '"polyline"' for polynomial fitting or '"loess"' for loess smoothing. Defaults to '"polyline"'.

poly

A numeric vector specifying the polynomial degrees to use for the correction when 'method = "polyline"'. Defaults to 'c(1, 2, 3, 4, 5)'.

degree

A numeric vector specifying the degree for loess smoothing when 'method = "loess"'. Defaults to 'c(1, 2)'.

path

A character string specifying the directory to save intermediate files. Defaults to the current directory ('"."').

Details

The function first writes a table of features from the database to a CSV file, which is used in the 'correct_rt' function to perform the retention time correction based on the provided internal standards tables. The corrected RT values are then updated in the 'databaseClass' object.

The 'method' parameter allows the user to choose between polynomial fitting ('"polyline"') and loess smoothing ('"loess"') for the RT correction. The 'poly' and 'degree' parameters specify the details of the polynomial or loess fitting, respectively.

Intermediate files generated during the process are saved in the directory specified by 'path', but are removed after use.

Value

A 'databaseClass' object with corrected RT values.

Author(s)

Xiaotao Shen xiaotao.shen@outlook.com

Examples

## Not run: 
# Correct RT in a database using polynomial fitting
corrected_db <- correct_database_rt(
  experiment.is.table = experiment_table,
  database.is.table = database_table,
  database = db_object,
  method = "polyline",
  poly = 1:3,
  degree = 2,
  path = "output_directory"
)

## End(Not run)



tidymass/metid documentation built on Oct. 8, 2024, 10:32 p.m.