diff flagRemove.R @ 9:ac284b969836 draft

planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 20a48a1862267264f98b7c514287f9a5cba1143f
author computational-metabolomics
date Thu, 13 Jun 2024 11:35:57 +0000
parents e98ae5c1f4e7
children
line wrap: on
line diff
--- a/flagRemove.R	Wed Jun 12 16:01:28 2024 +0000
+++ b/flagRemove.R	Thu Jun 13 11:35:57 2024 +0000
@@ -1,4 +1,5 @@
 library(msPurity)
+library(xcms)
 library(optparse)
 print(sessionInfo())
 option_list <- list(
@@ -117,19 +118,25 @@
 
 print(opt)
 
-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"))
-        xcms::sampclass(xset) <- xset@phenoData$sample_group
-        return(xset)
-    }
-}
+# This R function can handle both XCMS object versions (so following code
+# no longer required - kept here for reference)
+# 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"))
+#     if (!is.null(xset@phenoData$sample_group)){
+#       xcms::sampclass(xset) <- xset@phenoData$sample_group
+#     }else{
+#       xcms::sampclass(xset) <- "."
+#     }
+#     return(xset)
+#   }
+# }
 
 
 loadRData <- function(rdata_path, name) {
@@ -138,9 +145,9 @@
     return(get(ls()[ls() %in% name]))
 }
 
-xset <- getxcmsSetObject(loadRData(opt$xset_path, c("xset", "xdata")))
+xset <- loadRData(opt$xset_path, c("xset", "xdata"))
 
-print(xset)
+
 if (is.null(opt$samplelist)) {
     blank_class <- opt$blank_class
 } else {
@@ -157,6 +164,8 @@
 }
 
 
+
+
 if (is.null(opt$multilist)) {
     ffrm_out <- flag_remove(xset,
         pol = opt$polarity,
@@ -201,15 +210,6 @@
     )
 } else {
     # nolint start
-    # TODO
-    # xsets <- split(xset, multilist_df$multlist)
-    #
-    # mult_grps <- unique(multilist_df$multlist)
-    #
-    # for (mgrp in mult_grps){
-    #   xset_i <- xsets[mgrp]
-    #   xcms::group(xset_i,
-    #
-    # }
+    # TODO - potential for multilist analysis (e)
     # nolint end
 }