This function adds MS2 data to a mass_dataset object. It reads MS2 files from a specified path, matches them with MS1 data in the object, and stores the matched MS2 data in the object.

mutate_ms2(
  object,
  column = c("rp", "hilic"),
  polarity = c("positive", "negative"),
  ms1.ms2.match.mz.tol = 15,
  ms1.ms2.match.rt.tol = 30,
  path = "."
)

Arguments

object

A mass_dataset object.

column

A character vector specifying the column types. Default is c("rp", "hilic").

polarity

A character vector specifying the polarity. Default is c("positive", "negative").

ms1.ms2.match.mz.tol

Numeric, the m/z tolerance for matching MS1 and MS2. Default is 15.

ms1.ms2.match.rt.tol

Numeric, the retention time tolerance for matching MS1 and MS2. Default is 30.

path

Character, the directory path where MS2 files are located. Default is the current directory.

Value

A modified mass_dataset object with added MS2 data.

Author

Xiaotao Shen shenxt1990@outlook.com

Examples

if (FALSE) {
  data("expression_data")
  data("sample_info")
  data("variable_info")
  object =
    create_mass_dataset(
      expression_data = expression_data,
      sample_info = sample_info,
      variable_info = variable_info,
    )
  
  object
  
  dir.create("demo_data")
  system.file("ms2_data", package = "metid")
  file.copy(
    file.path(
      system.file("ms2_data", package = "massdataset"),
      "QC_MS2_NCE25_1.mgf"
    ),
    to = "demo_data",
    overwrite = TRUE
  )
  
  object =
    mutate_ms2(object = object,
               column = "rp",
               polarity = "positive")
  
  object@ms2_data
}