changeset 2:b1d4689e8a26 draft

planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7c8cb8294e711ca45f19de7bd9564157527f98db
author tomnl
date Fri, 14 Jun 2019 09:05:29 -0400
parents 92dbd3a31caf
children 0a3e6c28f1ab
files createDatabase.R flagRemove.R
diffstat 2 files changed, 43 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/createDatabase.R	Tue Jun 04 10:38:28 2019 -0400
+++ b/createDatabase.R	Fri Jun 14 09:05:29 2019 -0400
@@ -68,11 +68,25 @@
 print(opt)
 
 loadRData <- function(rdata_path, name){
-  #loads an RData file, and returns the named xset object if it is there
-  load(rdata_path)
-  return(get(ls()[ls() == name]))
+#loads an RData file, and returns the named xset object if it is there
+    load(rdata_path)
+    return(get(ls()[ls() %in% name]))
 }
 
+getxcmsSetObject <- function(xobject) {
+    # XCMS 1.x
+    if (class(xobject) == "xcmsSet")
+        return (xobject)
+    # XCMS 3.x
+    if (class(xobject) == "XCMSnExp") {
+        # Get the legacy xcmsSet object
+        suppressWarnings(xset <- as(xobject, 'xcmsSet'))
+        sampclass(xset) <- xset@phenoData$sample_group
+        return (xset)
+    }
+}
+
+
 print(paste('pa', opt$pa))
 print(opt$xset)
 
@@ -84,8 +98,11 @@
 print(pa@fileList)
 
 
+
 if (opt$xcms_camera_option=='xcms'){
-  xset <- loadRData(opt$xset, 'xset')
+  
+  xset <- loadRData(opt$xset, c('xset','xdata'))
+  xset <- getxcmsSetObject(xset)
   fix <- xset_pa_filename_fix(opt, pa, xset)  
   pa <- fix[[1]]
   xset <- fix[[2]]
@@ -111,9 +128,9 @@
 
 dbPth <- msPurity::createDatabase(pa,
                                    xset=xset,
-#                                   xsa=xa, 
+                                   xsa=xa, 
                                    outDir=opt$outDir,
-#                                   grpPeaklist=grpPeaklist,
+                                   grpPeaklist=grpPeaklist,
                                    dbName='createDatabase_output.sqlite'
 )
 
--- a/flagRemove.R	Tue Jun 04 10:38:28 2019 -0400
+++ b/flagRemove.R	Fri Jun 14 09:05:29 2019 -0400
@@ -71,11 +71,9 @@
               help="Assign True if files for each step saved (for testing purposes) [default = %default]"
   ),
 
-  make_option("--samplelist",  type="character", help="Sample list to determine the blank class"),
+  make_option("--samplelist",  type="character", help="Sample list to determine the blank class")
 
-  make_option("--xset_name",  default="xset",
-              help="Name of the xcmsSet object within the RData file [default = %default]"
-  )
+
 
 
 
@@ -108,13 +106,28 @@
 
 print(opt)
 
-loadRData <- function(rdata_path, xset_name){
+getxcmsSetObject <- function(xobject) {
+    # XCMS 1.x
+    if (class(xobject) == "xcmsSet")
+        return (xobject)
+    # XCMS 3.x
+    if (class(xobject) == "XCMSnExp") {
+        # Get the legacy xcmsSet object
+        suppressWarnings(xset <- as(xobject, 'xcmsSet'))
+        sampclass(xset) <- xset@phenoData$sample_group
+        return (xset)
+    }
+}
+
+
+loadRData <- function(rdata_path, name){
 #loads an RData file, and returns the named xset object if it is there
     load(rdata_path)
-    return(get(ls()[ls() == xset_name]))
+    return(get(ls()[ls() %in% name]))
 }
 
-xset<-loadRData(opt$xset_path, opt$xset_name)
+xset <- loadRData(opt$xset_path, c('xset','xdata'))
+
 print(xset)
 if (is.null(opt$samplelist)){
     blank_class <- opt$blank_class