-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_mzs.R
67 lines (35 loc) · 1.21 KB
/
get_mzs.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Helper script to extract a list of mz values from a list of files
library(xcms)
setwd("C:/Users/Lab/Desktop/Coding_Bits/VanKrevelen")
get_mzs <- function(in_file) {
xraw <- xcmsRaw(in_file)
peak_data <- findPeaks(xraw)
peak_data <- peak_data@.Data
peak_data[, 1]
}
files <- c(
"ACM_Feb6_244-pos.mzXML",
"ACM_Feb6_268-pos.mzXML",
"ACM_Feb6_277-pos.mzXML",
"ACM_Feb6_B2_255-pos.mzXML",
"ACM_Feb6_B2_274-pos.mzXML",
"ACM_Feb6_B3_270-pos.mzXML"
)
mzs <- lapply(files, get_mzs)
lapply(1:length(mzs), function(x){
write.table(mzs[x], file = paste(files[x], '.csv'), col.names = "mzs", row.names = F)
})
output <- unlist(mzs)
setwd("C:/Users/Lab/Desktop/Tissue_Spray_Final/Tri/Input/")
write.table(output, file = "Tri-pos-mzs.txt", row.names = F, col.names = F)
get_both_mzs <- function(in_file) {
xraw <- xcmsRaw(in_file)
peak_data <- findPeaks(xraw)
peak_data <- peak_data@.Data
peak_data[, 1]
}
#Single File
output <- get_mzs("ACM_sept16_T1R3_GL20_method1.mzXML")
setwd("C:/Users/Lab/Desktop")
write.table(output, file = "ACM_sept16_T1R3_GL20_method1.mzXML-mzs.txt", row.names = F, col.names = F)
setwd("C:/Users/Lab/Desktop/Coding_Bits/VanKrevelen")