generated from jtr13/bookdown-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
00-File_converter.Rmd
74 lines (39 loc) · 1.71 KB
/
00-File_converter.Rmd
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
64
65
66
67
68
69
70
71
72
73
74
# File converter
The script `1.Pipeline_extension_format_converter.R` is available under the folder of `J:\CBMR\SUN-CBMR-Metabolomics\Workflow\Script\modules`
## Source paths on the server
```{r eval=FALSE}
source("J:/CBMR/SUN-CBMR-Metabolomics/Workflow_MS2/Scripts/utils/utils_MS2_set_up/set_up_paths.R")
```
## Specify the polarity 🕵
```{r eval=FALSE}
polarity <- "POS" #other options "NEG", "c("POS", "NEG")"
```
## Path of application of openms 🕵
```{r eval=FALSE}
path_openms <- "C:/Program Files/OpenMS-2.8.0/bin"
```
## Path of storing files (.mzML) exported from dataanalysis for each polarity 🕵
```{r eval=FALSE}
path_files_from_DA <- "H:/From_SUND/Scripts/test/MS2pos_untarget"
```
## Conduct
### Add extension (**if not available**) to files exported from dataanalysis
```{r eval=FALSE}
files_from_DA <- list.files(path_files_from_DA, full.names = TRUE)
id_not_ext <- setdiff(1:length(files_from_DA),
grep("\\.mzML$|\\.d$", basename(files_from_DA)))
if (length(id_not_ext) != 0) {
file.rename(files_from_DA[id_not_ext],
paste0(files_from_DA[id_not_ext], ".mzML")
)
}
```
### File converter for adapting to run XCMS
```{r eval=FALSE}
source(paste0(path_func, "/file-conversion.R"))
#Create a sibling folder for storing files from openms
path_files_from_openms <- paste0(dirname(path_files_from_DA), "/mzML_openms_MS2_", polarity)
if (!dir.exists(file.path(path_files_from_openms))) dir.create(path_files_from_openms, showWarnings = FALSE, recursive = TRUE)
#conduct converting
mapply(function(x, y) file_conversion(x,y, path_openms, ".mzML", ".mzML"), path_files_from_openms, path_files_from_DA)
```