knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  warning = FALSE,
  message = TRUE,
  out.width = "100%"
)

Some times if you have more than two batch peak tables, and they are processed at different times, so you need to align them together before other analysis. In metflow2, we use the align_batch() function to do that.

Data preparation

Peak table

The peak table (csv format) can be from any software. We recomment that you use the Peak_table_for_cleaning.csv from processData() function from metflow2.

If you use other software, please make sure that the top 3 columns are name (peak name), mz and rt (retention time, second). And the left column are sample intensity.

![](../man/figures/Screen Shot 2020-04-01 at 1.07.37 PM.png)

Sample information

We need the sample information (csv format) to define the detailed information of samples. Column 1 is sample.name, column 2 is injection.order, column 3 is class (such as Subject, QC, Blank), column 4 is batch and column 5 is group (such as control and case).

![](../man/figures/Screen Shot 2020-04-02 at 8.40.02 AM.png)

Read data

Then place the peak table and sample information in a folder. We use the demo data from demoData package.

library(metflow2)
library(demoData)
library(tidyverse)

Load demo data

##create a folder named as example
path <- file.path(".", "example")
dir.create(path = path, showWarnings = FALSE)
##get demo data
demo_data <- system.file("metflow2", package = "demoData")

file.copy(from = file.path(demo_data, dir(demo_data)), 
          to = path, overwrite = TRUE, recursive = TRUE)

Here, we have two peak tables, batch1.data.csv and batch2.data.csv, and sample_info.csv are in your ./example folder.

Creat metflowClass object

object <-
  create_metflow_object(
    ms1.data = c("batch1.data.csv", "batch2.data.csv"),
    sample.information = "sample_info.csv",
    path = path
  )

object is a metflowClass object, so you can print it in the console.

object

Run align_batch() function

object2 <- align_batch(object = object, 
            combine.mz.tol = 15, 
            combine.rt.tol = 30, 
            use.int.tol = FALSE)
object2


jaspershen/metflow2 documentation built on Aug. 15, 2021, 4:38 p.m.