comparison annotationRmn2D.R @ 3:546c7ccd2ed4 draft default tip

"planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit 911f4beba3dcb25c1033e8239426f8f763683523"
author workflow4metabolomics
date Fri, 04 Feb 2022 09:01:11 +0000
parents dff7bde22102
children
comparison
equal deleted inserted replaced
2:dff7bde22102 3:546c7ccd2ed4
1 ########################################################################################################################################### 1 ##########################################################################
2 # ANNOTATION SPECTRE 2D MATRICE COMPLEXE BASEE SUR UNE SEQUENCE RMN # 2 # ANNOTATION SPECTRE 2D MATRICE COMPLEXE BASEE SUR UNE SEQUENCE RMN #
3 # matriceComplexe : data.frame liste couples ppm de la matrice a annoter # 3 # matriceComplexe : data.frame liste couples ppm de la matrice a annoter #
4 # BdDStandards : objet contenant la base de donnees des composes standards # 4 # BdDStandards : objet contenant la base de donnees des composes standards #
5 # nom_séquence : nom sequence 2D a utiliser pour annotation ("JRES","COSY","TOCSY","HMBC","HSQC") # 5 # nom_sequence : nom sequence 2D a utiliser pour annotation ("JRES", "COSY", "TOCSY", "HMBC", "HSQC") #
6 # ppm1Tol : tolerance ppm axe abscisses # 6 # ppm1Tol : tolerance ppm axe abscisses #
7 # ppm2Tol : tolerance ppm axe ordonnees # 7 # ppm2Tol : tolerance ppm axe ordonnees #
8 # nb_ligne_template : préciser le nombre total de ligne de la feuille de calcul à annoter # 8 # nb_ligne_template : preciser le nombre total de ligne de la feuille de calcul a annoter #
9 ########################################################################################################################################### 9 #######################################################################################################
10 annotationRmn2D <- function(matriceComplexe, BdDStandards, nom_sequence, ppm1Tol=0.01, ppm2Tol=0.01, 10 annotationRmn2D <- function(matriceComplexe, BdDStandards, nom_sequence, ppm1Tol = 0.01, ppm2Tol = 0.01,
11 seuil=0, unicite="NO") 11 seuil = 0, unicite = "NO") {
12 {
13 ## Longueur de la peak-list de la matrice a annoter 12 ## Longueur de la peak-list de la matrice a annoter
14 PeakListLength <- length(matriceComplexe[, 1]) 13 PeakListLength <- length(matriceComplexe[, 1])
15 14
16 ## Nombre de metabolites inclus dans BdD de composes standards 15 ## Nombre de metabolites inclus dans BdD de composes standards
17 nbMetabolitesBdD <- length(BdDStandards) 16 nbMetabolitesBdD <- length(BdDStandards)
18 matrixAnnotation <- data.frame() 17 matrixAnnotation <- data.frame()
19 allMetabolitesList <- data.frame() 18 allMetabolitesList <- data.frame()
20 seuil_score <- seuil 19 seuil_score <- seuil
21 20
22 ## Boucle sur les metabolites inclus dans BdD 21 ## Boucle sur les metabolites inclus dans BdD
23 for (i in 1:nbMetabolitesBdD) 22 for (i in seq_len(nbMetabolitesBdD)) {
24 {
25 ## Infos metabolite en cours 23 ## Infos metabolite en cours
26 iMetabolite <- BdDStandards[[i]] 24 iMetabolite <- BdDStandards[[i]]
27 ppm1M <- iMetabolite[,1] 25 ppm1M <- iMetabolite[, 1]
28 ppm2M <- iMetabolite[,2] 26 ppm2M <- iMetabolite[, 2]
29 nbPeakMetabolite <- length(ppm1M) 27 nbPeakMetabolite <- length(ppm1M)
30 MetaboliteName <- names(BdDStandards[i]) 28 MetaboliteName <- names(BdDStandards[i])
31 ## print(MetaboliteName) 29
32 ## Initialisation 30 ## Initialisation
33 k <- 0 31 k <- 0
34 presenceScore <- 0 32 presenceScore <- 0
35 annotatedPpmRef <- data.frame() 33 annotatedPpmRef <- data.frame()
36 annotatedPpmList <- data.frame() 34 annotatedPpmList <- data.frame()
37 annotatedPeakLength <- 0 35 annotatedPeakLength <- 0
38 metabolites <- data.frame() 36 metabolites <- data.frame()
39 metabolitesList <- data.frame() 37 metabolitesList <- data.frame()
40 38
41 ## Boucle sur les couples de pics de la matrice a annoter 39 ## Boucle sur les couples de pics de la matrice a annoter
42 for (p in 1:PeakListLength) 40 for (p in seq_len(PeakListLength)) {
43 {
44 ppmAnnotationF1 <- as.numeric(matriceComplexe[p, 3]) 41 ppmAnnotationF1 <- as.numeric(matriceComplexe[p, 3])
45 ppmAnnotationF2 <- as.numeric(matriceComplexe[p, 2]) 42 ppmAnnotationF2 <- as.numeric(matriceComplexe[p, 2])
46 e <- simpleMessage("end of file") 43 e <- simpleMessage("end of file")
47 tryCatch({ 44 tryCatch({
48 if (!is.na(ppmAnnotationF1)) 45 if (!is.na(ppmAnnotationF1)) {
49 {
50 matrixAnnotation <- unique.data.frame(rbind.data.frame(matrixAnnotation, matriceComplexe[p, ])) 46 matrixAnnotation <- unique.data.frame(rbind.data.frame(matrixAnnotation, matriceComplexe[p, ]))
51 } 47 }
52 # Recherche du couple de pics de la matrice la liste des couples du metabolite standard 48 # Recherche du couple de pics de la matrice la liste des couples du metabolite standard
53 metaboliteIn <- (ppm1M >= (ppmAnnotationF2-ppm1Tol) & ppm1M <= (ppmAnnotationF2+ppm1Tol) & 49 metaboliteIn <- (ppm1M >= (ppmAnnotationF2 - ppm1Tol) & ppm1M <= (ppmAnnotationF2 + ppm1Tol) &
54 ppm2M >= (ppmAnnotationF1-ppm2Tol) & ppm2M <= (ppmAnnotationF1+ppm2Tol)) 50 ppm2M >= (ppmAnnotationF1 - ppm2Tol) & ppm2M <= (ppmAnnotationF1 + ppm2Tol))
55 WhichMetaboliteIn <- which(metaboliteIn) 51 WhichMetaboliteIn <- which(metaboliteIn)
56 # Si au moins un couple de la matrice a annoter dans liste couples metabolite standard 52 # Si au moins un couple de la matrice a annoter dans liste couples metabolite standard
57 if (length(WhichMetaboliteIn) > 0) 53 if (length(WhichMetaboliteIn) > 0) {
58 { 54 for (a in seq_len(length(WhichMetaboliteIn))) {
59 for (a in 1:length(WhichMetaboliteIn)) 55 annotatedPpmList <- data.frame(ppm1 = ppm1M[WhichMetaboliteIn[a]], ppm2 = ppm2M[WhichMetaboliteIn[a]], theoricalLength = nbPeakMetabolite)
60 { 56 annotatedPpmRef <- rbind(annotatedPpmRef, annotatedPpmList)
61 annotatedPpmList <- data.frame(ppm1=ppm1M[WhichMetaboliteIn[a]], ppm2=ppm2M[WhichMetaboliteIn[a]], theoricalLength=nbPeakMetabolite)
62 annotatedPpmRef <- rbind(annotatedPpmRef,annotatedPpmList)
63 } 57 }
64 } 58 }
65 }, error=function(e){cat ("End of file \n");}) 59 }, error = function(e) {
60 cat("End of file \n");
61 })
66 } 62 }
67 63
68 # Au - 1 couple de ppm de la matrice complexe annote 64 # Au - 1 couple de ppm de la matrice complexe annote
69 if (nrow(annotatedPpmRef) >= 1) 65 if (nrow(annotatedPpmRef) >= 1) {
70 {
71 ## Nombre couples annotes 66 ## Nombre couples annotes
72 annotatedPeakLength <- nrow(annotatedPpmRef) 67 annotatedPeakLength <- nrow(annotatedPpmRef)
73 68
74 ## Recherche doublons 69 ## Recherche doublons
75 annotatedDoublons <- duplicated(annotatedPpmRef) 70 annotatedDoublons <- duplicated(annotatedPpmRef)
76 if (sum(duplicated(annotatedPpmRef)) > 0) 71 if (sum(duplicated(annotatedPpmRef)) > 0) {
77 {
78 annotatedPeakLength <- nrow(annotatedPpmRef) - sum(duplicated(annotatedPpmRef)) 72 annotatedPeakLength <- nrow(annotatedPpmRef) - sum(duplicated(annotatedPpmRef))
79 annotatedPpmRef <- annotatedPpmRef[-duplicated(annotatedPpmRef), ] 73 annotatedPpmRef <- annotatedPpmRef[-duplicated(annotatedPpmRef), ]
80 } 74 }
81 presenceScore <- annotatedPeakLength/nbPeakMetabolite 75 presenceScore <- round(annotatedPeakLength / nbPeakMetabolite, 2)
82 } 76 }
83 77
84 ## Conservation metabolites dont score > seuil 78 ## Conservation metabolites dont score > seuil
85 if (presenceScore > seuil_score) 79 if (presenceScore > seuil_score) {
86 { 80 metabolites <- data.frame(Metabolite = MetaboliteName, score = presenceScore)
87 metabolites <- data.frame(Metabolite=MetaboliteName, score=presenceScore) 81 metabolitesList <- cbind.data.frame(annotatedPpmRef, metabolites)
88 metabolitesList <- cbind.data.frame(annotatedPpmRef, metabolites)
89 allMetabolitesList <- rbind.data.frame(allMetabolitesList, metabolitesList) 82 allMetabolitesList <- rbind.data.frame(allMetabolitesList, metabolitesList)
90 } 83 }
91 } 84 }
92 85
93 # Initialisation 86 # Initialisation
94 commonPpm <- data.frame() 87 commonPpm <- data.frame()
95 commonPpmList <- data.frame() 88 commonPpmList <- data.frame()
96 metaboliteAdd <- data.frame() 89 metaboliteAdd <- data.frame()
97 metaboliteAddList <- data.frame() 90 metaboliteAddList <- data.frame()
98 # metabolite_ref <- data.frame()
99 commonMetabolitesList <- data.frame() 91 commonMetabolitesList <- data.frame()
100 commonMetabolitesPpmList <- data.frame() 92 commonMetabolitesPpmList <- data.frame()
101 commonMetabolitesPpmAllList1 <- data.frame() 93 commonMetabolitesPpmAllList1 <- data.frame()
102 commonMetabolitesPpmAllList <- data.frame() 94 commonMetabolitesPpmAllList <- data.frame()
103 listeTotale_2D_unicite <- allMetabolitesList[, 1:4] 95 listeTotale_2D_unicite <- allMetabolitesList[, 1:4]
104 allMetabolitesList <- allMetabolitesList[, -3] 96 allMetabolitesList <- allMetabolitesList[, -3]
105 metabolitesAllUnicite <- data.frame() 97 metabolitesAllUnicite <- data.frame()
106 98
107 ## Boucle sur tous couples annotes 99 ## Boucle sur tous couples annotes
108 for (j in 1:length(allMetabolitesList$ppm1)) 100 for (j in seq_len(length(allMetabolitesList$ppm1))) {
109 {
110 ## Boucle sur metabolites dans BdD composes standards 101 ## Boucle sur metabolites dans BdD composes standards
111 for (i in 1:nbMetabolitesBdD) 102 for (i in seq_len(nbMetabolitesBdD)) {
112 {
113 ppmMetaboliteBdD <- BdDStandards[[i]] 103 ppmMetaboliteBdD <- BdDStandards[[i]]
114 ppm1M <- ppmMetaboliteBdD[,1] 104 ppm1M <- ppmMetaboliteBdD[, 1]
115 ppm2M <- ppmMetaboliteBdD[,2] 105 ppm2M <- ppmMetaboliteBdD[, 2]
116 # Nombre de couples metabolite 106 # Nombre de couples metabolite
117 nbPeakMetabolite <- length(ppm1M) 107 nbPeakMetabolite <- length(ppm1M)
118 MetaboliteName <- names(BdDStandards[i]) 108 MetaboliteName <- names(BdDStandards[i])
119 109
120 metabolitesInAll <- (ppm1M >= (allMetabolitesList[j,1]-ppm1Tol) & ppm1M <= (allMetabolitesList[j,1]+ppm1Tol) & 110 metabolitesInAll <- (ppm1M >= (allMetabolitesList[j, 1] - ppm1Tol) & ppm1M <= (allMetabolitesList[j, 1] + ppm1Tol) &
121 ppm2M >= (allMetabolitesList[j,2]-ppm2Tol) & ppm2M <= (allMetabolitesList[j,2]+ppm2Tol)) 111 ppm2M >= (allMetabolitesList[j, 2] - ppm2Tol) & ppm2M <= (allMetabolitesList[j, 2] + ppm2Tol))
122 WhichMetabolitesInAll <- which(metabolitesInAll) 112 WhichMetabolitesInAll <- which(metabolitesInAll)
123 113
124 if (MetaboliteName != allMetabolitesList[j, 3] & length(WhichMetabolitesInAll) > 0) 114 if (MetaboliteName != allMetabolitesList[j, 3] & length(WhichMetabolitesInAll) > 0) {
125 { 115 metabolitesAllUnicite <- rbind.data.frame(metabolitesAllUnicite, listeTotale_2D_unicite[j, ])
126 metabolitesAllUnicite <- rbind.data.frame(metabolitesAllUnicite, listeTotale_2D_unicite[j,]) 116 commonPpm <- data.frame(ppm1 = allMetabolitesList[j, 1], ppm2 = allMetabolitesList[j, 2])
127 commonPpm <- data.frame(ppm1=allMetabolitesList[j,1], ppm2=allMetabolitesList[j,2])
128 commonPpmList <- rbind.data.frame(commonPpmList, commonPpm) 117 commonPpmList <- rbind.data.frame(commonPpmList, commonPpm)
129 commonPpmList <- unique(commonPpmList) 118 commonPpmList <- unique(commonPpmList)
130 metaboliteAdd <- data.frame(nom_metabolite=MetaboliteName) 119 metaboliteAdd <- data.frame(nom_metabolite = MetaboliteName)
131 metaboliteAddList <- rbind.data.frame(metaboliteAddList, metaboliteAdd) 120 metaboliteAddList <- rbind.data.frame(metaboliteAddList, metaboliteAdd)
132 # metabolite_ref <- data.frame(nom_metabolite=allMetabolitesList[j,3]) 121 commonMetabolitesList <- rbind.data.frame(data.frame(nom_metabolite = allMetabolitesList[j, 3]), metaboliteAddList)
133 commonMetabolitesList <- rbind.data.frame(data.frame(nom_metabolite=allMetabolitesList[j, 3]), metaboliteAddList)
134 commonMetabolitesPpmList <- cbind.data.frame(commonPpm, commonMetabolitesList) 122 commonMetabolitesPpmList <- cbind.data.frame(commonPpm, commonMetabolitesList)
135 commonMetabolitesPpmAllList1 <- rbind.data.frame(commonMetabolitesPpmAllList1, commonMetabolitesPpmList) 123 commonMetabolitesPpmAllList1 <- rbind.data.frame(commonMetabolitesPpmAllList1, commonMetabolitesPpmList)
136 commonMetabolitesPpmAllList1 <- unique.data.frame(commonMetabolitesPpmAllList1) 124 commonMetabolitesPpmAllList1 <- unique.data.frame(commonMetabolitesPpmAllList1)
137 } 125 }
138 } 126 }
139 commonMetabolitesPpmAllList <- rbind.data.frame(commonMetabolitesPpmAllList, commonMetabolitesPpmAllList1) 127 commonMetabolitesPpmAllList <- rbind.data.frame(commonMetabolitesPpmAllList, commonMetabolitesPpmAllList1)
140 commonMetabolitesPpmAllList <- unique.data.frame(commonMetabolitesPpmAllList) 128 commonMetabolitesPpmAllList <- unique.data.frame(commonMetabolitesPpmAllList)
141 129
142 #initialisation des data.frame 130 #initialisation des data.frame
143 commonPpm <- data.frame() 131 commonPpm <- data.frame()
144 metaboliteAdd <- data.frame() 132 metaboliteAdd <- data.frame()
145 metaboliteAddList <- data.frame() 133 metaboliteAddList <- data.frame()
146 metabolite_ref <- data.frame() 134 metabolite_ref <- data.frame()
148 commonMetabolitesPpmList <- data.frame() 136 commonMetabolitesPpmList <- data.frame()
149 commonMetabolitesPpmAllList1 <- data.frame() 137 commonMetabolitesPpmAllList1 <- data.frame()
150 } 138 }
151 139
152 unicityAllList <- listeTotale_2D_unicite 140 unicityAllList <- listeTotale_2D_unicite
153 if (nrow(listeTotale_2D_unicite)!=0 & nrow(metabolitesAllUnicite)!=0) 141 if (nrow(listeTotale_2D_unicite) != 0 & nrow(metabolitesAllUnicite) != 0)
154 unicityAllList <- setdiff(listeTotale_2D_unicite, metabolitesAllUnicite) 142 unicityAllList <- setdiff(listeTotale_2D_unicite, metabolitesAllUnicite)
155 143
156 unicitynbCouplesRectif <- data.frame() 144 unicitynbCouplesRectif <- data.frame()
157 for (g in 1:nrow(unicityAllList)) 145 for (g in seq_len(nrow(unicityAllList))) {
158 {
159 metaboliteUnicity <- (unicityAllList$Metabolite == unicityAllList$Metabolite[g]) 146 metaboliteUnicity <- (unicityAllList$Metabolite == unicityAllList$Metabolite[g])
160 WhichMetaboliteUnicity <- which(metaboliteUnicity) 147 WhichMetaboliteUnicity <- which(metaboliteUnicity)
161 nb_occurence <- length(WhichMetaboliteUnicity) 148 nb_occurence <- length(WhichMetaboliteUnicity)
162 unicitynbCouplesRectif <- rbind.data.frame(unicitynbCouplesRectif, nb_occurence) 149 unicitynbCouplesRectif <- rbind.data.frame(unicitynbCouplesRectif, nb_occurence)
163 } 150 }
164 names(unicitynbCouplesRectif) <- "NbCouplesAnnotes" 151 names(unicitynbCouplesRectif) <- "NbCouplesAnnotes"
165 unicityAllList <- cbind.data.frame(unicityAllList, unicitynbCouplesRectif) 152 unicityAllList <- cbind.data.frame(unicityAllList, unicitynbCouplesRectif)
166 153
167 unicityAllList <- cbind.data.frame(unicityAllList, score_unicite=unicityAllList$NbCouplesAnnotes/unicityAllList$theoricalLength) 154 unicityAllList <- cbind.data.frame(unicityAllList, score_unicite = unicityAllList$NbCouplesAnnotes / unicityAllList$theoricalLength)
168 unicityAllList <- unicityAllList[, -3] 155 unicityAllList <- unicityAllList[, -3]
169 unicityAllList <- unicityAllList[, -4] 156 unicityAllList <- unicityAllList[, -4]
170 157
171 ## unicityAllList <- filter(unicityAllList, unicityAllList$score_unicite > seuil_score) 158 unicityAllList <- unicityAllList[unicityAllList$score_unicite > seuil_score, ]
172 unicityAllList <- unicityAllList[unicityAllList$score_unicite > seuil_score,]
173 159
174 listeTotale_metabo <- data.frame() 160 listeTotale_metabo <- data.frame()
175 if (nrow(commonPpmList) !=0) 161 if (nrow(commonPpmList) != 0) {
176 { 162 for (o in seq_len(length(commonPpmList[, 1]))) {
177 for (o in 1:length(commonPpmList[, 1])) 163 tf6 <- (commonMetabolitesPpmAllList$ppm1 == commonPpmList[o, 1] & commonMetabolitesPpmAllList$ppm2 == commonPpmList[o, 2])
178 { 164 w6 <- which(tf6)
179 tf6 <- (commonMetabolitesPpmAllList$ppm1 == commonPpmList[o,1] & commonMetabolitesPpmAllList$ppm2 == commonPpmList[o,2]) 165
180 w6 <- which(tf6) 166 for (s in seq_len(length(w6))) {
181 167 metaboliteAdd <- data.frame(nom_metabolite = commonMetabolitesPpmAllList[w6[s], 3])
182 for (s in 1:length(w6)) 168 commonMetabolitesList <- paste(commonMetabolitesList, metaboliteAdd[1, ], sep = " ")
183 {
184 metaboliteAdd <- data.frame(nom_metabolite=commonMetabolitesPpmAllList[w6[s],3])
185 commonMetabolitesList <- paste(commonMetabolitesList, metaboliteAdd[1,], sep = " ")
186 } 169 }
187 liste_metabo_ppm <- cbind.data.frame(ppm1=commonPpmList[o,1],ppm2=commonPpmList[o,2], commonMetabolitesList) 170 liste_metabo_ppm <- cbind.data.frame(ppm1 = commonPpmList[o, 1], ppm2 = commonPpmList[o, 2], commonMetabolitesList)
188 listeTotale_metabo <- rbind.data.frame(listeTotale_metabo, liste_metabo_ppm) 171 listeTotale_metabo <- rbind.data.frame(listeTotale_metabo, liste_metabo_ppm)
189 commonMetabolitesList <- data.frame() 172 commonMetabolitesList <- data.frame()
190 } 173 }
191 } 174 }
192 175
193 # Representation graphique 176 # Representation graphique
194 if (nom_sequence == "HSQC" | nom_sequence == "HMBC") 177 if (nom_sequence == "HSQC" | nom_sequence == "HMBC") {
195 {
196 atome <- "13C" 178 atome <- "13C"
197 indice_positif <- 1 179 indice_positif <- 1
198 indice_negatif <- -10 180 indice_negatif <- -10
199 }else{ 181 } else {
200 atome <- "1H" 182 atome <- "1H"
201 indice_positif <- 0.5 183 indice_positif <- 0.5
202 indice_negatif <- -0.5 184 indice_negatif <- -0.5
203 } 185 }
204 186
205 matriceComplexe <- matrixAnnotation 187 matriceComplexe <- matrixAnnotation
206 ppm1 <- as.numeric(matriceComplexe[,2]) 188 ppm1 <- as.numeric(matriceComplexe[, 2])
207 ppm2 <- as.numeric(matriceComplexe[,3]) 189 ppm2 <- as.numeric(matriceComplexe[, 3])
208 190
209 if (unicite == "NO") 191 if (unicite == "NO") {
210 {
211 listeTotale_2D_a_utiliser <- allMetabolitesList 192 listeTotale_2D_a_utiliser <- allMetabolitesList
212 d1.ppm <- allMetabolitesList$ppm1 193 d1.ppm <- allMetabolitesList$ppm1
213 d2.ppm <- allMetabolitesList$ppm2 194 d2.ppm <- allMetabolitesList$ppm2
214 }else{ 195 } else {
215 listeTotale_2D_a_utiliser <- unicityAllList 196 listeTotale_2D_a_utiliser <- unicityAllList
216 d1.ppm <- listeTotale_2D_a_utiliser$ppm1 197 d1.ppm <- listeTotale_2D_a_utiliser$ppm1
217 d2.ppm <- listeTotale_2D_a_utiliser$ppm2 198 d2.ppm <- listeTotale_2D_a_utiliser$ppm2
218 } 199 }
219 200
220 if (nrow(listeTotale_2D_a_utiliser) > 0) 201 if (nrow(listeTotale_2D_a_utiliser) > 0) {
221 {
222 ## Taches de correlations 202 ## Taches de correlations
223 # Matrice biologique + Annotations 203 # Matrice biologique + Annotations
224 maxX <- max(round(max(as.numeric(matriceComplexe[,2])))+0.5, round(max(as.numeric(matriceComplexe[,2])))) 204 maxX <- max(round(max(as.numeric(matriceComplexe[, 2]))) + 0.5, round(max(as.numeric(matriceComplexe[, 2]))))
225 maxY <- max(round(max(as.numeric(matriceComplexe[,3])))+indice_positif, round(max(as.numeric(matriceComplexe[,3])))) 205 maxY <- max(round(max(as.numeric(matriceComplexe[, 3]))) + indice_positif, round(max(as.numeric(matriceComplexe[, 3]))))
226 probability.score <- as.factor(round(listeTotale_2D_a_utiliser[,4],2)) 206 probability.score <- as.factor(round(listeTotale_2D_a_utiliser[, 4], 2))
227 lgr <- length(unique(probability.score)) 207 lgr <- length(unique(probability.score))
228 sp <- ggplot(matriceComplexe, aes(x=ppm1, y=ppm2)) 208 sp <- ggplot(matriceComplexe, aes(x = ppm1, y = ppm2))
229 sp <- sp + geom_point(size=2) + scale_x_reverse(breaks=seq(maxX, 0, -0.5)) + 209 sp <- sp + geom_point(size = 2) + scale_x_reverse(breaks = seq(maxX, 0, -0.5)) +
230 scale_y_reverse(breaks=seq(maxY, 0, indice_negatif)) + 210 scale_y_reverse(breaks = seq(maxY, 0, indice_negatif)) +
231 xlab("1H chemical shift (ppm)") + ylab(paste(atome, " chemical shift (ppm)")) + ggtitle(nom_sequence) + 211 xlab("1H chemical shift (ppm)") + ylab(paste(atome, " chemical shift (ppm)")) + ggtitle(nom_sequence) +
232 geom_text(data=listeTotale_2D_a_utiliser, aes(d1.ppm, d2.ppm, label=str_to_lower(substr(listeTotale_2D_a_utiliser[,3],1,3)), 212 geom_text(data = listeTotale_2D_a_utiliser, aes(d1.ppm, d2.ppm, label = str_to_lower(substr(listeTotale_2D_a_utiliser[, 3], 1, 3)), col = probability.score),
233 col=probability.score), 213 size = 4, hjust = 0, nudge_x = 0.02, vjust = 0, nudge_y = 0.2) + scale_colour_manual(values = viridis(lgr))
234 size=4, hjust=0, nudge_x=0.02, vjust=0, nudge_y=0.2) + scale_colour_manual(values=viridis(lgr))
235 ## scale_color_colormap('Annotation', discrete=T, reverse=T)
236 print(sp) 214 print(sp)
237 } 215 }
238 216
239 # Liste des résultats (couples pmm / metabolite / score) + liste ppms metabolites communs 217 # Liste des resultats (couples pmm / metabolite / score) + liste ppms metabolites communs
240 if (unicite == "NO") 218 if (unicite == "NO") {
241 { 219 return(list(liste_resultat = allMetabolitesList, listing_ppm_commun = listeTotale_metabo))
242 return(list(liste_resultat=allMetabolitesList, listing_ppm_commun=listeTotale_metabo)) 220 } else {
243 }else{ 221 return(list(liste_resultat_unicite = unicityAllList, listing_ppm_commun_affichage = listeTotale_metabo))
244 return(list(liste_resultat_unicite=unicityAllList, listing_ppm_commun_affichage=listeTotale_metabo))
245 } 222 }
246 } 223 }