Mercurial > repos > workflow4metabolomics > ms2snoop
annotate MS2snoop.R @ 5:78d5a12406c2 draft
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
author | workflow4metabolomics |
---|---|
date | Fri, 05 Aug 2022 17:25:45 +0000 |
parents | 856001213966 |
children | 77abacd33c31 |
rev | line source |
---|---|
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
1 #' |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
2 #' read and process mspurity W4M files |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
3 #' create a summary of fragment for each precursor and a graphics of peseudo |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
4 #' spectra + correlation on which checking of fragment is based on |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
5 #' V3 try to identify and process multiple files for 1 precursor which may |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
6 #' occur if different collision energy are used |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
7 #' V4 elimination of correlation = NA. Correlation is done with precursor, if |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
8 #' precursor is not present correlation with most intense peak |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
9 #' author: Jean-Francois Martin |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
10 #' V5 is versionned, lintR-compliant, packaged, unit-tested, documented and |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
11 #' tested against data from other labs. |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
12 #' new maintainer: Lain Pavot - lain.pavot@inrae.fr |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
13 #' |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
14 #' @import optparse |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
15 #' |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
16 |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
17 |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
18 get_version <- function() { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
19 cmd <- commandArgs(trailingOnly = FALSE) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
20 root <- dirname(gsub("--file=", "", cmd[grep("--file=", cmd)])) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
21 readme <- readLines(file.path(root, "README.md")) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
22 version_line <- readme[grepl(" * **@version**: ", readme, fixed = TRUE)] |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
23 return(gsub(".*: ", "", version_line)) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
24 } |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
25 |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
26 defaults <- list( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
27 MS2SNOOP_VERSION = get_version(), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
28 MISSING_PARAMETER_ERROR = 1, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
29 BAD_PARAMETER_VALUE_ERROR = 2, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
30 MISSING_INPUT_FILE_ERROR = 3, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
31 NO_ANY_RESULT_ERROR = 255, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
32 DEFAULT_PRECURSOR_PATH = NULL, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
33 DEFAULT_FRAGMENTS_PATH = NULL, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
34 DEFAULT_COMPOUNDS_PATH = NULL, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
35 DEFAULT_OUTPUT_PATH = "compound_fragments_result.txt", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
36 DEFAULT_TOLMZ = 0.01, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
37 DEFAULT_TOLRT = 20, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
38 DEFAULT_MZDECIMAL = 3, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
39 DEFAULT_R_THRESHOLD = 0.85, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
40 DEFAULT_MINNUMBERSCAN = 8, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
41 DEFAULT_SEUIL_RA = 0.05, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
42 DEFAULT_FRAGMENTS_MATCH_DELTA = 10, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
43 DEFAULT_FRAGMENTS_MATCH_DELTA_UNIT = "ppm", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
44 DEFAULT_PDF_PATH = "" |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
45 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
46 env <- globalenv() |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
47 for (default in names(defaults)) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
48 assign(default, defaults[[default]], envir = env) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
49 lockBinding(default, env) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
50 } |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
51 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
52 ######################################################################## |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
53 |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
54 get_formulas <- function( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
55 mzref, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
56 spectra, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
57 nominal_mz_list, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
58 processing_parameters, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
59 background = !TRUE |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
60 ) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
61 if (is.vector(mzref) && length(mzref) > 1) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
62 return(lapply( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
63 mzref, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
64 function(mz) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
65 return(get_formulas( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
66 mzref = mz, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
67 spectra = spectra, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
68 nominal_mz_list = nominal_mz_list, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
69 processing_parameters = processing_parameters, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
70 background = background |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
71 )) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
72 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
73 )) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
74 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
75 input <- sprintf( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
76 "%s-%s.ms", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
77 gsub("[[:space:]]", "_", processing_parameters$c_name), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
78 mzref |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
79 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
80 create_ms_file(input, mzref, spectra, processing_parameters) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
81 output <- sprintf( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
82 "out/%s-%s.out", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
83 gsub("[[:space:]]", "_", processing_parameters$c_name), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
84 mzref |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
85 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
86 command <- sprintf( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
87 paste( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
88 "sirius", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
89 "--noCite", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
90 "--noSummaries", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
91 "--loglevel=WARNING", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
92 "-i='%s'", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
93 "-o='%s'", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
94 "tree", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
95 ## loglevel is not working taken into account during |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
96 ## sirius startup, so we filter outputs... |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
97 "2>&1 | grep '^(WARNING|SEVERE)'" |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
98 ), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
99 input, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
100 output |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
101 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
102 verbose_catf( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
103 ">> Sirius is running %swith the command: %s\n", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
104 if (background) "in the background " else "", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
105 command |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
106 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
107 system( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
108 command, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
109 wait = !background, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
110 ignore.stdout = background, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
111 ignore.stderr = background |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
112 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
113 return(extract_sirius_results(output, spectra$mz, processing_parameters)) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
114 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
115 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
116 create_ms_file <- function( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
117 path, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
118 mzref, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
119 spectra, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
120 processing_parameters |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
121 ) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
122 file_content <- paste( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
123 sprintf(">compound %s", processing_parameters$c_name), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
124 sprintf(">ionization %s", processing_parameters$ionization), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
125 sprintf(">parentmass %s", mzref), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
126 sprintf(">formula %s", processing_parameters$elemcomposition), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
127 sep = "\n" |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
128 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
129 displayed_file_content <- sprintf( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
130 "%s\n>collision\n%s", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
131 file_content, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
132 paste( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
133 sprintf( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
134 "%s %s", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
135 spectra[1:3, "mz"], |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
136 spectra[1:3, "intensities"] |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
137 ), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
138 collapse = "\n" |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
139 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
140 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
141 if (nrow(spectra) > 3) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
142 displayed_file_content <- sprintf( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
143 "%s\n[... %s more rows of mz and intensities ...]", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
144 displayed_file_content, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
145 nrow(spectra) - 3 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
146 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
147 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
148 catf( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
149 ">> MS file created for %s with content:\n%s\n", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
150 processing_parameters$c_name, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
151 displayed_file_content |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
152 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
153 file_content <- sprintf( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
154 "%s\n\n>collision\n%s", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
155 file_content, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
156 paste( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
157 sprintf("%s %s", spectra$mz, spectra$intensities), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
158 collapse = "\n" |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
159 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
160 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
161 cat(file_content, file = path, append = FALSE) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
162 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
163 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
164 extract_sirius_results <- function( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
165 output, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
166 mz_list, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
167 processing_parameters |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
168 ) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
169 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
170 delta <- processing_parameters$fragment_match_delta |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
171 delta_unit <- tolower(processing_parameters$fragment_match_delta_unit) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
172 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
173 output <- list.dirs(output, recursive = FALSE)[[1]] |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
174 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
175 spectra_out_dir <- sprintf("%s/spectra", output) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
176 spectra_filename <- sprintf( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
177 "%s/%s", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
178 spectra_out_dir, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
179 list.files(spectra_out_dir)[[1]] |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
180 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
181 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
182 trees_out_dir <- sprintf("%s/trees", output) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
183 trees_filename <- sprintf( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
184 "%s/%s", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
185 trees_out_dir, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
186 list.files(trees_out_dir)[[1]] |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
187 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
188 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
189 if (!is.null(spectra_filename)) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
190 sirius_results <- get_csv_or_tsv(spectra_filename) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
191 } else { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
192 return(rep(NA, length(mz_list))) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
193 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
194 if (!is.null(trees_filename)) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
195 sirius_results <- cbind(sirius_results, extract_sirius_ppm(trees_filename)) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
196 } else { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
197 return(rep(NA, length(mz_list))) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
198 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
199 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
200 fragment_matchings <- data.frame( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
201 formula = NA, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
202 ppm = NA, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
203 mz = mz_list, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
204 error = NA |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
205 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
206 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
207 sirius_results <- filter_sirius_with_delta( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
208 sirius_results = sirius_results, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
209 original_mz = fragment_matchings$mz, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
210 delta = delta, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
211 delta_unit = delta_unit |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
212 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
213 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
214 for (index in seq_len(nrow(sirius_results))) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
215 result <- sirius_results[index, ] |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
216 filter <- which(order(abs(fragment_matchings$mz - result$mz)) == 1) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
217 fragment_matchings[filter, "formula"] <- result$formula |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
218 fragment_matchings[filter, "ppm"] <- result$ppm |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
219 catf( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
220 "[OK] Fragment with m/z=%s matches %s with a difference of %s ppm\n", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
221 fragment_matchings[filter, "mz"], result$formula, result$ppm |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
222 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
223 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
224 return(fragment_matchings) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
225 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
226 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
227 filter_sirius_with_delta <- function( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
228 sirius_results, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
229 original_mz, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
230 delta, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
231 delta_unit |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
232 ) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
233 if (is.numeric(delta) && !is.na(delta) && delta > 0) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
234 if (delta_unit == "ppm") { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
235 filter <- abs(sirius_results$ppm) <= delta |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
236 fine <- which(filter) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
237 not_fine <- which(!filter) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
238 catf( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
239 paste("[KO] fragment %s (m/z=%s) eleminated because ppm=%s is greater", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
240 "than delta=%s\n" |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
241 ), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
242 sirius_results[not_fine, ]$formula, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
243 sirius_results[not_fine, ]$mz, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
244 sirius_results[not_fine, ]$ppm, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
245 delta |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
246 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
247 sirius_results <- sirius_results[fine, ] |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
248 } else if (delta_unit == "mz") { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
249 differences <- sapply( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
250 sirius_results$mz, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
251 function(mz) min(abs(original_mz - mz)) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
252 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
253 fine <- which(sapply( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
254 sirius_results$mz, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
255 function(mz) any(abs(original_mz - mz) <= delta) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
256 )) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
257 not_fine <- which(sapply( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
258 sirius_results$mz, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
259 function(mz) all(abs(original_mz - mz) > delta) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
260 )) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
261 catf( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
262 paste( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
263 "[KO] fragment %s eleminated because mz difference=%s is", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
264 "greater than delta=%s\n" |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
265 ), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
266 sirius_results[not_fine, ]$formula, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
267 differences[not_fine], |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
268 delta |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
269 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
270 sirius_results <- sirius_results[fine, ] |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
271 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
272 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
273 return(sirius_results) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
274 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
275 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
276 extract_sirius_ppm <- function(path) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
277 json <- file(path, "r") |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
278 suppressWarnings(json_lines <- readLines(json)) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
279 close(json) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
280 json_lines <- json_lines[ |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
281 grepl("\\s+\"(massDeviation|recalibratedMass)\" :", json_lines) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
282 ] |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
283 json_lines <- gsub("^\\s+\"[^\"]+\" : \"?", "", json_lines) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
284 ppms <- json_lines[seq(1, length(json_lines), 2)] |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
285 mz <- json_lines[seq(2, length(json_lines), 2)] |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
286 ppms <- as.numeric(gsub(" ppm .*", "", ppms)) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
287 mz <- as.numeric(gsub(",$", "", mz)) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
288 ordered <- order(mz) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
289 return(list(ppm = ppms[ordered], recalibrated_mz = mz[ordered])) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
290 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
291 |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
292 #' @title plot_pseudo_spectra |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
293 #' @param x |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
294 #' @param fid |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
295 #' @param sum_int |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
296 #' @param vmz |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
297 #' @param cor_abs_int |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
298 #' @param refcol |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
299 #' @param c_name |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
300 #' @description plot_pseudo_spectra |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
301 #' function to compute sum of intensities among scans for all |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
302 #' m/z kept (cor > r_threshold & minimum number of scans) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
303 #' and plot pseudo spectra |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
304 #' x dataframe scan X fragments with scans number in the 1st column and |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
305 #' ions in next with intensities |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
306 #' fid file id when several a precursor has been detected in several files |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
307 plot_pseudo_spectra <- function( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
308 x, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
309 fid, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
310 sum_int, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
311 vmz, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
312 cor_abs_int, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
313 refcol, |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
314 meaned_mz, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
315 processing_parameters |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
316 ) { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
317 ## du fait de la difference de nombre de colonne entre la dataframe qui |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
318 ## inclue les scans en 1ere col, mzRef se decale de 1 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
319 refcol <- refcol - 1 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
320 ## compute relative intensities max=100% |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
321 rel_int <- sum_int[-1] |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
322 rel_int <- rel_int / max(rel_int) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
323 |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
324 if (processing_parameters$do_pdf) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
325 ## define max value on vertical axis (need to increase in order to plot the |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
326 ## label of fragments) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
327 ymax <- max(rel_int) + 0.2 * max(rel_int) |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
328 |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
329 par(mfrow = c(2, 1)) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
330 plot(vmz, rel_int, type = "h", ylim = c(0, ymax), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
331 main = processing_parameters$c_name |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
332 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
333 ## low correl coef. will be display in grey |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
334 cor_low <- which(round(cor_abs_int, 2) < processing_parameters$r_threshold) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
335 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
336 lbmzcor <- sprintf("%s(r=%s)", vmz, round(cor_abs_int, 2)) |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
337 |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
338 if (length(cor_low) > 0) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
339 text( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
340 vmz[cor_low], |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
341 rel_int[cor_low], |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
342 lbmzcor[cor_low], |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
343 cex = 0.5, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
344 col = "grey", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
345 srt = 90, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
346 adj = 0 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
347 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
348 if (length(vmz) - length(cor_low) > 1) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
349 text( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
350 vmz[-c(refcol, cor_low)], |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
351 rel_int[-c(refcol, cor_low)], |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
352 lbmzcor[-c(refcol, cor_low)], |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
353 cex = 0.6, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
354 col = 1, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
355 srt = 90, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
356 adj = 0 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
357 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
358 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
359 } else { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
360 if (length(vmz) > 1) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
361 text( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
362 vmz[-c(refcol)], |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
363 rel_int[-c(refcol)], |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
364 lbmzcor[-c(refcol)], |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
365 cex = 0.6, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
366 col = 1, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
367 srt = 90, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
368 adj = 0 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
369 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
370 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
371 } |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
372 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
373 text( |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
374 vmz[refcol], |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
375 rel_int[refcol], |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
376 lbmzcor[refcol], |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
377 cex = 0.8, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
378 col = 2, |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
379 srt = 90, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
380 adj = 0 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
381 ) |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
382 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
383 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
384 ## prepare result file |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
385 cor_valid <- (round(cor_abs_int, 2) >= processing_parameters$r_threshold) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
386 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
387 do_sirius <- TRUE |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
388 verbose_catf("Checking sirius parameters...\n") |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
389 if (is.null(processing_parameters$ionization)) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
390 do_sirius <- FALSE |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
391 verbose_catf("[KO] No ionization passed in parameter.\n") |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
392 } else { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
393 verbose_catf("[OK] Ionization=%s.\n", processing_parameters$ionization) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
394 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
395 if (is.na(processing_parameters$elemcomposition)) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
396 do_sirius <- FALSE |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
397 verbose_catf("[KO] Elemental composition is NA.\n") |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
398 } else if (length(processing_parameters$elemcomposition) < 1) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
399 do_sirius <- FALSE |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
400 verbose_catf("[KO] No elemental composition is provided.\n") |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
401 } else if (processing_parameters$elemcomposition == "") { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
402 do_sirius <- FALSE |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
403 verbose_catf("[KO] Elemental composition is an empty string.\n") |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
404 } else { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
405 verbose_catf( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
406 "[OK] Elemental composition=%s.\n", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
407 processing_parameters$elemcomposition |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
408 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
409 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
410 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
411 cp_res_length <- length(vmz) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
412 ppm <- rep(NA, cp_res_length) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
413 formulas <- rep(NA, cp_res_length) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
414 if (do_sirius) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
415 verbose_catf("Everything is ok, preparing for sirius.\n") |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
416 formulas <- get_formulas( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
417 mzref = processing_parameters$mzref, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
418 spectra = data.frame(mz = meaned_mz, intensities = sum_int[-1]), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
419 nominal_mz_list = vmz, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
420 processing_parameters = processing_parameters |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
421 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
422 if (nrow(formulas) == 0) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
423 catf("No formula found.\n") |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
424 } else { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
425 ppm <- formulas$ppm |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
426 formulas <- formulas$formula |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
427 catf( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
428 "Found %s formula for %s fragments\n", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
429 length(formulas[which(!(is.na(formulas)))]), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
430 cp_res_length |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
431 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
432 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
433 } else { |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
434 verbose_catf("Sirius cannot be run.\n") |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
435 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
436 cp_res <- data.frame( |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
437 rep(processing_parameters$c_name, cp_res_length), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
438 rep(processing_parameters$inchikey, cp_res_length), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
439 rep(processing_parameters$elemcomposition, cp_res_length), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
440 formulas, |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
441 vmz, |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
442 ppm, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
443 rep(fid, cp_res_length), |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
444 cor_abs_int, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
445 sum_int[-1], |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
446 rel_int, |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
447 cor_valid |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
448 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
449 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
450 colnames(cp_res) <- c( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
451 "compoundName", |
4
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
452 "inchikey", |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
453 "elemcomposition", |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
454 "fragment", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
455 "fragment_mz", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
456 "ppm", |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
457 "fileid", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
458 "CorWithPrecursor", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
459 "AbsoluteIntensity", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
460 "relativeIntensity", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
461 "corValid" |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
462 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
463 return(cp_res) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
464 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
465 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
466 #' |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
467 #' @title extract_fragments |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
468 #' |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
469 #' @param precursors the precursor list from mspurity |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
470 #' @param fragments the fragments list from ms purity |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
471 # ' @param mzref |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
472 # ' @param rtref |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
473 # ' @param c_name |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
474 # ' @param inchikey |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
475 # ' @param elemcomposition |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
476 #' @param processing_parameters |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
477 #' @returns |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
478 #' |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
479 #' @description |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
480 #' function for extraction of fragments corresponding to precursors |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
481 #' detected by MSPurity |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
482 extract_fragments <- function( ## nolint cyclocomp_linter |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
483 precursors, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
484 fragments, |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
485 processing_parameters |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
486 ) { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
487 ## filter precursor in the precursors file based on mz and rt in the |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
488 ## compound list |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
489 catf("processing %s\n", processing_parameters$c_name) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
490 verbose_catf("===\n") |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
491 param <- processing_parameters |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
492 selected_precursors <- which( |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
493 (abs(precursors$precurMtchMZ - param$mzref) <= param$tolmz) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
494 & (abs(precursors$precurMtchRT - param$rtref) <= param$tolrt) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
495 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
496 rm(param) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
497 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
498 verbose_catf( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
499 "> %s precursors selected with mz=%s±%s and rt=%s±%s\n", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
500 length(selected_precursors), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
501 processing_parameters$mzref, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
502 processing_parameters$tolmz, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
503 processing_parameters$rtref, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
504 processing_parameters$tolrt |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
505 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
506 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
507 ## check if there is the precursor in the file |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
508 |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
509 if (length(selected_precursors) < 1) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
510 cat("> non detected in precursor file\n") |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
511 show_end_processing() |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
512 return(NULL) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
513 } |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
514 |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
515 precursors <- precursors[selected_precursors, ] |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
516 |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
517 ## check if fragments corresponding to precursor are found in several |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
518 ## files (collision energy) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
519 ## this lead to a processing for each fileid |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
520 file_ids <- as.character(sort(unique(precursors$fileid))) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
521 if (length(file_ids) > 1) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
522 catf("> several files detected for this compounds :\n") |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
523 } else if (length(file_ids) < 1 || nrow(precursors) < 1) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
524 return(data.frame()) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
525 } |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
526 |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
527 res_comp <- data.frame() |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
528 for (curent_file_id in file_ids) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
529 curent_precursors <- precursors[precursors$fileid == curent_file_id, ] |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
530 selected_fragments <- fragments[ |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
531 fragments$grpid %in% as.character(curent_precursors$grpid) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
532 & fragments$fileid == curent_file_id, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
533 ] |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
534 filtered_fragments <- selected_fragments[ |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
535 selected_fragments$ra > processing_parameters$seuil_ra, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
536 ] |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
537 if (nrow(filtered_fragments) != 0) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
538 res_comp_by_file <- process_file( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
539 curent_file_id = curent_file_id, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
540 precursor_mz = curent_precursors$mz, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
541 filtered_fragments = filtered_fragments, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
542 processing_parameters = processing_parameters |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
543 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
544 if (!is.null(res_comp_by_file)) { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
545 res_comp <- rbind(res_comp, res_comp_by_file) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
546 } |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
547 } else { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
548 catf("No fragment found for in fragment file\n") |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
549 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
550 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
551 return(unique(res_comp)) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
552 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
553 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
554 process_file <- function( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
555 curent_file_id, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
556 precursor_mz, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
557 filtered_fragments, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
558 processing_parameters |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
559 ) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
560 mznominal <- round(x = filtered_fragments$mz, digits = 0) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
561 meaned_mz <- round( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
562 aggregate( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
563 data.frame( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
564 mz = filtered_fragments$mz, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
565 mznominal = mznominal |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
566 ), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
567 list(mznominal), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
568 FUN = mean |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
569 )$mz, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
570 digits = processing_parameters$mzdecimal |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
571 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
572 filtered_fragments <- data.frame(filtered_fragments, mznominal) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
573 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
574 ## creation of cross table row=scan col=mz X=ra |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
575 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
576 vmz <- as.character(sort(unique(filtered_fragments$mznominal))) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
577 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
578 ds_abs_int <- create_ds_abs_int(vmz, filtered_fragments) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
579 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
580 if (global_debug) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
581 print(ds_abs_int) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
582 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
583 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
584 ## elimination of mz with less than min_number_scan scans (user defined |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
585 ## parameter) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
586 xmz <- rep(NA, ncol(ds_abs_int) - 1) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
587 sum_int <- rep(NA, ncol(ds_abs_int)) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
588 nbxmz <- 0 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
589 nb_scan_check <- min(nrow(ds_abs_int), processing_parameters$min_number_scan) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
590 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
591 for (j in 2:ncol(ds_abs_int)) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
592 sum_int[j] <- sum(ds_abs_int[j], na.rm = TRUE) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
593 if (sum(!is.na(ds_abs_int[[j]])) < nb_scan_check) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
594 nbxmz <- nbxmz + 1 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
595 xmz[nbxmz] <- j |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
596 } |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
597 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
598 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
599 xmz <- xmz[-which(is.na(xmz))] |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
600 if (length(xmz) > 0) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
601 ds_abs_int <- ds_abs_int[, -c(xmz)] |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
602 sum_int <- sum_int[-c(xmz)] |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
603 ## liste des mz keeped decale de 1 avec ds_abs_int |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
604 vmz <- as.numeric(vmz[-c(xmz - 1)]) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
605 meaned_mz <- meaned_mz[-c(xmz - 1)] |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
606 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
607 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
608 ## mz of precursor in data precursor to check correlation with |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
609 mz_prec <- paste0( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
610 "mz", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
611 round(mean(precursor_mz), processing_parameters$mzdecimal) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
612 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
613 ## reference ion for correlation computing = precursor OR maximum |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
614 ## intensity ion in precursor is not present |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
615 refcol <- which(colnames(ds_abs_int) == mz_prec) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
616 if (length(refcol) == 0) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
617 refcol <- which(sum_int == max(sum_int, na.rm = TRUE)) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
618 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
619 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
620 if (processing_parameters$do_pdf) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
621 start_pdf(processing_parameters, curent_file_id) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
622 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
623 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
624 ## Pearson correlations between absolute intensities computing |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
625 cor_abs_int <- rep(NA, length(vmz)) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
626 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
627 if (length(refcol) > 0) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
628 for (i in 2:length(ds_abs_int)) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
629 cor_abs_int[i - 1] <- stats::cor( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
630 x = ds_abs_int[[refcol]], |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
631 y = ds_abs_int[[i]], |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
632 use = "pairwise.complete.obs", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
633 method = "pearson" |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
634 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
635 debug_catf( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
636 "Correlation between %s and %s: %s\n", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
637 paste(ds_abs_int[[refcol]], collapse = ";"), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
638 paste(ds_abs_int[[i]], collapse = ";"), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
639 paste(cor_abs_int[i - 1], collapse = ";") |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
640 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
641 if (processing_parameters$do_pdf) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
642 pdf_plot_ds_abs_int( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
643 processing_parameters$c_name, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
644 ds_abs_int, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
645 refcol, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
646 i, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
647 round(cor_abs_int[i - 1], 2) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
648 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
649 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
650 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
651 ## plot pseudo spectra |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
652 res_comp_by_file <- plot_pseudo_spectra( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
653 x = ds_abs_int, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
654 fid = curent_file_id, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
655 sum_int = sum_int, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
656 vmz = vmz, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
657 cor_abs_int = cor_abs_int, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
658 refcol = refcol, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
659 meaned_mz = meaned_mz, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
660 processing_parameters = processing_parameters |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
661 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
662 catf( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
663 "%s has been processed and %s fragments have been found.\n", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
664 processing_parameters$c_name, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
665 nrow(res_comp_by_file) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
666 ) |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
667 } else { |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
668 res_comp_by_file <- NULL |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
669 cat(">> non detected in fragments file \n") |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
670 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
671 show_end_processing() |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
672 if (processing_parameters$do_pdf) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
673 end_pdf() |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
674 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
675 return(res_comp_by_file) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
676 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
677 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
678 create_ds_abs_int <- function(vmz, filtered_fragments) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
679 verbose_catf( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
680 ">> fragments: %s\n", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
681 paste(vmz, collapse = " ") |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
682 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
683 ds_abs_int <- create_int_mz(vmz[1], filtered_fragments) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
684 for (mz in vmz[-1]) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
685 int_mz <- create_int_mz(mz, filtered_fragments) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
686 ds_abs_int <- merge( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
687 x = ds_abs_int, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
688 y = int_mz, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
689 by.x = 1, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
690 by.y = 1, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
691 all.x = TRUE, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
692 all.y = TRUE |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
693 ) |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
694 } |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
695 return(ds_abs_int) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
696 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
697 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
698 create_int_mz <- function(mz, filtered_fragments) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
699 ## absolute intensity |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
700 int_mz <- filtered_fragments[ |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
701 filtered_fragments$mznominal == mz, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
702 c("acquisitionNum", "i") |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
703 ] |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
704 colnames(int_mz)[2] <- paste0("mz", mz) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
705 ## average intensities of mass in duplicate scans |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
706 comp_scans <- aggregate(x = int_mz, by = list(int_mz[[1]]), FUN = mean) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
707 return(comp_scans[, -1]) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
708 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
709 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
710 show_end_processing <- function() { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
711 verbose_catf("==========\n") |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
712 cat("\n") |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
713 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
714 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
715 start_pdf <- function(processing_parameters, curent_file_id) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
716 if (!dir.exists(processing_parameters$pdf_path)) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
717 dir.create(processing_parameters$pdf_path, recursive = TRUE) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
718 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
719 pdf( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
720 file = sprintf( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
721 "%s/%s_processing_file%s.pdf", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
722 processing_parameters$pdf_path, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
723 processing_parameters$c_name, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
724 curent_file_id |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
725 ), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
726 width = 8, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
727 height = 11 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
728 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
729 par(mfrow = c(3, 2)) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
730 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
731 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
732 pdf_plot_ds_abs_int <- function(c_name, ds_abs_int, refcol, i, r_coef) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
733 plot( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
734 ds_abs_int[[refcol]], |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
735 ds_abs_int[[i]], |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
736 xlab = colnames(ds_abs_int)[refcol], |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
737 ylab = colnames(ds_abs_int)[i], |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
738 main = sprintf( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
739 "%s corr coeff r=%s", c_name, r_coef |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
740 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
741 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
742 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
743 end_pdf <- function() { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
744 dev.off() |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
745 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
746 |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
747 set_global <- function(var, value) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
748 assign(var, value, envir = globalenv()) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
749 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
750 |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
751 set_debug <- function() { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
752 set_global("global_debug", TRUE) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
753 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
754 |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
755 unset_debug <- function() { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
756 set_global("global_debug", FALSE) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
757 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
758 |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
759 set_verbose <- function() { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
760 set_global("global_verbose", TRUE) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
761 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
762 |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
763 unset_verbose <- function() { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
764 set_global("global_verbose", FALSE) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
765 } |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
766 |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
767 verbose_catf <- function(...) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
768 if (global_verbose) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
769 cat(sprintf(...), sep = "") |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
770 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
771 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
772 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
773 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
774 debug_catf <- function(...) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
775 if (global_debug) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
776 cat(sprintf(...), sep = "") |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
777 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
778 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
779 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
780 catf <- function(...) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
781 cat(sprintf(...), sep = "") |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
782 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
783 |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
784 create_parser <- function() { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
785 parser <- optparse::OptionParser() |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
786 parser <- optparse::add_option( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
787 parser, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
788 c("-v", "--verbose"), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
789 action = "store_true", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
790 default = FALSE, |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
791 help = paste( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
792 "[default %default]", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
793 "Print extra output" |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
794 ) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
795 ) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
796 parser <- optparse::add_option( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
797 parser, |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
798 c("-V", "--version"), |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
799 action = "store_true", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
800 default = FALSE, |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
801 help = "Prints version and exits" |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
802 ) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
803 parser <- optparse::add_option( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
804 parser, |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
805 c("-d", "--debug"), |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
806 action = "store_true", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
807 default = FALSE, |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
808 help = paste( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
809 "[default %default]", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
810 "Print debug outputs" |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
811 ) |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
812 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
813 parser <- optparse::add_option( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
814 parser, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
815 c("-o", "--output"), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
816 type = "character", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
817 default = DEFAULT_OUTPUT_PATH, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
818 action = "store", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
819 help = "Path to the output file [default %default]" |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
820 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
821 parser <- optparse::add_option( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
822 parser, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
823 c("-p", "--precursors"), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
824 type = "character", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
825 default = DEFAULT_PRECURSOR_PATH, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
826 action = "store", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
827 help = "Path to the precursors file [default %default]" |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
828 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
829 parser <- optparse::add_option( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
830 parser, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
831 c("-f", "--fragments"), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
832 type = "character", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
833 default = DEFAULT_FRAGMENTS_PATH, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
834 action = "store", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
835 help = "Path to the fragments file [default %default]" |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
836 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
837 parser <- optparse::add_option( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
838 parser, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
839 c("-c", "--compounds"), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
840 type = "character", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
841 default = DEFAULT_COMPOUNDS_PATH, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
842 action = "store", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
843 help = "Path to the compounds file [default %default]" |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
844 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
845 parser <- optparse::add_option( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
846 parser, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
847 c("--tolmz"), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
848 type = "numeric", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
849 action = "store", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
850 default = DEFAULT_TOLMZ, |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
851 metavar = "number", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
852 help = paste( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
853 "[default %default]", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
854 "Tolerance for MZ (in Dalton) to match the standard in the compounds" |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
855 ) |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
856 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
857 parser <- optparse::add_option( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
858 parser, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
859 c("--tolrt"), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
860 type = "integer", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
861 action = "store", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
862 default = DEFAULT_TOLRT, |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
863 metavar = "number", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
864 help = paste( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
865 "[default %default]", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
866 "RT (in seconds) to match the standard in the compounds" |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
867 ) |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
868 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
869 parser <- optparse::add_option( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
870 parser, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
871 c("--seuil_ra"), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
872 type = "numeric", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
873 action = "store", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
874 default = DEFAULT_SEUIL_RA, |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
875 metavar = "number", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
876 help = paste( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
877 "[default %default]", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
878 "relative intensity threshold" |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
879 ), |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
880 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
881 parser <- optparse::add_option( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
882 parser, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
883 c("--mzdecimal"), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
884 type = "integer", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
885 default = DEFAULT_MZDECIMAL, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
886 action = "store", |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
887 help = paste( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
888 "[default %default]", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
889 "Number of decimal to write for MZ" |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
890 ), |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
891 metavar = "number" |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
892 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
893 parser <- optparse::add_option( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
894 parser, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
895 c("--r_threshold"), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
896 type = "integer", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
897 default = DEFAULT_R_THRESHOLD, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
898 action = "store", |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
899 help = paste( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
900 "[default %default]", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
901 "R-Pearson correlation threshold between precursor and fragment", |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
902 "absolute intensity" |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
903 ), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
904 metavar = "number" |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
905 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
906 parser <- optparse::add_option( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
907 parser, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
908 c("--min_number_scan"), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
909 type = "numeric", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
910 action = "store", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
911 default = DEFAULT_MINNUMBERSCAN, |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
912 help = paste( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
913 "[default %default]", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
914 "Fragments are kept if there are found in a minimum number", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
915 "of min_number_scan scans" |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
916 ), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
917 metavar = "number" |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
918 ) |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
919 parser <- optparse::add_option( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
920 parser, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
921 c("--pdf_path"), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
922 type = "character", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
923 default = DEFAULT_PDF_PATH, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
924 help = paste( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
925 "[default %default]", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
926 "PDF files output path" |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
927 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
928 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
929 parser <- optparse::add_option( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
930 parser, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
931 c("--ionization"), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
932 type = "character", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
933 action = "store", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
934 default = "None", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
935 help = paste( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
936 "[default %default]", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
937 "Which ionization to use for sirius" |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
938 ), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
939 metavar = "character" |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
940 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
941 parser <- optparse::add_option( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
942 parser, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
943 c("--fragment_match_delta"), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
944 type = "numeric", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
945 action = "store", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
946 default = DEFAULT_FRAGMENTS_MATCH_DELTA, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
947 help = paste( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
948 "[default %default]", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
949 "Fragment match delta" |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
950 ), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
951 metavar = "numeric" |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
952 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
953 parser <- optparse::add_option( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
954 parser, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
955 c("--fragment_match_delta_unit"), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
956 type = "character", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
957 action = "store", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
958 default = DEFAULT_FRAGMENTS_MATCH_DELTA_UNIT, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
959 help = paste( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
960 "[default %default]", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
961 "Fragment match delta" |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
962 ), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
963 metavar = "character" |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
964 ) |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
965 return(parser) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
966 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
967 |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
968 stop_with_status <- function(msg, status) { |
4
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
969 sink(stderr()) |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
970 message(sprintf("Error: %s", msg)) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
971 message(sprintf("Error code: %s", status)) |
4
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
972 sink(NULL) |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
973 base::quit(status = status) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
974 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
975 |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
976 check_args_validity <- function(args) { ## nolint cyclocomp_linter |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
977 if (length(args$output) == 0 || nchar(args$output[1]) == 0) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
978 stop_with_status( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
979 "Missing output parameters. Please set it with --output.", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
980 MISSING_PARAMETER_ERROR |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
981 ) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
982 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
983 if (length(args$precursors) == 0 || nchar(args$precursors[1]) == 0) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
984 stop_with_status( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
985 "Missing precursors parameters. Please set it with --precursors.", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
986 MISSING_PARAMETER_ERROR |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
987 ) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
988 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
989 if (length(args$fragments) == 0 || nchar(args$fragments[1]) == 0) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
990 stop_with_status( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
991 "Missing fragments parameters. Please set it with --fragments.", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
992 MISSING_PARAMETER_ERROR |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
993 ) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
994 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
995 if (length(args$compounds) == 0 || nchar(args$compounds[1]) == 0) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
996 stop_with_status( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
997 "Missing compounds parameters. Please set it with --compounds.", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
998 MISSING_PARAMETER_ERROR |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
999 ) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1000 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1001 if (!file.exists(args$precursors)) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1002 stop_with_status( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1003 sprintf( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1004 "Precursors file %s does not exist or cannot be accessed.", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1005 args$precursors |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1006 ), |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1007 MISSING_INPUT_FILE_ERROR |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1008 ) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1009 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1010 if (!file.exists(args$fragments)) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1011 stop_with_status( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1012 sprintf( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1013 "Fragments file %s does not exist or cannot be accessed.", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1014 args$fragments |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1015 ), |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1016 MISSING_INPUT_FILE_ERROR |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1017 ) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1018 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1019 if (!file.exists(args$compounds)) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1020 stop_with_status( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1021 sprintf( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1022 "Compounds file %s does not exist or cannot be accessed.", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1023 args$compounds |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1024 ), |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1025 MISSING_INPUT_FILE_ERROR |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1026 ) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1027 } |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1028 if (in_galaxy_env()) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1029 check_galaxy_args_validity(args) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1030 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1031 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1032 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1033 in_galaxy_env <- function() { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1034 sysvars <- Sys.getenv() |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1035 sysvarnames <- names(sysvars) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1036 return( |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1037 "_GALAXY_JOB_HOME_DIR" %in% sysvarnames |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1038 || "_GALAXY_JOB_TMP_DIR" %in% sysvarnames |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1039 || "GALAXY_MEMORY_MB" %in% sysvarnames |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1040 || "GALAXY_MEMORY_MB_PER_SLOT" %in% sysvarnames |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1041 || "GALAXY_SLOTS" %in% sysvarnames |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1042 ) |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1043 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1044 |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1045 check_galaxy_args_validity <- function(args) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1046 if (!file.exists(args$output)) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1047 stop_with_status( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1048 sprintf( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1049 "Output file %s does not exist or cannot be accessed.", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1050 args$output |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1051 ), |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1052 MISSING_INPUT_FILE_ERROR |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1053 ) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1054 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1055 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1056 |
3
c68c94865667
planemo upload commit 09540e3a13b630b078a35afd3e129bc18c9953f0
workflow4metabolomics
parents:
1
diff
changeset
|
1057 get_csv_or_tsv <- function( |
c68c94865667
planemo upload commit 09540e3a13b630b078a35afd3e129bc18c9953f0
workflow4metabolomics
parents:
1
diff
changeset
|
1058 path, |
c68c94865667
planemo upload commit 09540e3a13b630b078a35afd3e129bc18c9953f0
workflow4metabolomics
parents:
1
diff
changeset
|
1059 sep_stack = c("\t", ",", ";"), |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1060 sep_names = c("tab", "comma", "semicolon"), |
3
c68c94865667
planemo upload commit 09540e3a13b630b078a35afd3e129bc18c9953f0
workflow4metabolomics
parents:
1
diff
changeset
|
1061 header = TRUE, |
c68c94865667
planemo upload commit 09540e3a13b630b078a35afd3e129bc18c9953f0
workflow4metabolomics
parents:
1
diff
changeset
|
1062 quote = "\"" |
c68c94865667
planemo upload commit 09540e3a13b630b078a35afd3e129bc18c9953f0
workflow4metabolomics
parents:
1
diff
changeset
|
1063 ) { |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1064 sep <- determine_csv_or_tsv_sep( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1065 path = path, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1066 sep_stack = sep_stack, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1067 header = header, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1068 quote = quote |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1069 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1070 verbose_catf( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1071 "%s separator has been determined for %s.\n", |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1072 sep_names[sep_stack == sep], |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1073 path |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1074 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1075 return(read.table( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1076 file = path, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1077 sep = sep, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1078 header = header, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1079 quote = quote |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1080 )) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1081 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1082 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1083 determine_csv_or_tsv_sep <- function( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1084 path, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1085 sep_stack = c("\t", ",", ";"), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1086 header = TRUE, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1087 quote = "\"" |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1088 ) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1089 count <- -1 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1090 best_sep <- sep_stack[1] |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1091 for (sep in sep_stack) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1092 tryCatch({ |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1093 table <- read.table( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1094 file = path, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1095 sep = sep, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1096 header = header, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1097 quote = quote, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1098 nrows = 1 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1099 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1100 if (ncol(table) > count) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1101 count <- ncol(table) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1102 best_sep <- sep |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1103 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1104 }) |
3
c68c94865667
planemo upload commit 09540e3a13b630b078a35afd3e129bc18c9953f0
workflow4metabolomics
parents:
1
diff
changeset
|
1105 } |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1106 return(best_sep) |
3
c68c94865667
planemo upload commit 09540e3a13b630b078a35afd3e129bc18c9953f0
workflow4metabolomics
parents:
1
diff
changeset
|
1107 } |
c68c94865667
planemo upload commit 09540e3a13b630b078a35afd3e129bc18c9953f0
workflow4metabolomics
parents:
1
diff
changeset
|
1108 |
4
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1109 uniformize_columns <- function(df) { |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1110 cols <- colnames(df) |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1111 for (func in c(tolower)) { |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1112 cols <- func(cols) |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1113 } |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1114 colnames(df) <- cols |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1115 return(df) |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1116 } |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1117 |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1118 handle_galaxy_param <- function(args) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1119 for (param in names(args)) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1120 if (is.character(args[[param]])) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1121 args[[param]] <- gsub("__ob__", "[", args[[param]]) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1122 args[[param]] <- gsub("__cb__", "]", args[[param]]) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1123 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1124 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1125 return(args) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1126 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1127 |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1128 zip_pdfs <- function(processing_parameters) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1129 if (processing_parameters$do_pdf) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1130 if (zip <- Sys.getenv("R_ZIPCMD", "zip") == "") { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1131 catf("R could not fin the zip executable. Trying luck: zip = \"zip\"") |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1132 zip <- "zip" |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1133 } else { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1134 catf("Found zip executable at %s .", zip) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1135 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1136 utils::zip( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1137 processing_parameters$pdf_zip_path, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1138 processing_parameters$pdf_path, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1139 zip = zip |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1140 ) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1141 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1142 } |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1143 |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
1144 main <- function(args) { |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1145 if (args$version) { |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1146 catf("%s\n", MS2SNOOP_VERSION) |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1147 base::quit(status = 0) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1148 } |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1149 if (in_galaxy_env()) { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1150 print(sessionInfo()) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1151 cat("\n\n") |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1152 } |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1153 check_args_validity(args) |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1154 args <- handle_galaxy_param(args) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1155 if (args$ionization == "None") { |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1156 args$ionization <- NULL |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1157 } |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1158 if (args$debug) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1159 set_debug() |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1160 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1161 if (args$verbose) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1162 set_verbose() |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1163 } |
3
c68c94865667
planemo upload commit 09540e3a13b630b078a35afd3e129bc18c9953f0
workflow4metabolomics
parents:
1
diff
changeset
|
1164 precursors <- get_csv_or_tsv(args$precursors) |
c68c94865667
planemo upload commit 09540e3a13b630b078a35afd3e129bc18c9953f0
workflow4metabolomics
parents:
1
diff
changeset
|
1165 fragments <- get_csv_or_tsv(args$fragments) |
c68c94865667
planemo upload commit 09540e3a13b630b078a35afd3e129bc18c9953f0
workflow4metabolomics
parents:
1
diff
changeset
|
1166 compounds <- get_csv_or_tsv(args$compounds) |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
1167 |
4
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1168 compounds <- uniformize_columns(compounds) |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1169 mandatory_columns <- c( |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1170 "compound_name", |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1171 "mz", |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1172 "rtsec", |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1173 "inchikey" |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1174 ) |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1175 presents <- mandatory_columns %in% colnames(compounds) |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1176 if (!all(presents)) { |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1177 stop_with_status( |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1178 sprintf( |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1179 "Some columns are missing: %s", |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1180 paste(mandatory_columns[which(!presents)], collapse = ", ") |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1181 ), |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1182 BAD_PARAMETER_VALUE_ERROR |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1183 ) |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1184 } |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1185 |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1186 res_all <- data.frame() |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1187 processing_parameters <- list( |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1188 min_number_scan = args$min_number_scan, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1189 mzdecimal = args$mzdecimal, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1190 r_threshold = args$r_threshold, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1191 seuil_ra = args$seuil_ra, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1192 tolmz = args$tolmz, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1193 tolrt = args$tolrt, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1194 ionization = args$ionization, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1195 do_pdf = nchar(args$pdf_path) > 0, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1196 pdf_zip_path = args$pdf_path, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1197 pdf_path = tempdir(), |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1198 fragment_match_delta = args$fragment_match_delta, |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1199 fragment_match_delta_unit = args$fragment_match_delta_unit |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1200 ) |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
1201 for (i in seq_len(nrow(compounds))) { |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1202 processing_parameters$mzref <- compounds[["mz"]][i] |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1203 processing_parameters$rtref <- compounds[["rtsec"]][i] |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1204 processing_parameters$c_name <- compounds[["compound_name"]][i] |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1205 processing_parameters$inchikey <- compounds[["inchikey"]][i] |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1206 processing_parameters$elemcomposition <- compounds[["elemcomposition"]][i] |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
1207 res_cor <- extract_fragments( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
1208 precursors = precursors, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
1209 fragments = fragments, |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1210 processing_parameters = processing_parameters |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
1211 ) |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1212 if (!is.null(res_cor)) { |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1213 res_all <- rbind(res_all, res_cor) |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
1214 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
1215 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
1216 |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1217 if (nrow(res_all) == 0) { |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
1218 stop_with_status("No result at all!", NO_ANY_RESULT_ERROR) |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
1219 } |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1220 |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
1221 write.table( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
1222 x = res_all, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
1223 file = args$output, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
1224 sep = "\t", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
1225 row.names = FALSE |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
1226 ) |
5
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1227 zip_pdfs(processing_parameters) |
78d5a12406c2
planemo upload commit a5f94dac9b268629399dc22c5d6ac48c5a85adc3
workflow4metabolomics
parents:
4
diff
changeset
|
1228 unlink(processing_parameters$pdf_path, recursive = TRUE) |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
1229 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
1230 |
4
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1231 global_debug <- FALSE |
856001213966
planemo upload commit 53543b5d911fc1f2d204f314a4d2aaf93a8c7715
workflow4metabolomics
parents:
3
diff
changeset
|
1232 global_verbose <- FALSE |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
1233 args <- optparse::parse_args(create_parser()) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
1234 main(args) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
1235 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
1236 warnings() |