knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Introduction

ms2sweeper is an R package designed to find and retreive ms/ms spectra within whenever available for a given feature for the analysis of metabolomics data. If multiple scans for a single are available, the program does its best to return the cleanest possible spectra.

The cleaning processes is designed to remove noise peaks from spectra that are there due to contamination from other peaks being coeluted within the isolation window or irreproducible secondary fragments.

Installation

To install this package, please type the following command into the R console:

#devtools::install_github("crmclean/ms2sweeper")

Hopefully in the future, this package will be distributed through either CRAN or Bioconductor.

Tutorial

library(ms2sweeper)

metadata <- read.csv("~/MIT/Research/MMETSP_Project/data/MMETSPsequencetrim.2017.2.11.csv",stringsAsFactors = F)
files <- metadata$File.Name[grep("*. pos \\(Hak\\)",as.character(metadata$Sample.Name),
                                 ignore.case = T)]
ms2dir <- "~/MIT/Research/MMETSP_Project/data/2017-12-21/all_ms2"
ms2Data <- list.files(ms2dir) 
dataIndex <- sapply(paste0(files, ".mzML"), grep, ms2Data) %>% unlist()
ms2Paths <- file.path(ms2dir, ms2Data[dataIndex])
features <- read.csv(here::here("lipid_table.csv"))    

outpath <- here::here("data/sweeperTest")
sweeper <- ms2sweeper::createSweeper(features, ms2Path = ms2Paths)
sweeper <- ms2sweeper::harvestMS2(sweeperObj = sweeper, clearData = FALSE)
temp <- alignMS2s(sweeperObj = sweeper, mzDiff = 0.1)
retreiveSpectra(sweeperObj = temp, outputPath = outpath)

Loading content needed to check for MS2 data.

lobDB$mz
frags[[2]][frags[[2]]$msLevel == 1,] %>% View()

ms2sweeper requires that the columns for exact mass and retention time for each feature be labeled as mz and rt respectively.

colnames(checkFeatures) <- c("mz", "rt") 
ms2sweeper::createSweeper(checkFeatures, files)


crmclean/ms2sweeper documentation built on May 22, 2019, 2:44 p.m.