Mercurial > repos > lecorguille > camera_annotate
comparison CAMERA_annotateDiffreport.r @ 18:cb923396e70f draft
planemo upload commit 459ef7f63e313493aca32441bd821f09e36de48c
| author | lecorguille |
|---|---|
| date | Thu, 29 Aug 2019 11:38:21 -0400 |
| parents | |
| children | 01459b73daf9 |
comparison
equal
deleted
inserted
replaced
| 17:73d82de36369 | 18:cb923396e70f |
|---|---|
| 1 #!/usr/bin/env Rscript | |
| 2 | |
| 3 # ----- PACKAGE ----- | |
| 4 cat("\tSESSION INFO\n") | |
| 5 | |
| 6 #Import the different functions | |
| 7 source_local <- function(fname){ argv <- commandArgs(trailingOnly=FALSE); base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)); source(paste(base_dir, fname, sep="/")) } | |
| 8 source_local("lib.r") | |
| 9 | |
| 10 pkgs=c("CAMERA","multtest","batch") | |
| 11 loadAndDisplayPackages(pkgs) | |
| 12 cat("\n\n"); | |
| 13 | |
| 14 # ----- ARGUMENTS ----- | |
| 15 cat("\tARGUMENTS INFO\n") | |
| 16 | |
| 17 args = parseCommandArgs(evaluate=FALSE) #interpretation of arguments given in command line as an R list of objects | |
| 18 write.table(as.matrix(args), col.names=F, quote=F, sep='\t') | |
| 19 | |
| 20 cat("\n\n"); | |
| 21 | |
| 22 | |
| 23 # ----- PROCESSING INFILE ----- | |
| 24 cat("\tINFILE PROCESSING INFO\n") | |
| 25 | |
| 26 #image is an .RData file necessary to use xset variable given by previous tools | |
| 27 load(args$image); args$image=NULL | |
| 28 | |
| 29 cat("\n\n") | |
| 30 | |
| 31 | |
| 32 # ----- ARGUMENTS PROCESSING ----- | |
| 33 cat("\tARGUMENTS PROCESSING INFO\n") | |
| 34 | |
| 35 # Save arguments to generate a report | |
| 36 if (!exists("listOFargs")) listOFargs=list() | |
| 37 listOFargs[[format(Sys.time(), "%y%m%d-%H:%M:%S_annotatediff")]] = args | |
| 38 | |
| 39 # We unzip automatically the chromatograms from the zip files. | |
| 40 if (!exists("zipfile")) zipfile=NULL | |
| 41 if (!exists("singlefile")) singlefile=NULL | |
| 42 rawFilePath = getRawfilePathFromArguments(singlefile, zipfile, args) | |
| 43 zipfile = rawFilePath$zipfile | |
| 44 singlefile = rawFilePath$singlefile | |
| 45 args = rawFilePath$args | |
| 46 directory = retrieveRawfileInTheWorkingDirectory(singlefile, zipfile) | |
| 47 | |
| 48 # Because so far CAMERA isn't compatible with the new XCMSnExp object | |
| 49 if (exists("xdata")){ | |
| 50 xset <- getxcmsSetObject(xdata) | |
| 51 } | |
| 52 | |
| 53 cat("\n\n") | |
| 54 | |
| 55 | |
| 56 # ----- PROCESSING INFO ----- | |
| 57 cat("\tMAIN PROCESSING INFO\n") | |
| 58 | |
| 59 results_list=annotatediff(xset=xset,args=args,variableMetadataOutput="variableMetadata.tsv") | |
| 60 xa=results_list$xa | |
| 61 diffrep=results_list$diffrep | |
| 62 variableMetadata=results_list$variableMetadata | |
| 63 | |
| 64 cat("\n\n") | |
| 65 | |
| 66 # ----- EXPORT ----- | |
| 67 | |
| 68 cat("\tXSET OBJECT INFO\n") | |
| 69 print(xa) | |
| 70 cat("\n\n") | |
| 71 | |
| 72 #saving R data in .Rdata file to save the variables used in the present tool | |
| 73 objects2save = c("xa","variableMetadata","diffrep","cAnnot","listOFargs","zipfile","singlefile") | |
| 74 save(list=objects2save[objects2save %in% ls()], file="annotatediff.RData") | |
| 75 | |
| 76 cat("\n\n") | |
| 77 | |
| 78 cat("\tDONE\n") |
