diff flagRemove.R @ 9:f11c129a4227 draft

planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 20a48a1862267264f98b7c514287f9a5cba1143f
author computational-metabolomics
date Thu, 13 Jun 2024 11:40:53 +0000
parents 94a2b6571758
children
line wrap: on
line diff
--- a/flagRemove.R	Wed Jun 12 16:06:42 2024 +0000
+++ b/flagRemove.R	Thu Jun 13 11:40:53 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
 }