1
|
1 ## =========== This is a copy that can be executed in R environment directly for interactive tests
|
|
2
|
|
3 ## read args:
|
|
4 args <- "test"
|
|
5
|
|
6 ## the constructed DB, e.g. "E:/Rworkspace/metaMS/data/LCDBtest.RData"
|
|
7 args.constructedDB <- "E:/workspace/PRIMS-metabolomics/python-tools/tools/metaMS/test/LCDBtest.RData"
|
|
8 ## data files, e.g. "E:/Rworkspace/metaMS/data/data.zip" (with e.g. .CDF files) and unzip output dir, e.g. "E:/"
|
|
9 args.dataZip <- "E:/workspace/PRIMS-metabolomics/python-tools/tools/metaMS/test/extdata.zip"
|
|
10 args.zipExtrDir <- "E:/workspace/PRIMS-metabolomics/python-tools/tools/metaMS/test/zipOut"
|
|
11 ## settings file, e.g. "E:/Rworkspace/metaMS/data/settings.r", should contain assignment to an object named "customMetaMSsettings"
|
|
12 args.settings <- "E:/workspace/PRIMS-metabolomics/python-tools/tools/metaMS/test/example_settings.txt"
|
|
13
|
|
14 ## output file names, e.g. "E:/Rworkspace/metaMS/data/out.txt"
|
|
15 args.outAnnotationTable <- "E:/workspace/PRIMS-metabolomics/python-tools/tools/metaMS/test/out/annotationTable.txt"
|
|
16 args.outLogFile <- "E:/workspace/PRIMS-metabolomics/python-tools/tools/metaMS/test/out/logfile.txt"
|
|
17
|
|
18 library(metaMS)
|
|
19
|
|
20 ## load the constructed DB :
|
|
21 tempEnv <- new.env()
|
|
22 testDB <- load(args.constructedDB, envir=tempEnv)
|
|
23
|
|
24 ## load the data files from a zip file
|
|
25 files <- unzip(args.dataZip, exdir=args.zipExtrDir)
|
|
26
|
|
27 ## load settings "script" into "customMetaMSsettings"
|
|
28 source(args.settings, local=tempEnv)
|
|
29
|
|
30
|
|
31 # Just to highlight: if you want to use more than one
|
|
32 # trigger runLC:
|
|
33 LC <- runLC(files, settings = tempEnv[["customMetaMSsettings"]], DB = tempEnv[[testDB[1]]]$DB, nSlaves=20, returnXset = TRUE)
|
|
34
|
|
35 # write out runLC annotation results:
|
|
36 write.table(LC$Annotation$annotation.table, args.outAnnotationTable, sep="\t", row.names=FALSE)
|
|
37
|
|
38 # the used constructed DB (write to log):
|
|
39 sink( args.outLogFile )
|
|
40 cat("Constructed DB info===============:")
|
|
41 str(tempEnv[[testDB[1]]]$Info)
|
|
42 cat("Constructed DB table===============:")
|
|
43 sink()
|
|
44 write.table(tempEnv[[testDB[1]]]$DB, args.outLogFile, append=TRUE, row.names=FALSE)
|
|
45 write.table(tempEnv[[testDB[1]]]$Reftable, args.outLogFile, sep="\t", append=TRUE, row.names=FALSE)
|
|
46
|
|
47 # report
|
|
48 LC$xset@xcmsSet
|
|
49 gt <- groups(LC$xset@xcmsSet)
|
|
50 colnames(gt)
|
|
51 groupidx1 <- which(gt[,"rtmed"] > 0 & gt[,"rtmed"] < 3000 & gt[,"npeaks"] > 3)
|
|
52 if (length(groupidx1) > 0)
|
|
53 {
|
|
54 eiccor <- getEIC(LC$xset@xcmsSet, groupidx = c(groupidx1))
|
|
55 eicraw <- getEIC(LC$xset@xcmsSet, groupidx = c(groupidx1), rt = "raw")
|
|
56 for (i in 1:length(groupidx1))
|
|
57 {
|
|
58 png( paste("E:/workspace/PRIMS-metabolomics/python-tools/tools/metaMS/test/out/outplot", i,".png", sep="") )
|
|
59 plot(eiccor, LC$xset@xcmsSet, groupidx = i)
|
|
60 devname = dev.off()
|
|
61 }
|
|
62
|
|
63 }
|
|
64
|
|
65
|