-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpeak_detection.R
40 lines (35 loc) · 1.09 KB
/
peak_detection.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
mzML_dir <- "/data/massspec/mzML"
out_dir <- "/data/massspec/RData2"
dir.create(out_dir, showWarnings = FALSE)
ncores <- Sys.getenv("SLURM_JOB_CPUS_PER_NODE", 3)
library(readxl)
library(xcms)
cwp <- CentWaveParam(
peakwidth = c(2, 20),
ppm = 50,
snthresh = 5,
mzdiff = 0.001,
prefilter = c(3, 500),
noise = 100,
integrate = 2)
mnp <- MergeNeighboringPeaksParam(
expandRt = 2,
expandMz = 0.001,
ppm = 10,
minProp = 0.66)
register(bpstart(MulticoreParam(ncores)))
fls <- read_xlsx(
"/home/jrainer/Projects/git/EuracBiomedicalResearch/metabo_chris_untargeted/data/chris-files-annotated.xlsx")
fls <- fls$mzML_file
peak_detection_for_file <- function(x){
require("xcms")
fname <- x
raw_data <- readMSData(files = paste0(mzML_dir, "/", fname),
mode = "onDisk")
xdata <- findChromPeaks(raw_data, param = cwp)
xdata <- refineChromPeaks(xdata, param = mnp)
tmp <- paste0(out_dir, "/", gsub(".mzML$", ".RData", fname))
dir.create(dirname(tmp), recursive = TRUE, showWarnings = FALSE)
save(xdata, file = tmp)
}
bplapply(fls, peak_detection_for_file)