Mercurial > repos > workflow4metabolomics > ms2snoop
annotate MS2snoop.R @ 1:df2672c37732 draft
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
author | workflow4metabolomics |
---|---|
date | Tue, 24 May 2022 18:14:49 +0000 |
parents | 91a3242fd67f |
children | c68c94865667 |
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 |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
18 assign("MS2SNOOP_VERSION", "1.0.1") |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
19 lockBinding("MS2SNOOP_VERSION", globalenv()) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
20 |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
21 assign("MISSING_PARAMETER_ERROR", 1) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
22 lockBinding("MISSING_PARAMETER_ERROR", globalenv()) |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
23 |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
24 assign("BAD_PARAMETER_VALUE_ERROR", 2) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
25 lockBinding("BAD_PARAMETER_VALUE_ERROR", globalenv()) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
26 |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
27 assign("MISSING_INPUT_FILE_ERROR", 3) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
28 lockBinding("MISSING_INPUT_FILE_ERROR", globalenv()) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
29 |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
30 assign("NO_ANY_RESULT_ERROR", 255) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
31 lockBinding("NO_ANY_RESULT_ERROR", globalenv()) |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
32 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
33 assign("DEFAULT_PRECURSOR_PATH", "peaklist_precursors.tsv") |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
34 assign("DEFAULT_FRAGMENTS_PATH", "peaklist_fragments.tsv") |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
35 assign("DEFAULT_COMPOUNDS_PATH", "compounds_pos.txt") |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
36 assign("DEFAULT_OUTPUT_PATH", "compound_fragments_result.txt") |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
37 assign("DEFAULT_TOLMZ", 0.01) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
38 assign("DEFAULT_TOLRT", 20) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
39 assign("DEFAULT_MZDECIMAL", 0) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
40 assign("DEFAULT_R_THRESHOLD", 0.85) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
41 assign("DEFAULT_MINNUMBERSCAN", 8) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
42 assign("DEFAULT_SEUIL_RA", 0.5) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
43 lockBinding("DEFAULT_PRECURSOR_PATH", globalenv()) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
44 lockBinding("DEFAULT_FRAGMENTS_PATH", globalenv()) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
45 lockBinding("DEFAULT_COMPOUNDS_PATH", globalenv()) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
46 lockBinding("DEFAULT_OUTPUT_PATH", globalenv()) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
47 lockBinding("DEFAULT_TOLMZ", globalenv()) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
48 lockBinding("DEFAULT_TOLRT", globalenv()) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
49 lockBinding("DEFAULT_MZDECIMAL", globalenv()) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
50 lockBinding("DEFAULT_R_THRESHOLD", globalenv()) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
51 lockBinding("DEFAULT_MINNUMBERSCAN", globalenv()) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
52 lockBinding("DEFAULT_SEUIL_RA", globalenv()) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
53 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
54 assign("DEFAULT_EXTRACT_FRAGMENTS_R_THRESHOLD", 0.85) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
55 assign("DEFAULT_EXTRACT_FRAGMENTS_SEUIL_RA", 0.1) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
56 assign("DEFAULT_EXTRACT_FRAGMENTS_TOLMZ", 0.01) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
57 assign("DEFAULT_EXTRACT_FRAGMENTS_TOLRT", 60) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
58 lockBinding("DEFAULT_EXTRACT_FRAGMENTS_R_THRESHOLD", globalenv()) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
59 lockBinding("DEFAULT_EXTRACT_FRAGMENTS_SEUIL_RA", globalenv()) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
60 lockBinding("DEFAULT_EXTRACT_FRAGMENTS_TOLMZ", globalenv()) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
61 lockBinding("DEFAULT_EXTRACT_FRAGMENTS_TOLRT", globalenv()) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
62 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
63 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
64 ######################################################################## |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
65 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
66 #' @title plot_pseudo_spectra |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
67 #' @param x |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
68 #' @param r_threshold |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
69 #' @param fid |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
70 #' @param sum_int |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
71 #' @param vmz |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
72 #' @param cor_abs_int |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
73 #' @param refcol |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
74 #' @param c_name |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
75 #' @description plot_pseudo_spectra |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
76 #' function to compute sum of intensities among scans for all |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
77 #' m/z kept (cor > r_threshold & minimum number of scans) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
78 #' and plot pseudo spectra |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
79 #' x dataframe scan X fragments with scans number in the 1st column and |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
80 #' ions in next with intensities |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
81 #' fid file id when several a precursor has been detected in several files |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
82 plot_pseudo_spectra <- function( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
83 x, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
84 r_threshold, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
85 fid, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
86 sum_int, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
87 vmz, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
88 cor_abs_int, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
89 refcol, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
90 c_name |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
91 ) { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
92 ## du fait de la difference de nombre de colonne entre la dataframe qui |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
93 ## inclue les scans en 1ere col, mzRef se decale de 1 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
94 refcol <- refcol - 1 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
95 ## compute relative intensities max=100% |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
96 rel_int <- sum_int[-1] |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
97 rel_int <- rel_int / max(rel_int) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
98 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
99 ## define max value on vertical axis (need to increase in order to plot the |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
100 ## label of fragments) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
101 ymax <- max(rel_int) + 0.2 * max(rel_int) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
102 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
103 par(mfrow = c(2, 1)) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
104 plot(vmz, rel_int, type = "h", ylim = c(0, ymax), main = c_name) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
105 ## low correl coef. will be display in grey |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
106 cor_low <- which(round(cor_abs_int, 2) < r_threshold) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
107 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
108 lbmzcor <- sprintf("%s(r=%s)", vmz, round(cor_abs_int, 2)) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
109 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
110 if (length(cor_low) > 0) { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
111 text( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
112 vmz[cor_low], |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
113 rel_int[cor_low], |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
114 lbmzcor[cor_low], |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
115 cex = 0.5, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
116 col = "grey", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
117 srt = 90, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
118 adj = 0 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
119 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
120 if (length(vmz) - length(cor_low) > 1) { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
121 text( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
122 vmz[-c(refcol, cor_low)], |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
123 rel_int[-c(refcol, cor_low)], |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
124 lbmzcor[-c(refcol, cor_low)], |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
125 cex = 0.6, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
126 col = 1, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
127 srt = 90, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
128 adj = 0 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
129 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
130 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
131 } else { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
132 if (length(vmz) > 1) { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
133 text( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
134 vmz[-c(refcol)], |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
135 rel_int[-c(refcol)], |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
136 lbmzcor[-c(refcol)], |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
137 cex = 0.6, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
138 col = 1, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
139 srt = 90, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
140 adj = 0 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
141 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
142 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
143 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
144 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
145 text( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
146 vmz[refcol], |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
147 rel_int[refcol], |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
148 lbmzcor[refcol], |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
149 cex = 0.8, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
150 col = 2, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
151 srt = 90, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
152 adj = 0 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
153 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
154 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
155 ## prepare result file |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
156 corValid <- (round(cor_abs_int, 2) >= r_threshold) ##nolint object_name_linter |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
157 cp_res <- data.frame( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
158 rep(c_name, length(vmz)), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
159 rep(fid, length(vmz)), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
160 vmz, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
161 cor_abs_int, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
162 sum_int[-1], |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
163 rel_int, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
164 corValid |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
165 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
166 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
167 colnames(cp_res) <- c( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
168 "compoundName", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
169 "fileid", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
170 "fragments_mz", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
171 "CorWithPrecursor", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
172 "AbsoluteIntensity", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
173 "relativeIntensity", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
174 "corValid" |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
175 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
176 return(cp_res) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
177 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
178 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
179 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
180 #' |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
181 #' @title extract_fragments |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
182 #' |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
183 #' @param precursors the precursor list from mspurity |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
184 #' @param fragments the fragments list from ms purity |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
185 #' @param mzref |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
186 #' @param rtref |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
187 #' @param c_name |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
188 #' @param r_threshold default = DEFAULT_EXTRACT_FRAGMENTS_R_THRESHOLD |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
189 #' @param seuil_ra default = DEFAULT_EXTRACT_FRAGMENTS_SEUIL_RA |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
190 #' @param tolmz default = DEFAULT_EXTRACT_FRAGMENTS_TOLMZ |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
191 #' @param tolrt default = DEFAULT_EXTRACT_FRAGMENTS_TOLRT |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
192 #' @returns |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
193 #' |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
194 #' @description |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
195 #' function for extraction of fragments corresponding to precursors |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
196 #' detected by MSPurity |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
197 extract_fragments <- function( ## nolint cyclocomp_linter |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
198 precursors, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
199 fragments, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
200 mzref, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
201 rtref, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
202 c_name, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
203 min_number_scan, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
204 mzdecimal, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
205 r_threshold=DEFAULT_EXTRACT_FRAGMENTS_R_THRESHOLD, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
206 seuil_ra=DEFAULT_EXTRACT_FRAGMENTS_SEUIL_RA, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
207 tolmz=DEFAULT_EXTRACT_FRAGMENTS_TOLMZ, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
208 tolrt=DEFAULT_EXTRACT_FRAGMENTS_TOLRT |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
209 ) { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
210 ## filter precursor in the precursors file based on mz and rt in the |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
211 ## compound list |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
212 cat("processing ", c_name, "\n") |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
213 selected_precursors <- which( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
214 (abs(precursors$precurMtchMZ - mzref) <= tolmz) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
215 & (abs(precursors$precurMtchRT - rtref) <= tolrt) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
216 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
217 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
218 ## check if there is the precursor in the file |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
219 if (length(selected_precursors) > 0) { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
220 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
221 sprecini <- precursors[selected_precursors, ] |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
222 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
223 ## check if fragments corresponding to precursor are found in several |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
224 ## files (collision energy) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
225 ## this lead to a processing for each fileid |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
226 mf <- levels(as.factor(sprecini$fileid)) |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
227 if (length(mf) > 1 && global_verbose) { |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
228 cat(" several files detected for this compounds :\n") |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
229 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
230 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
231 for (f in seq_along(mf)) { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
232 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
233 sprec <- sprecini[sprecini$fileid == mf[f], ] |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
234 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
235 ## selection of fragment in the fragments file with the grpid common in |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
236 ## both fragments and precursors |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
237 selfrgt <- levels(as.factor(sprec$grpid)) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
238 sfrgt <- fragments[ |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
239 fragments$grpid %in% selfrgt |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
240 & fragments$fileid == mf[f], |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
241 ] |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
242 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
243 ## filter fragments on relative intensity seuil_ra = user defined |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
244 ## parameter (MSpurity flags could be used here) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
245 sfrgtfil <- sfrgt[sfrgt$ra > seuil_ra, ] |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
246 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
247 mznominal <- round(x = sfrgtfil$mz, mzdecimal) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
248 sfrgtfil <- data.frame(sfrgtfil, mznominal) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
249 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
250 ## creation of cross table row=scan col=mz X=ra |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
251 vmz <- levels(as.factor(sfrgtfil$mznominal)) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
252 |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
253 if (global_verbose) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
254 cat(" fragments :", vmz) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
255 } |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
256 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
257 ## mz of precursor in data precursor to check correlation with |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
258 mz_prec <- paste0("mz", round(mean(sprec$mz), mzdecimal)) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
259 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
260 for (m in seq_along(vmz)) { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
261 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
262 ## absolute intensity |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
263 cln <- c( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
264 which(colnames(sfrgtfil) == "acquisitionNum"), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
265 which(colnames(sfrgtfil) == "i") |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
266 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
267 int_mz <- sfrgtfil[sfrgtfil$mznominal == vmz[m], cln] |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
268 colnames(int_mz)[2] <- paste0("mz", vmz[m]) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
269 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
270 ## average intensities of mass in duplicate scans |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
271 comp_scans <- aggregate(x = int_mz, by = list(int_mz[[1]]), FUN = mean) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
272 int_mz <- comp_scans[, -1] |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
273 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
274 if (m == 1) { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
275 ds_abs_int <- int_mz |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
276 } else { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
277 ds_abs_int <- merge( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
278 x = ds_abs_int, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
279 y = int_mz, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
280 by.x = 1, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
281 by.y = 1, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
282 all.x = TRUE, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
283 all.y = TRUE |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
284 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
285 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
286 } |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
287 if (global_debug) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
288 print(ds_abs_int) |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
289 write.table( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
290 x = ds_abs_int, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
291 file = paste0(c_name, "ds_abs_int.txt"), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
292 row.names = FALSE, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
293 sep = "\t" |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
294 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
295 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
296 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
297 ## elimination of mz with less than min_number_scan scans (user defined |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
298 ## parameter) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
299 xmz <- rep(NA, ncol(ds_abs_int) - 1) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
300 sum_int <- rep(NA, ncol(ds_abs_int)) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
301 nbxmz <- 0 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
302 nb_scan_check <- min(nrow(ds_abs_int), min_number_scan) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
303 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
304 for (j in 2:ncol(ds_abs_int)) { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
305 sum_int[j] <- sum(ds_abs_int[j], na.rm = TRUE) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
306 if (sum(!is.na(ds_abs_int[[j]])) < nb_scan_check) { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
307 nbxmz <- nbxmz + 1 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
308 xmz[nbxmz] <- j |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
309 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
310 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
311 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
312 xmz <- xmz[-which(is.na(xmz))] |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
313 if (length(xmz) > 0) { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
314 ds_abs_int <- ds_abs_int[, -c(xmz)] |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
315 sum_int <- sum_int[-c(xmz)] |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
316 ## liste des mz keeped decale de 1 avec ds_abs_int |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
317 vmz <- as.numeric(vmz[-c(xmz - 1)]) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
318 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
319 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
320 ## reference ion for correlation computing = precursor OR maximum |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
321 ## intensity ion in precursor is not present |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
322 refcol <- which(colnames(ds_abs_int) == mz_prec) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
323 if (length(refcol) == 0) { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
324 refcol <- which(sum_int == max(sum_int, na.rm = TRUE)) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
325 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
326 pdf( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
327 file = sprintf("%s_processing_file%s.pdf", c_name, mf[f]), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
328 width = 8, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
329 height = 11 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
330 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
331 par(mfrow = c(3, 2)) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
332 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
333 ## Pearson correlations between absolute intensities computing |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
334 cor_abs_int <- rep(NA, length(vmz)) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
335 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
336 if (length(refcol) > 0) { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
337 for (i in 2:length(ds_abs_int)) { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
338 cor_abs_int[i - 1] <- cor( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
339 x = ds_abs_int[[refcol]], |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
340 y = ds_abs_int[[i]], |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
341 use = "pairwise.complete.obs", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
342 method = "pearson" |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
343 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
344 plot( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
345 ds_abs_int[[refcol]], |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
346 ds_abs_int[[i]], |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
347 xlab = colnames(ds_abs_int)[refcol], |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
348 ylab = colnames(ds_abs_int)[i], |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
349 main = sprintf( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
350 "%s corr coeff r=%s", c_name, round(cor_abs_int[i - 1], 2) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
351 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
352 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
353 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
354 ## plot pseudo spectra |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
355 res_comp_by_file <- plot_pseudo_spectra( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
356 x = ds_abs_int, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
357 r_threshold = r_threshold, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
358 fid = mf[f], |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
359 sum_int = sum_int, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
360 vmz = vmz, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
361 cor_abs_int = cor_abs_int, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
362 refcol = refcol, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
363 c_name = c_name |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
364 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
365 if (f == 1) { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
366 res_comp <- res_comp_by_file |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
367 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
368 } else { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
369 res_comp_by_file <- NULL |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
370 cat(" non detected in fragments file \n") |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
371 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
372 if (!is.null(res_comp_by_file)) { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
373 res_comp <- rbind(res_comp, res_comp_by_file) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
374 } |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
375 if (global_verbose) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
376 cat("\n") |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
377 } |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
378 dev.off() |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
379 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
380 } else { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
381 res_comp <- NULL |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
382 cat(" non detected in precursor file \n") |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
383 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
384 return(res_comp) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
385 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
386 |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
387 set_global <- function(var, value) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
388 assign(var, value, envir = globalenv()) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
389 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
390 |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
391 set_debug <- function() { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
392 set_global("global_debug", TRUE) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
393 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
394 |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
395 unset_debug <- function() { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
396 set_global("global_debug", FALSE) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
397 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
398 |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
399 set_verbose <- function() { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
400 set_global("global_verbose", TRUE) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
401 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
402 |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
403 unset_verbose <- function() { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
404 set_global("global_verbose", FALSE) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
405 } |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
406 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
407 create_parser <- function() { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
408 parser <- optparse::OptionParser() |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
409 parser <- optparse::add_option( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
410 parser, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
411 c("-v", "--verbose"), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
412 action = "store_true", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
413 default = FALSE, |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
414 help = paste( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
415 "[default %default]", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
416 "Print extra output" |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
417 ) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
418 ) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
419 parser <- optparse::add_option( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
420 parser, |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
421 c("-V", "--version"), |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
422 action = "store_true", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
423 default = FALSE, |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
424 help = "Prints version and exits" |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
425 ) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
426 parser <- optparse::add_option( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
427 parser, |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
428 c("-d", "--debug"), |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
429 action = "store_true", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
430 default = FALSE, |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
431 help = paste( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
432 "[default %default]", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
433 "Print debug outputs" |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
434 ) |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
435 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
436 parser <- optparse::add_option( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
437 parser, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
438 c("-o", "--output"), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
439 type = "character", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
440 default = DEFAULT_OUTPUT_PATH, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
441 action = "store", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
442 help = "Path to the output file [default %default]" |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
443 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
444 parser <- optparse::add_option( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
445 parser, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
446 c("-p", "--precursors"), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
447 type = "character", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
448 default = DEFAULT_PRECURSOR_PATH, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
449 action = "store", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
450 help = "Path to the precursors file [default %default]" |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
451 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
452 parser <- optparse::add_option( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
453 parser, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
454 c("-f", "--fragments"), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
455 type = "character", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
456 default = DEFAULT_FRAGMENTS_PATH, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
457 action = "store", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
458 help = "Path to the fragments file [default %default]" |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
459 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
460 parser <- optparse::add_option( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
461 parser, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
462 c("-c", "--compounds"), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
463 type = "character", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
464 default = DEFAULT_COMPOUNDS_PATH, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
465 action = "store", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
466 help = "Path to the compounds file [default %default]" |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
467 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
468 parser <- optparse::add_option( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
469 parser, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
470 c("--tolmz"), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
471 type = "numeric", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
472 action = "store", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
473 default = DEFAULT_TOLMZ, |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
474 metavar = "number", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
475 help = paste( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
476 "[default %default]", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
477 "Tolerance for MZ (in Dalton) to match the standard in the compounds" |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
478 ) |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
479 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
480 parser <- optparse::add_option( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
481 parser, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
482 c("--tolrt"), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
483 type = "integer", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
484 action = "store", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
485 default = DEFAULT_TOLRT, |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
486 metavar = "number", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
487 help = paste( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
488 "[default %default]", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
489 "RT (in seconds) to match the standard in the compounds" |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
490 ) |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
491 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
492 parser <- optparse::add_option( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
493 parser, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
494 c("--seuil_ra"), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
495 type = "numeric", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
496 action = "store", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
497 default = DEFAULT_SEUIL_RA, |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
498 metavar = "number", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
499 help = paste( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
500 "[default %default]", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
501 "relative intensity threshold" |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
502 ), |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
503 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
504 parser <- optparse::add_option( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
505 parser, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
506 c("--mzdecimal"), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
507 type = "integer", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
508 default = DEFAULT_MZDECIMAL, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
509 action = "store", |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
510 help = paste( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
511 "[default %default]", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
512 "Number of decimal to write for MZ" |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
513 ), |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
514 metavar = "number" |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
515 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
516 parser <- optparse::add_option( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
517 parser, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
518 c("--r_threshold"), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
519 type = "integer", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
520 default = DEFAULT_R_THRESHOLD, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
521 action = "store", |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
522 help = paste( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
523 "[default %default]", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
524 "R-Pearson correlation threshold between precursor and fragment", |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
525 "absolute intensity" |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
526 ), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
527 metavar = "number" |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
528 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
529 parser <- optparse::add_option( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
530 parser, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
531 c("--min_number_scan"), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
532 type = "numeric", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
533 action = "store", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
534 default = DEFAULT_MINNUMBERSCAN, |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
535 help = paste( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
536 "[default %default]", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
537 "Fragments are kept if there are found in a minimum number", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
538 "of min_number_scan scans" |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
539 ), |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
540 metavar = "number" |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
541 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
542 return(parser) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
543 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
544 |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
545 stop_with_status <- function(msg, status) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
546 message(sprintf("Error: %s", msg)) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
547 message(sprintf("Error code: %s", status)) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
548 base::quit(status = status) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
549 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
550 |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
551 check_args_validity <- function(args) { ## nolint cyclocomp_linter |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
552 sysvars <- Sys.getenv() |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
553 sysvarnames <- names(sysvars) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
554 if (length(args$output) == 0 || nchar(args$output[1]) == 0) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
555 stop_with_status( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
556 "Missing output parameters. Please set it with --output.", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
557 MISSING_PARAMETER_ERROR |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
558 ) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
559 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
560 if (length(args$precursors) == 0 || nchar(args$precursors[1]) == 0) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
561 stop_with_status( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
562 "Missing precursors parameters. Please set it with --precursors.", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
563 MISSING_PARAMETER_ERROR |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
564 ) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
565 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
566 if (length(args$fragments) == 0 || nchar(args$fragments[1]) == 0) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
567 stop_with_status( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
568 "Missing fragments parameters. Please set it with --fragments.", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
569 MISSING_PARAMETER_ERROR |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
570 ) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
571 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
572 if (length(args$compounds) == 0 || nchar(args$compounds[1]) == 0) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
573 stop_with_status( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
574 "Missing compounds parameters. Please set it with --compounds.", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
575 MISSING_PARAMETER_ERROR |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
576 ) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
577 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
578 if (!file.exists(args$precursors)) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
579 stop_with_status( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
580 sprintf( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
581 "Precursors file %s does not exist or cannot be accessed.", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
582 args$precursors |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
583 ), |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
584 MISSING_INPUT_FILE_ERROR |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
585 ) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
586 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
587 if (!file.exists(args$fragments)) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
588 stop_with_status( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
589 sprintf( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
590 "Fragments file %s does not exist or cannot be accessed.", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
591 args$fragments |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
592 ), |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
593 MISSING_INPUT_FILE_ERROR |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
594 ) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
595 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
596 if (!file.exists(args$compounds)) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
597 stop_with_status( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
598 sprintf( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
599 "Compounds file %s does not exist or cannot be accessed.", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
600 args$compounds |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
601 ), |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
602 MISSING_INPUT_FILE_ERROR |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
603 ) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
604 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
605 if ( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
606 "_GALAXY_JOB_HOME_DIR" %in% sysvarnames |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
607 || "_GALAXY_JOB_TMP_DIR" %in% sysvarnames |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
608 || "GALAXY_MEMORY_MB" %in% sysvarnames |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
609 || "GALAXY_MEMORY_MB_PER_SLOT" %in% sysvarnames |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
610 || "GALAXY_SLOTS" %in% sysvarnames |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
611 ) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
612 check_galaxy_args_validity(args) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
613 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
614 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
615 |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
616 check_galaxy_args_validity <- function(args) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
617 if (!file.exists(args$output)) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
618 stop_with_status( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
619 sprintf( |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
620 "Output file %s does not exist or cannot be accessed.", |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
621 args$output |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
622 ), |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
623 MISSING_INPUT_FILE_ERROR |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
624 ) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
625 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
626 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
627 |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
628 main <- function(args) { |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
629 if (args$version) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
630 cat(sprintf("%s\n", MS2SNOOP_VERSION)) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
631 base::quit(status = 0) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
632 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
633 sessionInfo() |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
634 check_args_validity(args) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
635 if (args$debug) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
636 set_debug() |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
637 } |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
638 if (args$verbose) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
639 set_verbose() |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
640 } |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
641 ## MSpurity precursors file |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
642 precursors <- read.table( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
643 file = args$precursors, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
644 header = TRUE, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
645 sep = "\t", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
646 quote = "\"" |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
647 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
648 ## MSpurity fragments file |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
649 fragments <- read.table( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
650 file = args$fragments, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
651 header = TRUE, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
652 sep = "\t", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
653 quote = "\"" |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
654 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
655 ## list of compounds : col1=Name of molecule, col2=m/z, col3=retention time |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
656 compounds <- read.table( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
657 file = args$compounds, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
658 sep = "\t", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
659 quote = "\"", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
660 header = TRUE |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
661 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
662 |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
663 res_all <- NULL |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
664 for (i in seq_len(nrow(compounds))) { |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
665 ## loop execution for all compounds in the compounds file |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
666 res_cor <- NULL |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
667 res_cor <- extract_fragments( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
668 precursors = precursors, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
669 fragments = fragments, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
670 mzref = compounds[[2]][i], |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
671 rtref = compounds[[3]][i], |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
672 c_name = compounds[[1]][i], |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
673 min_number_scan = args$min_number_scan, |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
674 mzdecimal = args$mzdecimal, |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
675 r_threshold = args$r_threshold, |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
676 seuil_ra = args$seuil_ra, |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
677 tolmz = args$tolmz, |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
678 tolrt = args$tolrt |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
679 ) |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
680 if (!is.null(res_cor)) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
681 if (is.null(res_all)) { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
682 res_all <- res_cor |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
683 } else { |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
684 res_all <- rbind(res_all, res_cor) |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
685 } |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
686 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
687 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
688 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
689 if (is.null(res_all)) { |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
690 stop_with_status("No result at all!", NO_ANY_RESULT_ERROR) |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
691 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
692 write.table( |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
693 x = res_all, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
694 file = args$output, |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
695 sep = "\t", |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
696 row.names = FALSE |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
697 ) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
698 } |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
699 |
1
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
700 unset_debug() |
df2672c37732
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43
workflow4metabolomics
parents:
0
diff
changeset
|
701 unset_verbose() |
0
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
702 args <- optparse::parse_args(create_parser()) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
703 main(args) |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
704 |
91a3242fd67f
"planemo upload commit c7676a9c7ac542043691d735285ae19e430bf032"
workflow4metabolomics
parents:
diff
changeset
|
705 warnings() |