Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 36 additions & 21 deletions tools/nmr_annotation2d/annotationRmn2D.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
##########################################################################
# ANNOTATION SPECTRE 2D MATRICE COMPLEXE BASEE SUR UNE SEQUENCE RMN #
# matriceComplexe : data.frame liste couples ppm de la matrice a annoter #
# BdDStandards : objet contenant la base de donnees des composes standards #
# nom_sequence : nom sequence 2D a utiliser pour annotation ("JRES", "COSY", "TOCSY", "HMBC", "HSQC") #
# ppm1Tol : tolerance ppm axe abscisses #
# ppm2Tol : tolerance ppm axe ordonnees #
# nb_ligne_template : preciser le nombre total de ligne de la feuille de calcul a annoter #
#######################################################################################################
###########################################################################################################################################
# ANNOTATION SPECTRE 2D MATRICE COMPLEXE BASEE SUR UNE SEQUENCE RMN #
# matriceComplexe : data.frame liste couples ppm de la matrice a annoter #
# BdDStandards : objet contenant la base de donnees des composes standards #
# nom_s�quence : nom sequence 2D a utiliser pour annotation ("JRES","COSY","TOCSY","HMBC","HSQC") #
# ppm1Tol : tolerance ppm axe abscisses #
# ppm2Tol : tolerance ppm axe ordonnees #
# nb_ligne_template : pr�ciser le nombre total de ligne de la feuille de calcul annoter #
###########################################################################################################################################
annotationRmn2D <- function(matriceComplexe, BdDStandards, nom_sequence, ppm1Tol = 0.01, ppm2Tol = 0.01,
seuil = 0, unicite = "NO") {
## Longueur de la peak-list de la matrice a annoter
Expand All @@ -19,14 +19,15 @@ annotationRmn2D <- function(matriceComplexe, BdDStandards, nom_sequence, ppm1Tol
seuil_score <- seuil

## Boucle sur les metabolites inclus dans BdD
for (i in seq_len(nbMetabolitesBdD)) {
for (i in 1:nbMetabolitesBdD)
{
## Infos metabolite en cours
iMetabolite <- BdDStandards[[i]]
ppm1M <- iMetabolite[, 1]
ppm2M <- iMetabolite[, 2]
nbPeakMetabolite <- length(ppm1M)
MetaboliteName <- names(BdDStandards[i])

## print(MetaboliteName)
## Initialisation
k <- 0
presenceScore <- 0
Expand All @@ -37,7 +38,8 @@ annotationRmn2D <- function(matriceComplexe, BdDStandards, nom_sequence, ppm1Tol
metabolitesList <- data.frame()

## Boucle sur les couples de pics de la matrice a annoter
for (p in seq_len(PeakListLength)) {
for (p in 1:PeakListLength)
{
ppmAnnotationF1 <- as.numeric(matriceComplexe[p, 3])
ppmAnnotationF2 <- as.numeric(matriceComplexe[p, 2])
e <- simpleMessage("end of file")
Expand All @@ -52,7 +54,8 @@ annotationRmn2D <- function(matriceComplexe, BdDStandards, nom_sequence, ppm1Tol
WhichMetaboliteIn <- which(metaboliteIn)
# Si au moins un couple de la matrice a annoter dans liste couples metabolite standard
if (length(WhichMetaboliteIn) > 0) {
for (a in seq_len(length(WhichMetaboliteIn))) {
for (a in 1:length(WhichMetaboliteIn))
{
annotatedPpmList <- data.frame(ppm1 = ppm1M[WhichMetaboliteIn[a]], ppm2 = ppm2M[WhichMetaboliteIn[a]], theoricalLength = nbPeakMetabolite)
annotatedPpmRef <- rbind(annotatedPpmRef, annotatedPpmList)
}
Expand All @@ -75,7 +78,7 @@ annotationRmn2D <- function(matriceComplexe, BdDStandards, nom_sequence, ppm1Tol
annotatedPeakLength <- nrow(annotatedPpmRef) - sum(duplicated(annotatedPpmRef))
annotatedPpmRef <- annotatedPpmRef[-duplicated(annotatedPpmRef), ]
}
presenceScore <- round(annotatedPeakLength / nbPeakMetabolite, 2)
presenceScore <- annotatedPeakLength / nbPeakMetabolite
}

## Conservation metabolites dont score > seuil
Expand All @@ -91,6 +94,7 @@ annotationRmn2D <- function(matriceComplexe, BdDStandards, nom_sequence, ppm1Tol
commonPpmList <- data.frame()
metaboliteAdd <- data.frame()
metaboliteAddList <- data.frame()
# metabolite_ref <- data.frame()
commonMetabolitesList <- data.frame()
commonMetabolitesPpmList <- data.frame()
commonMetabolitesPpmAllList1 <- data.frame()
Expand All @@ -100,9 +104,11 @@ annotationRmn2D <- function(matriceComplexe, BdDStandards, nom_sequence, ppm1Tol
metabolitesAllUnicite <- data.frame()

## Boucle sur tous couples annotes
for (j in seq_len(length(allMetabolitesList$ppm1))) {
for (j in 1:length(allMetabolitesList$ppm1))
{
## Boucle sur metabolites dans BdD composes standards
for (i in seq_len(nbMetabolitesBdD)) {
for (i in 1:nbMetabolitesBdD)
{
ppmMetaboliteBdD <- BdDStandards[[i]]
ppm1M <- ppmMetaboliteBdD[, 1]
ppm2M <- ppmMetaboliteBdD[, 2]
Expand All @@ -121,6 +127,7 @@ annotationRmn2D <- function(matriceComplexe, BdDStandards, nom_sequence, ppm1Tol
commonPpmList <- unique(commonPpmList)
metaboliteAdd <- data.frame(nom_metabolite = MetaboliteName)
metaboliteAddList <- rbind.data.frame(metaboliteAddList, metaboliteAdd)
# metabolite_ref <- data.frame(nom_metabolite=allMetabolitesList[j,3])
commonMetabolitesList <- rbind.data.frame(data.frame(nom_metabolite = allMetabolitesList[j, 3]), metaboliteAddList)
commonMetabolitesPpmList <- cbind.data.frame(commonPpm, commonMetabolitesList)
commonMetabolitesPpmAllList1 <- rbind.data.frame(commonMetabolitesPpmAllList1, commonMetabolitesPpmList)
Expand All @@ -146,7 +153,8 @@ annotationRmn2D <- function(matriceComplexe, BdDStandards, nom_sequence, ppm1Tol
}

unicitynbCouplesRectif <- data.frame()
for (g in seq_len(nrow(unicityAllList))) {
for (g in 1:nrow(unicityAllList))
{
metaboliteUnicity <- (unicityAllList$Metabolite == unicityAllList$Metabolite[g])
WhichMetaboliteUnicity <- which(metaboliteUnicity)
nb_occurence <- length(WhichMetaboliteUnicity)
Expand All @@ -159,15 +167,18 @@ annotationRmn2D <- function(matriceComplexe, BdDStandards, nom_sequence, ppm1Tol
unicityAllList <- unicityAllList[, -3]
unicityAllList <- unicityAllList[, -4]

## unicityAllList <- filter(unicityAllList, unicityAllList$score_unicite > seuil_score)
unicityAllList <- unicityAllList[unicityAllList$score_unicite > seuil_score, ]

listeTotale_metabo <- data.frame()
if (nrow(commonPpmList) != 0) {
for (o in seq_len(length(commonPpmList[, 1]))) {
for (o in 1:length(commonPpmList[, 1]))
{
tf6 <- (commonMetabolitesPpmAllList$ppm1 == commonPpmList[o, 1] & commonMetabolitesPpmAllList$ppm2 == commonPpmList[o, 2])
w6 <- which(tf6)

for (s in seq_len(length(w6))) {
for (s in 1:length(w6))
{
metaboliteAdd <- data.frame(nom_metabolite = commonMetabolitesPpmAllList[w6[s], 3])
commonMetabolitesList <- paste(commonMetabolitesList, metaboliteAdd[1, ], sep = " ")
}
Expand Down Expand Up @@ -214,13 +225,17 @@ annotationRmn2D <- function(matriceComplexe, BdDStandards, nom_sequence, ppm1Tol
scale_y_reverse(breaks = seq(maxY, 0, indice_negatif)) +
xlab("1H chemical shift (ppm)") + ylab(paste(atome, " chemical shift (ppm)")) + ggtitle(nom_sequence) +
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),
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
),
size = 4, hjust = 0, nudge_x = 0.02, vjust = 0, nudge_y = 0.2
) + scale_colour_manual(values = viridis(lgr))
## scale_color_colormap('Annotation', discrete=T, reverse=T)
print(sp)
}

# Liste des resultats (couples pmm / metabolite / score) + liste ppms metabolites communs
# Liste des r�sultats (couples pmm / metabolite / score) + liste ppms metabolites communs
if (unicite == "NO") {
return(list(liste_resultat = allMetabolitesList, listing_ppm_commun = listeTotale_metabo))
} else {
Expand Down
2 changes: 1 addition & 1 deletion tools/nmr_annotation2d/annotationRmn2D.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tool id="2DNmrAnnotation" name="2DNMRAnnotation" version="2.0.0+galaxy3" profile="20.09">
<tool id="2DNmrAnnotation" name="2DNMRAnnotation" version="2.0.0+galaxy4" profile="20.09">
<description>Annotation of complex mixture bidimensional NMR spectra</description>

<requirements>
Expand Down
Loading
Loading