Mercurial > repos > marie-tremblay-metatoul > nmr_alignment
diff nmr_alignement/NmrAlignment_wrapper.R @ 3:f3ec6799c435 draft
Uploaded
author | marie-tremblay-metatoul |
---|---|
date | Wed, 12 Apr 2017 04:32:23 -0400 |
parents | 908e1345d7ca |
children | 265ee538e120 |
line wrap: on
line diff
--- a/nmr_alignement/NmrAlignment_wrapper.R Fri Mar 31 09:56:39 2017 -0400 +++ b/nmr_alignement/NmrAlignment_wrapper.R Wed Apr 12 04:32:23 2017 -0400 @@ -17,7 +17,7 @@ ## Libraries loading ##------------------------------ # ParseCommandArgs function -library(batch) +library(batch) # Alignment library(speaq) @@ -51,7 +51,7 @@ if(!runExampleL) argLs <- parseCommandArgs(evaluate=FALSE) - + ## Parameters Loading ##------------------- # Inputs @@ -61,14 +61,6 @@ zipfile= argLs[["zipfile"]] directory=unzip(zipfile, list=F) directory=paste(getwd(),strsplit(directory[1],"/")[[1]][2],sep="/") -} else if (!is.null(argLs[["library"]])){ - fileType="zip" - directory=argLs[["library"]] - if(!file.exists(directory)){ - error_message=paste("Cannot access the directory :",directory,".Please verify if the directory exists or not.") - print(error_message) - stop(error_message) - } } else if (!is.null(argLs[["tsvfile"]])){ fileType="tsv" directory <- read.table(argLs[["tsvfile"]],check.names=FALSE,header=TRUE,sep="\t") @@ -78,7 +70,7 @@ ## Spectral width leftBorder <- argLs[["left_border"]] rightBorder <- argLs[["right_border"]] - + ##Exclusion zone(s) exclusionZones <- argLs[["zone_exclusion_choices.choice"]] exclusionZonesBorders <- NULL @@ -89,13 +81,13 @@ exclusionZonesBorders <- c(exclusionZonesBorders,list(c(argLs[[i]],argLs[[i+1]]))) } } - + ## Reference spectrum reference <- argLs[["reference"]] ## Size of a small nDivRange nDivRange <- argLs[["nDivRange"]] - + ## Intensity threshold for peak removal baselineThresh <- argLs[["baselineThresh"]] @@ -111,12 +103,12 @@ error.stock <- "\n" if(length(error.stock) > 1) stop(error.stock) - - + + ## Computation ##------------ directory.alignement <- nmr.alignment(fileType=fileType,directory=directory,leftBorder=leftBorder,rightBorder=rightBorder,exclusionZones=exclusionZones, - exclusionZonesBorders=exclusionZonesBorders, reference=reference, nDivRange=nDivRange, + exclusionZonesBorders=exclusionZonesBorders, reference=reference, nDivRange=nDivRange, baselineThresh=baselineThresh, maxshift=50, verbose=FALSE) directory.raw <- directory.alignement[[1]] directory.aligned <- directory.alignement[[2]] @@ -127,7 +119,7 @@ t.directory.aligned <- t(directory.aligned) rownames(t.directory.aligned) <- colnames(directory.aligned) # colnames(t.directory.aligned) <- c("Bucket",colnames(t.directory.aligned)) -write.table(t.directory.aligned,file=alignedSpectra,row.names=TRUE,quote=FALSE,sep="\t") +write.table(t.directory.aligned,file=alignedSpectra,row.names=TRUE,quote=FALSE,sep="\t") excludedZone <- NULL @@ -164,7 +156,7 @@ 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 } - + 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="") }