diff frag4feature.R @ 4:ff61a6fb23bf draft

planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 9ea2ca0892fa55c21491c93afba790e8d9427e01-dirty
author tomnl
date Wed, 04 Apr 2018 17:08:30 -0400
parents 2766f2a85997
children 906e8e2be944
line wrap: on
line diff
--- a/frag4feature.R	Fri Mar 30 10:12:19 2018 -0400
+++ b/frag4feature.R	Wed Apr 04 17:08:30 2018 -0400
@@ -65,12 +65,28 @@
 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]))
+    return(get(ls()[ls() %in% name]))
+}
+
+# This function retrieve a xset like object
+#@author Gildas Le Corguille lecorguille@sb-roscoff.fr
+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)
+    }
 }
 
 # Requires
 pa <- loadRData(opt$pa, 'pa')
-xset <- loadRData(opt$xset, 'xset')
+xset <- loadRData(opt$xset, c('xset','xdata'))
+xset <- getxcmsSetObject(xset)
 
 pa@cores <- opt$cores
 
@@ -102,8 +118,6 @@
 
 if(is.null(opt$grp_peaklist)){
     grp_peaklist = NA
-
-
 }else{
     grp_peaklist = opt$grp_peaklist
 }