R/data_conversion.R

Defines functions convertMSfile

## MetSyke : metabolomics data processing
## Author Dinesh Kumar Barupal dinkumar@ucdavis.edu
## License : MIT

####################
# Package loading ##
####################
library(doSNOW)
library(foreach)
library(readMzXmlData)

#############################################
### Convert raw data files to MZXML files. ##
#############################################

###
# The approach is one directory at the time. We process all the files in parellel within that directory.
###

convertMSfile <- function(
  datadir= "path/to/the/files", # Full path to the data location. If you are using RStudio, use the tab key to get the directory structure and to avoid typing the path.
  inputType = ".raw|.d|.wiff", # provide one of these types or any other
  numberOfCores = 2, # by default doSNOW will be performed on a 2 core cluster. But more COREs can be provided here to gain more speed.
  msConvertLocation = "C:/ProteoWizard/msconvert.exe" ## location of the MSconvert software. You can download it from the proteowizard and install it on your computer.
) {

  cl <- makeCluster(numberOfCores)
  registerDoSNOW(cl)
  foreach(k = dir(datadir)[grep(paste0(".",inputType,"$"),dir(datadir))],.verbose = TRUE) %dopar% {
    shell(paste0(msConvertLocation," ",datadir,k," -o ",datadir," --mzXML --zlib --filter \"peakPicking true [1,2] \" --filter \"msLevel 1-\""))
  }
  stopCluster(cl)
}

## Usage
# convertMSfile(datadir = datadir,inputType = "raw",numberOfCores = 6,msConvertLocation = "C:/ProteoWizard/msconvert.exe")
barupal/MetSkye documentation built on May 19, 2019, 1:46 a.m.