Mercurial > repos > pieterlukasse > prims_metabolomics
diff test/Copy of metaMS_cmd_interface.r @ 1:071a185c2ced
new tools
author | pieter.lukasse@wur.nl |
---|---|
date | Fri, 24 Oct 2014 12:52:56 +0200 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/Copy of metaMS_cmd_interface.r Fri Oct 24 12:52:56 2014 +0200 @@ -0,0 +1,65 @@ +## =========== This is a copy that can be executed in R environment directly for interactive tests + +## read args: +args <- "test" + +## the constructed DB, e.g. "E:/Rworkspace/metaMS/data/LCDBtest.RData" +args.constructedDB <- "E:/workspace/PRIMS-metabolomics/python-tools/tools/metaMS/test/LCDBtest.RData" +## data files, e.g. "E:/Rworkspace/metaMS/data/data.zip" (with e.g. .CDF files) and unzip output dir, e.g. "E:/" +args.dataZip <- "E:/workspace/PRIMS-metabolomics/python-tools/tools/metaMS/test/extdata.zip" +args.zipExtrDir <- "E:/workspace/PRIMS-metabolomics/python-tools/tools/metaMS/test/zipOut" +## settings file, e.g. "E:/Rworkspace/metaMS/data/settings.r", should contain assignment to an object named "customMetaMSsettings" +args.settings <- "E:/workspace/PRIMS-metabolomics/python-tools/tools/metaMS/test/example_settings.txt" + +## output file names, e.g. "E:/Rworkspace/metaMS/data/out.txt" +args.outAnnotationTable <- "E:/workspace/PRIMS-metabolomics/python-tools/tools/metaMS/test/out/annotationTable.txt" +args.outLogFile <- "E:/workspace/PRIMS-metabolomics/python-tools/tools/metaMS/test/out/logfile.txt" + +library(metaMS) + +## load the constructed DB : +tempEnv <- new.env() +testDB <- load(args.constructedDB, envir=tempEnv) + +## load the data files from a zip file +files <- unzip(args.dataZip, exdir=args.zipExtrDir) + +## load settings "script" into "customMetaMSsettings" +source(args.settings, local=tempEnv) + + +# Just to highlight: if you want to use more than one +# trigger runLC: +LC <- runLC(files, settings = tempEnv[["customMetaMSsettings"]], DB = tempEnv[[testDB[1]]]$DB, nSlaves=20, returnXset = TRUE) + +# write out runLC annotation results: +write.table(LC$Annotation$annotation.table, args.outAnnotationTable, sep="\t", row.names=FALSE) + +# the used constructed DB (write to log): +sink( args.outLogFile ) +cat("Constructed DB info===============:") +str(tempEnv[[testDB[1]]]$Info) +cat("Constructed DB table===============:") +sink() +write.table(tempEnv[[testDB[1]]]$DB, args.outLogFile, append=TRUE, row.names=FALSE) +write.table(tempEnv[[testDB[1]]]$Reftable, args.outLogFile, sep="\t", append=TRUE, row.names=FALSE) + +# report +LC$xset@xcmsSet +gt <- groups(LC$xset@xcmsSet) +colnames(gt) +groupidx1 <- which(gt[,"rtmed"] > 0 & gt[,"rtmed"] < 3000 & gt[,"npeaks"] > 3) +if (length(groupidx1) > 0) +{ + eiccor <- getEIC(LC$xset@xcmsSet, groupidx = c(groupidx1)) + eicraw <- getEIC(LC$xset@xcmsSet, groupidx = c(groupidx1), rt = "raw") + for (i in 1:length(groupidx1)) + { + png( paste("E:/workspace/PRIMS-metabolomics/python-tools/tools/metaMS/test/out/outplot", i,".png", sep="") ) + plot(eiccor, LC$xset@xcmsSet, groupidx = i) + devname = dev.off() + } + +} + +