Repository 'w4mclassfilter'
hg clone https://toolshed.g2.bx.psu.edu/repos/eschen42/w4mclassfilter

Changeset 14:87ec0d3c2266 (2020-01-03)
Previous changeset 13:c18040b6e8b9 (2019-10-24) Next changeset 15:f9cb2244fd01 (2021-03-11)
Commit message:
"planemo upload for repository https://github.com/HegemanLab/w4mclassfilter_galaxy_wrapper/tree/master commit a9664e9a04e49d436ebbb643ba1755397ab759dc"
modified:
LICENSE
README
w4mclassfilter.xml
w4mclassfilter_wrapper.R
b
diff -r c18040b6e8b9 -r 87ec0d3c2266 LICENSE
--- a/LICENSE Thu Oct 24 10:21:23 2019 -0400
+++ b/LICENSE Fri Jan 03 11:07:39 2020 -0500
b
@@ -1,6 +1,6 @@
 MIT License
 
-Copyright (c) 2017 Hegeman Lab
+Copyright (c) 2017-2020 Adrian D. Hegeman's Laboratory
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
b
diff -r c18040b6e8b9 -r 87ec0d3c2266 README
--- a/README Thu Oct 24 10:21:23 2019 -0400
+++ b/README Fri Jan 03 11:07:39 2020 -0500
b
@@ -1,8 +1,17 @@
 Galaxy Wrapper for the w4mclassfilter R Package
-<https://doi.org/10.5281/zenodo.1034793>
+https://doi.org/10.5281/zenodo.1034793
+
+This is a Galaxy tool-wrapper
+https://docs.galaxyproject.org/en/latest/dev/schema.htm
+
+to wrap the w4mclassfilter R package
+https://github.com/HegemanLab/w4mclassfilter
 
-This is a Galaxy tool-wrapper <https://docs.galaxyproject.org/en/latest/dev/schema.htm>
-to wrap the w4mclassfilter R package <https://github.com/HegemanLab/w4mclassfilter> 
-for use with the Workflow4Metabolomics <http://workflow4metabolomics.org/>
-flavor of Galaxy <https://galaxyproject.org/>.
-The tool is built with Planemo <http://planemo.readthedocs.io/en/latest/>.
+for use with the Workflow4Metabolomics
+https://workflow4metabolomics.org
+
+flavor of Galaxy
+https://galaxyproject.org
+
+The tool is tested and deployed with Planemo
+https://planemo.readthedocs.io/en/latest
b
diff -r c18040b6e8b9 -r 87ec0d3c2266 w4mclassfilter.xml
--- a/w4mclassfilter.xml Thu Oct 24 10:21:23 2019 -0400
+++ b/w4mclassfilter.xml Fri Jan 03 11:07:39 2020 -0500
[
b'@@ -1,40 +1,49 @@\n-<tool id="w4mclassfilter" name="W4m Data Subset" version="0.98.14">\n-    <description>Filter W4m data by values or metadata</description>\n-    <!-- Here is the hyphenation standard that I *try* to apply consistently in my documentation: http://www.sandranoonan.com/dont-let-hyphenation-drive-crazy/ -->\n+<tool id="w4mclassfilter" name="W4m Data Subset" version="0.98.18">\n+    <description>Filter W4M data by values or metadata</description>\n+    <!-- Here is the hyphenation standard that I *try* to apply consistently in my documentation: \n+         https://web.archive.org/web/20161014025757/http://www.sandranoonan.com/dont-let-hyphenation-drive-crazy/\n+    -->\n     <requirements>\n-        <requirement type="package" version="3.6.1">r-base</requirement>\n+        <requirement type="package" version="3.6.2">r-base</requirement>\n         <requirement type="package" version="1.1_5">r-batch</requirement>\n-        <requirement type="package" version="0.98.14">w4mclassfilter</requirement>\n+        <requirement type="package" version="0.98.18">w4mclassfilter</requirement>\n     </requirements>\n     <command detect_errors="aggressive"><![CDATA[\n     unset R_HOME;\n-    Rscript $__tool_directory__/w4mclassfilter_wrapper.R\n-    dataMatrix_in         \'$dataMatrix_in\'\n-    sampleMetadata_in     \'$sampleMetadata_in\'\n-    variableMetadata_in   \'$variableMetadata_in\'\n-    sampleclassNames      \'$sampleclassNames\'\n-    inclusive             \'$inclusive\'\n-    wildcards             \'$wildcards\'\n-    classnameColumn       \'$classnameColumn\'\n-    samplenameColumn      \'sampleMetadata\'\n-    variable_range_filter \'$variableRangeFilter\'\n-    transformation        \'$transformation\'\n-    imputation            \'$imputation\'\n-    dataMatrix_out        \'$dataMatrix_out\'\n-    sampleMetadata_out    \'$sampleMetadata_out\'\n-    variableMetadata_out  \'$variableMetadata_out\'\n-    order_vrbl            \'$order_vrbl\'\n-    order_smpl            \'$order_smpl\'\n+    if [ \'$centering\' == \'medoid\' -a \'$imputation\' == \'none\' ]; then\n+    (echo \'medoid\' centering may not be chosen with imputation \'none\' 1>&2);\n+        [ ! 1 ];\n+    else\n+        Rscript\n+        $__tool_directory__/w4mclassfilter_wrapper.R\n+        dataMatrix_in         \'$dataMatrix_in\'\n+        sampleMetadata_in     \'$sampleMetadata_in\'\n+        variableMetadata_in   \'$variableMetadata_in\'\n+        sampleclassNames      \'$sampleclassNames\'\n+        inclusive             \'$inclusive\'\n+        wildcards             \'$wildcards\'\n+        classnameColumn       \'$classnameColumn\'\n+        samplenameColumn      \'sampleMetadata\'\n+        variable_range_filter \'$variableRangeFilter\'\n+        transformation        \'$transformation\'\n+        imputation            \'$imputation\'\n+        dataMatrix_out        \'$dataMatrix_out\'\n+        sampleMetadata_out    \'$sampleMetadata_out\'\n+        variableMetadata_out  \'$variableMetadata_out\'\n+        order_vrbl            \'$order_vrbl\'\n+        order_smpl            \'$order_smpl\'\n+        centering             \'$centering\';\n+    fi\n     ]]></command>\n     <inputs>\n-        <param name="dataMatrix_in" format="tabular" label="Data matrix file" type="data"\n-            help="data matrix, with sample names in first row and feature names in first column" />\n-        <param name="sampleMetadata_in" format="tabular" label="Sample metadata file" type="data"\n-            help="sample metadata, with one row per sample" />\n-        <param name="variableMetadata_in" format="tabular" label="Variable metadata file" type="data"\n-            help="variable metadata, with one row per feature" />\n-        <param name="classnameColumn" label="Column that names the sample-class" type="text" value = "class"\n-            help="name of the column in sample metadata that has the values to be tested against the \'Names of sample-classes\' input parameter">\n+        <param name="dataMatrix_in" format="tabular" label="Data matrix" type="data"\n+            help="Choose data-matrix file (ta'..b'st-data/rangefilter_variableMetadata.tsv |\n +-------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+\n+\n+--------------------------------\n+Example with Treatment-Centering\n+--------------------------------\n+\n+This example retains only the samples that are medoids for their gender.\n+\n+**Input parameters**\n+\n++---------------------------------------------+-----------------------------------+\n+| Input Parameter                             | Value                             |\n++=============================================+===================================+\n+| Column that names the sample class          | gender                            |\n++---------------------------------------------+-----------------------------------+\n+| Sample-class names                          | (Leave this field empty.)         |\n++---------------------------------------------+-----------------------------------+\n+| Exclude/include named classes               | filter-out                        |\n++---------------------------------------------+-----------------------------------+\n+| Use \'wild-cards\' or \'regular expressions\'   | wild-cards                        |\n++---------------------------------------------+-----------------------------------+\n+| Variable range-filters                      | (Leave this field empty.)         |\n++---------------------------------------------+-----------------------------------+\n+| Data transformation                         | none                              |\n++---------------------------------------------+-----------------------------------+\n+| Missing-value imputation                    | zero                              |\n++---------------------------------------------+-----------------------------------+\n+| Sample-sort column                          | gender                            |\n++---------------------------------------------+-----------------------------------+\n+| Feature-sort column                         | rt                                |\n++---------------------------------------------+-----------------------------------+\n+| Compute centers for classes                 | medoid                            |\n++---------------------------------------------+-----------------------------------+\n+\n+**Expected outputs**\n+\n++-------------------+----------------------------------------------------------------------------------------------------------+\n+| Expected Output   | Download from URL                                                                                        |\n++===================+==========================================================================================================+\n+| Data matrix       | https://raw.githubusercontent.com/HegemanLab/w4mclassfilter/master/tests/testthat/exp_cent_medoid_dm.tsv |\n++-------------------+----------------------------------------------------------------------------------------------------------+\n+| Sample metadata   | https://raw.githubusercontent.com/HegemanLab/w4mclassfilter/master/tests/testthat/exp_cent_medoid_sm.tsv |\n++-------------------+----------------------------------------------------------------------------------------------------------+\n+| Variable metadata | https://raw.githubusercontent.com/HegemanLab/w4mclassfilter/master/tests/testthat/exp_cent_medoid_vm.tsv |\n++-------------------+----------------------------------------------------------------------------------------------------------+\n     ]]></help>\n     <citations>\n-        <!-- Giacomoni_2014 W4m 2.5 -->\n+        <!-- Giacomoni_2014 W4M 2.5 -->\n         <citation type="doi">10.1093/bioinformatics/btu813</citation>\n-        <!-- Guitton_2017 W4m 3.0 -->\n+        <!-- Guitton_2017 W4M 3.0 -->\n         <citation type="doi">10.1016/j.biocel.2017.07.002</citation>\n         <!-- Kuhl_2012 CAMERA -->\n         <citation type="doi">10.1021/ac202450g</citation>\n'
b
diff -r c18040b6e8b9 -r 87ec0d3c2266 w4mclassfilter_wrapper.R
--- a/w4mclassfilter_wrapper.R Thu Oct 24 10:21:23 2019 -0400
+++ b/w4mclassfilter_wrapper.R Fri Jan 03 11:07:39 2020 -0500
[
@@ -23,8 +23,16 @@
 
 suppressMessages(library(w4mclassfilter))
 
-if(packageVersion("w4mclassfilter") < "0.98.12")
-    stop("Please use 'w4mclassfilter' versions of 0.98.12 and above")
+expected_version <- "0.98.18"
+actual_version <- packageVersion("w4mclassfilter")
+if(packageVersion("w4mclassfilter") < expected_version) {
+    stop(
+         sprintf(
+             "Unrecoverable error: Version %s of the 'w4mclassfilter' R package was loaded instead of expected version %s",
+             actual_version, expected_version
+         )
+    )
+}
 
 ## constants
 ##----------
@@ -104,8 +112,14 @@
 classnameColumn <- as.character(argVc["classnameColumn"])
 samplenameColumn <- as.character(argVc["samplenameColumn"])
 
-order_smpl <- as.character(argVc["order_smpl"])
 order_vrbl <- as.character(argVc["order_vrbl"])
+centering <- as.character(argVc["centering"])
+order_smpl <-
+  if (centering == 'centroid' || centering == 'median') {
+    "sampleMetadata"
+  } else {
+    as.character(argVc["order_smpl"])
+  }
 
 variable_range_filter <- as.character(argVc["variable_range_filter"])
 variable_range_filter <- strsplit(x = variable_range_filter, split = ",", fixed = TRUE)[[1]]
@@ -115,6 +129,8 @@
 ## -----------------------------
 my_transformation_and_imputation <- if (transformation == "log10") {
   function(m) {
+    # convert negative intensities to missing values
+    m[m < 0] <- NA
     if (!is.matrix(m))
       stop("Cannot transform and impute data - the supplied data is not in matrix form")
     if (nrow(m) == 0)
@@ -130,6 +146,8 @@
   }
 } else if (transformation == "log2") {
   function(m) {
+    # convert negative intensities to missing values
+    m[m < 0] <- NA
     if (!is.matrix(m))
       stop("Cannot transform and impute data - the supplied data is not in matrix form")
     if (nrow(m) == 0)
@@ -144,8 +162,21 @@
     return ( my_imputation_function(m) )
   }
 } else {
-  # use the method from the w4mclassfilter class
-  my_imputation_function
+  function(m) {
+    # convert negative intensities to missing values
+    m[m < 0] <- NA
+    if (!is.matrix(m))
+      stop("Cannot transform and impute data - the supplied data is not in matrix form")
+    if (nrow(m) == 0)
+      stop("Cannot transform and impute data - data matrix has no rows")
+    if (ncol(m) == 0)
+      stop("Cannot transform and impute data - data matrix has no columns")
+    suppressWarnings({
+      # suppress warnings here since non-positive values will produce NaN's that will be fixed in the next step
+      m[is.na(m)] <- NA
+    })
+    return ( my_imputation_function(m) )
+  }
 }
 
 ##------------------------------
@@ -165,6 +196,7 @@
 , samplename_column     = samplenameColumn
 , order_vrbl            = order_vrbl
 , order_smpl            = order_smpl
+, centering             = centering
 , variable_range_filter = variable_range_filter
 , failure_action        = my_print
 , data_imputation       = my_transformation_and_imputation