# HG changeset patch # User marie-tremblay-metatoul # Date 1502274490 14400 # Node ID 265ee538e120e51eb5ca72adc1b105599d8640e0 # Parent f3ec6799c43526d2d016e8cc93ca6ea6c9d402a3 Uploaded diff -r f3ec6799c435 -r 265ee538e120 nmr_alignement/NmrAlignment_script.R --- a/nmr_alignement/NmrAlignment_script.R Wed Apr 12 04:32:23 2017 -0400 +++ b/nmr_alignement/NmrAlignment_script.R Wed Aug 09 06:28:10 2017 -0400 @@ -202,8 +202,10 @@ pList[[i]] = sort(pList[[i]]) if (verbose) cat("\n Spectrum ", i, " has ", length(pList[[i]]), - " peaks") + " peaks \n") + cat(myPeakRes) } + cat("\n") return(pList) } @@ -368,18 +370,19 @@ verbose) { ## Peak picking - cat("\n detect peaks....") + cat("\t PEAK DETECTION \n") startTime <- proc.time() peakList <- detectSpecPeaks(X=data, nDivRange=nDivRange, scales=scales, baselineThresh=baselineThresh, SNR.Th = SNR.Th, verbose=verbose) endTime <- proc.time() - cat("Peak detection time:",(endTime[3]-startTime[3])/60," minutes") + cat("\t Peak detection time:",(endTime[3]-startTime[3])/60," minutes \n") + cat("\n") ## Reference spectrum determination if (reference == 0) { - cat("\n Find the spectrum reference...") - resFindRef<- findRef(peakList) + cat("\t DETERMINATION OF THE REFERENCE SPECTRUM \n") + resFindRef <- findRef(peakList) refInd <- resFindRef$refInd cat("\n Order of spectrum for reference \n") for (i in 1:length(resFindRef$orderSpec)) @@ -388,15 +391,19 @@ if (i %% 10 == 0) cat("\n") } - cat("\n The reference is: ", refInd) + cat("\n") + cat("\t Reference spectrum:", refInd, "\n") + cat("\n") } else { refInd=reference } ## Spectra alignment to the reference + cat("\t SPECTRA ALIGNMENT") maxshift <- 50 Y <- dohCluster(data, peakList=peakList, refInd=refInd, maxShift=maxShift, acceptLostPeak, verbose) + cat("\n") ## Output return(Y) diff -r f3ec6799c435 -r 265ee538e120 nmr_alignement/NmrAlignment_wrapper.R --- a/nmr_alignement/NmrAlignment_wrapper.R Wed Apr 12 04:32:23 2017 -0400 +++ b/nmr_alignement/NmrAlignment_wrapper.R Wed Aug 09 06:28:10 2017 -0400 @@ -71,7 +71,7 @@ leftBorder <- argLs[["left_border"]] rightBorder <- argLs[["right_border"]] - ##Exclusion zone(s) + ## Exclusion zone(s) exclusionZones <- argLs[["zone_exclusion_choices.choice"]] exclusionZonesBorders <- NULL if (!is.null(argLs$zone_exclusion_left)) @@ -91,6 +91,17 @@ ## Intensity threshold for peak removal baselineThresh <- argLs[["baselineThresh"]] + ## Graphical zone(s) +graphicalZones <- argLs[["zone_graphical_choices.choice"]] +graphicalZonesBorders <- NULL +if (!is.null(argLs$zone_exclusion_left)) +{ + for(i in which(names(argLs)=="zone_graphical_left")) + { + graphicalZonesBorders <- c(graphicalZonesBorders,list(c(argLs[[i]],argLs[[i+1]]))) + } +} + # Outputs logOut <- argLs[["logOut"]] @@ -98,6 +109,17 @@ graphOut <- argLs[["graphOut"]] +## Checking R packages +##-------------------- +sink(logOut) +cat("\tPACKAGE INFO\n") +#pkgs=c("xcms","batch") +pkgs=c("batch","speaq") +for(pkg in pkgs) { + suppressPackageStartupMessages( stopifnot( library(pkg, quietly=TRUE, logical.return=TRUE, character.only=TRUE))) + cat(pkg,"\t",as.character(packageVersion(pkg)),"\n",sep="") +} + ## Checking arguments ##------------------- error.stock <- "\n" @@ -122,15 +144,10 @@ write.table(t.directory.aligned,file=alignedSpectra,row.names=TRUE,quote=FALSE,sep="\t") -excludedZone <- NULL -for (c in 1:length(exclusionZonesBorders)) -{ - excludedZone <- c(excludedZone,exclusionZonesBorders[[c]]) - excludedZone <- sort(excludedZone) -} - ## Graphical output: overlay of raw and estimated spectra pdf(graphOut,onefile=TRUE) + +graphical.zone.length <- length(graphicalZonesBorders) par(mfrow=c(2,1)) raw.spectra <- data.frame(directory.raw) @@ -142,32 +159,22 @@ drawSpec(raw.spectra,xlab="", ylab="Raw spectra", main="") drawSpec(aligned.spectra,xlab="", ylab="Aligned spectra", main="") -nbZones <- length(excludedZone)/2 -if (nbZones != 0) +if (graphical.zone.length != 0) { - n <- length(excludedZone) - drawSpec(raw.spectra[,1:which(round(as.numeric(colnames(raw.spectra)),2) == excludedZone[n])[1]],xlab="", ylab="Raw spectra", main="") - drawSpec(aligned.spectra[,1:which(round(as.numeric(colnames(aligned.spectra)),2) == excludedZone[n])[1]],xlab="", ylab="Aligned spectra", main="") - - n <- n - 1 - while (n >= nbZones & nbZones > 1) + # par(mfrow=c(2,1)) + for (g in 1:graphical.zone.length) { - drawSpec(raw.spectra[,(which(round(as.numeric(colnames(raw.spectra)),2) == excludedZone[n])[1]):(which(round(as.numeric(colnames(raw.spectra)),2) == excludedZone[n-1])[1])],xlab="", ylab="Raw spectra", main="") - drawSpec(aligned.spectra[,(which(round(as.numeric(colnames(aligned.spectra)),2) == excludedZone[n])[1]):(which(round(as.numeric(colnames(aligned.spectra)),2) == excludedZone[n-1])[1])],xlab="", ylab="Aligned spectra", main="") - n <- n - 2 + print(paste(g, graphicalZonesBorders[[g]][1], graphicalZonesBorders[[g]][2])) + drawSpec(raw.spectra[,(which(round(as.numeric(colnames(raw.spectra)),2) == graphicalZonesBorders[[g]][1])[1]):(which(round(as.numeric(colnames(raw.spectra)),2) == graphicalZonesBorders[[g]][2])[1])],xlab="", main="") + drawSpec(aligned.spectra[,(which(round(as.numeric(colnames(aligned.spectra)),2) == graphicalZonesBorders[[g]][1])[1]):(which(round(as.numeric(colnames(aligned.spectra)),2) == graphicalZonesBorders[[g]][2])[1])],xlab="", main="") } - - drawSpec(raw.spectra[,(which(round(as.numeric(colnames(raw.spectra)),2) == excludedZone[1])[1]):ncol(raw.spectra)],xlab="", ylab="Raw spectra", main="") - drawSpec(aligned.spectra[,(which(round(as.numeric(colnames(aligned.spectra)),2) == excludedZone[1])[1]):ncol(aligned.spectra)],xlab="", ylab="Aligned spectra", main="") } -drawSpec(raw.spectra[,(which(round(as.numeric(colnames(raw.spectra)),2) == 2.4)[1]):(which(round(as.numeric(colnames(raw.spectra)),2) == 2.8)[1])],xlab="", ylab="Raw spectra", main="") -drawSpec(aligned.spectra[,(which(round(as.numeric(colnames(aligned.spectra)),2) == 2.4)[1]):(which(round(as.numeric(colnames(aligned.spectra)),2) == 2.8)[1])],xlab="", ylab="Aligned spectra", main="") - dev.off() ## Ending ##--------------------- cat("\nEnd of 'NMR alignment' Galaxy module call: ", as.character(Sys.time()), sep = "") +sink() options(stringsAsFactors = strAsFacL) rm(list = ls()) diff -r f3ec6799c435 -r 265ee538e120 nmr_alignement/NmrAlignment_xml.xml --- a/nmr_alignement/NmrAlignment_xml.xml Wed Apr 12 04:32:23 2017 -0400 +++ b/nmr_alignement/NmrAlignment_xml.xml Wed Aug 09 06:28:10 2017 -0400 @@ -1,4 +1,4 @@ - + based on the Cluster-based Peak Alignment (CluPA) algorithm r-batch @@ -40,6 +40,15 @@ ## Intensity threshold baselineThresh $baselineThresh + ## Graphical zone + zone_graphical_choices.choice ${zone_graphical_choices.choice} + #if str($zone_graphical_choices.choice) == 'yes': + #for $i in $zone_graphical_choices.conditions: + zone_graphical_left ${i.zone_graphical_left} + zone_graphical_right ${i.zone_graphical_right} + #end for + #end if + ## Outputs logOut '$logOut' alignedSpectra '$alignedSpectra' @@ -75,9 +84,24 @@ + + + + + + + + + + + + + + + @@ -104,6 +128,13 @@ + + + + + + + @@ -234,6 +265,13 @@ | Default value: 1 | +Graphical zone(s) + | Spectral regions to display + | If YES: parameters **Lower graphical zone** and **Upper graphical zone** are visible, + | If NO: no zone to display + | Default value is NO + | + ------------ Output files