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

Changeset 12:38f509903a0b (2019-10-01)
Previous changeset 11:9f5c0e23c205 (2018-09-03) Next changeset 13:c18040b6e8b9 (2019-10-24)
Commit message:
"planemo upload for repository https://github.com/HegemanLab/w4mclassfilter_galaxy_wrapper/tree/master commit b9712e554d16ed26f6c6d0c2e8cd74552b49f694"
modified:
test-data/expected_dataMatrix.tsv
test-data/rangefilter_dataMatrix.tsv
test-data/rangefilter_sampleMetadata.tsv
w4mclassfilter.xml
w4mclassfilter_wrapper.R
b
diff -r 9f5c0e23c205 -r 38f509903a0b test-data/expected_dataMatrix.tsv
--- a/test-data/expected_dataMatrix.tsv Mon Sep 03 22:34:35 2018 -0400
+++ b/test-data/expected_dataMatrix.tsv Tue Oct 01 16:57:58 2019 -0400
b
@@ -3,7 +3,7 @@
 HMDB00208 747080 595872 3143654 4059767 1433702 5593888 2477288 3346077 4230072
 HMDB00251 368600 94936 293988 352855 767894 268331 310918 1248919 577184
 HMDB00299 250551 456162 808657 614370 250403 768004 504108 1014041 1362408
-HMDB00512 0 280560 556003 590779 209285 342532 569970 525240 246282
+HMDB00512 525240 280560 556003 590779 209285 342532 569970 525240 246282
 HMDB00518 0 85944 129886 175800 13154 230242 440223 315368 10657
 HMDB00715 1252089 905408 5140022 2658555 814523 2558923 4184204 3865723 3236644
 HMDB01032 2569205 1604999 26222916 257139 675754 59906109 31151730 18648127 14989438
b
diff -r 9f5c0e23c205 -r 38f509903a0b test-data/rangefilter_dataMatrix.tsv
--- a/test-data/rangefilter_dataMatrix.tsv Mon Sep 03 22:34:35 2018 -0400
+++ b/test-data/rangefilter_dataMatrix.tsv Tue Oct 01 16:57:58 2019 -0400
b
@@ -1,6 +1,6 @@
- HU_017 HU_028 HU_034 HU_051 HU_060 HU_078 HU_091 HU_093 HU_099 HU_110 HU_130 HU_134 HU_138 HU_149 HU_152 HU_175 HU_178 HU_185 HU_208
-HMDB00191 19.0950724540801 19.5573683394871 19.1351832076319 18.581538968171 19.7610090032025 19.5831195045026 19.3006944055142 19.1741869272827 19.8736633887651 19.7958256457729 19.2864427002132 20.0597101691826 20.4262862563728 21.1281900906526 20.2494039981067 20.8917666482316 19.438513703552 19.5608253922588 19.2486364146654
-HMDB00208 19.5109032146715 23.6779611010349 19.1846429313023 20.1610039089984 22.7740711828923 21.5840110083096 21.9529654992985 20.451313755289 22.4154199380002 22.3652301844309 21.2403301698498 21.6740392144135 22.0122507889717 22.8615935600174 23.0952006159265 23.3011358356974 22.746605551146 20.5866803867983 21.2764220576728
-HMDB01032 21.2928905785523 24.6332887213057 20.6141409677961 18.7154961966847 22.9501240553341 24.6443247870262 17.9721889132336 19.3661386209868 25.8361997953493 18.0050049466979 24.8928089492302 24.1525273990616 23.8374429574498 20.5681658146509 24.2713659930314 22.4140893053724 19.7323297568288 13.958552715431 15.4342372710269
-HMDB01101.1 22.7134708439962 15.6722319530667 11.6247954558602 23.3631578345615 17.8085620299575 22.183613575742 21.8871689158671 19.8971659609365 19.6661147561338 19.214418735272 20.6142092807528 16.1361300108053 18.7553505325418 20.079142288524 20.4818181509538 14.9315685693242 21.3775881248719 16.1536311941017 14.9054340159519
-HMDB13189 21.3346290086766 19.4727602406215 20.6639784491577 19.2400016764968 17.0561931543153 21.3938481405109 19.1797706242895 19.6763582845664 21.7496566885488 20.9339312108399 20.6175661105571 21.7167470481744 20.8887603396637 16.7978767996065 21.5788388647145 21.4643567902489 20.9969706149343 19.9807336965562 19.6828797432404
+ HU_017 HU_028 HU_034 HU_051 HU_060 HU_078 HU_091 HU_093 HU_099 HU_110 HU_130 HU_149 HU_152 HU_175 HU_178 HU_185 HU_208
+HMDB00191 19.0950724540801 19.5573683394871 19.1351832076319 18.581538968171 19.7610090032025 19.5831195045026 19.3006944055142 19.1741869272827 19.8736633887651 19.7958256457729 19.2864427002132 21.1281900906526 20.2494039981067 20.8917666482316 19.438513703552 19.5608253922588 19.2486364146654
+HMDB00208 19.5109032146715 23.6779611010349 19.1846429313023 20.1610039089984 22.7740711828923 21.5840110083096 21.9529654992985 20.451313755289 22.4154199380002 22.3652301844309 21.2403301698498 22.8615935600174 23.0952006159265 23.3011358356974 22.746605551146 20.5866803867983 21.2764220576728
+HMDB01032 21.2928905785523 24.6332887213057 20.6141409677961 18.7154961966847 22.9501240553341 24.6443247870262 17.9721889132336 19.3661386209868 25.8361997953493 18.0050049466979 24.8928089492302 20.5681658146509 24.2713659930314 22.4140893053724 19.7323297568288 13.958552715431 15.4342372710269
+HMDB01101.1 22.7134708439962 15.6722319530667 11.6247954558602 23.3631578345615 17.8085620299575 22.183613575742 21.8871689158671 19.8971659609365 19.6661147561338 19.214418735272 20.6142092807528 20.079142288524 20.4818181509538 14.9315685693242 21.3775881248719 16.1536311941017 14.9054340159519
+HMDB13189 21.3346290086766 19.4727602406215 20.6639784491577 19.2400016764968 17.0561931543153 21.3938481405109 19.1797706242895 19.6763582845664 21.7496566885488 20.9339312108399 20.6175661105571 16.7978767996065 21.5788388647145 21.4643567902489 20.9969706149343 19.9807336965562 19.6828797432404
b
diff -r 9f5c0e23c205 -r 38f509903a0b test-data/rangefilter_sampleMetadata.tsv
--- a/test-data/rangefilter_sampleMetadata.tsv Mon Sep 03 22:34:35 2018 -0400
+++ b/test-data/rangefilter_sampleMetadata.tsv Tue Oct 01 16:57:58 2019 -0400
b
@@ -10,8 +10,6 @@
 HU_099 46 pos 23 21.3 M
 HU_110 53 pos 50 20.9 F
 HU_130 63 pos 33 26.06 M
-HU_134 67 pos 48 22.89 M
-HU_138 68 pos 42 21.88 M
 HU_149 72 pos 35 19.49 F
 HU_152 75 pos 26 17.58 F
 HU_175 87 pos 35 21.26 F
b
diff -r 9f5c0e23c205 -r 38f509903a0b w4mclassfilter.xml
--- a/w4mclassfilter.xml Mon Sep 03 22:34:35 2018 -0400
+++ b/w4mclassfilter.xml Tue Oct 01 16:57:58 2019 -0400
[
b'@@ -1,27 +1,28 @@\n-<tool id="w4mclassfilter" name="W4m Data Subset" version="0.98.11">\n+<tool id="w4mclassfilter" name="W4m Data Subset" version="0.98.13">\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     <requirements>\n-        <!-- <requirement type="package" version="6.2">readline</requirement> -->\n-        <requirement type="package" version="3.4.1">r-base</requirement>\n-        <requirement type="package" version="1.1_4">r-batch</requirement>\n-        <requirement type="package" version="0.98.8">w4mclassfilter</requirement>\n+        <requirement type="package" version="3.6.1">r-base</requirement>\n+        <requirement type="package" version="1.1_5">r-batch</requirement>\n+        <requirement type="package" version="0.98.13">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+    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-    dataMatrix_out \'$dataMatrix_out\'\n-    sampleMetadata_out \'$sampleMetadata_out\'\n-    variableMetadata_out \'$variableMetadata_out\'\n+    transformation        \'$transformation\'\n+    imputation            \'$imputation\'\n+    dataMatrix_out        \'$dataMatrix_out\'\n+    sampleMetadata_out    \'$sampleMetadata_out\'\n+    variableMetadata_out  \'$variableMetadata_out\'\n     ]]></command>\n     <inputs>\n         <param name="dataMatrix_in" format="tabular" label="Data matrix file" type="data"\n@@ -95,6 +96,12 @@\n             <option value="log2">log2</option>\n             <option value="log10">log10</option>\n         </param>\n+        <param name="imputation" label="Imputation of missing values" type="select"\n+            help="\'zero\' (the default) - replace missing values with zero; \'center\' - replace missing values with feature-median; \'none\' - perform no imputation">\n+            <option value="zero" selected="true">zero</option>\n+            <option value="center">center</option>\n+            <option value="none">none</option>\n+        </param>\n     </inputs>\n     <outputs>\n         <data name="dataMatrix_out" format="tabular" label="${dataMatrix_in.name}.subset" ></data>\n@@ -110,16 +117,27 @@\n         <param name="classnameColumn" value="gender"/>\n         <param name="sampleclassNames" value="M"/>\n         <param name="wildcards" value="FALSE"/>\n-        <param name="inclusive" value="filter-in"/>\n-        <param name="variableRangeFilter" value="FEATMAX:6.30103:,mz:200:,rt::800"/>\n-        <param name="transformation" value="log10"/>\n+        <param name="inclusive" value="TRUE"/>\n+        <param name="variableRangeFilter" value="FEATMAX:2e6:,mz:200:,rt::800"/>\n+        <param name="transformation" value="none"/>\n         <output name="dataMatrix_out">\n           <assert_contents>\n-            <has_text text="5.87336711011293" />\n+            <has_text text="747080" />\n+            <not_has_text text="13420742" />\n+            <not_has_text text="47259" />\n           </assert_contents>\n         </output>\n         <output name="sampleMetadata_out">\n           <assert_contents>\n+            <has_text text="'..b"------+\n+| Names of sample-classes                     | M                             |\n++---------------------------------------------+-------------------------------+\n+| Use 'wild-cards' or 'regular expressions'   | wild-cards                    |\n++---------------------------------------------+-------------------------------+\n+| Exclude/include named classes               | filter-in                     |\n++---------------------------------------------+-------------------------------+\n+| Variable range-filters                      | (Leave this field empty.)     |\n++---------------------------------------------+-------------------------------+\n+| Data transforamtion                         | none                          |\n++---------------------------------------------+-------------------------------+\n+| Missing-value imputation                    | center                        |\n++---------------------------------------------+-------------------------------+\n \n **Expected outputs**\n \n@@ -766,8 +846,6 @@\n | Variable metadata | https://raw.githubusercontent.com/HegemanLab/w4mclassfilter_galaxy_wrapper/master/tools/w4mclassfilter/test-data/expected_variableMetadata.tsv  |\n +-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+\n \n-.. class:: infomark\n-\n ----------------------------\n Running With Range-Filtering\n ----------------------------\n@@ -777,19 +855,23 @@\n \n **Input parameters**\n \n-+------------------------------------+------------------------------------+\n-| Input Parameter                    | Value                              |\n-+====================================+====================================+\n-| Names of sample-classes            | (Leave this field empty.)          |\n-+------------------------------------+------------------------------------+\n-| Include named classes              | filter-out                         |\n-+------------------------------------+------------------------------------+\n-| Column that names the sample-class | gender                             |\n-+------------------------------------+------------------------------------+\n-| Variable range-filters             | FEATMAX:20.93157:,mz:200:,rt::800  |\n-+------------------------------------+------------------------------------+\n-| Data transforamtion                | log2                               |\n-+------------------------------------+------------------------------------+\n++---------------------------------------------+-----------------------------------+\n+| Input Parameter                             | Value                             |\n++=============================================+===================================+\n+| Column that names the sample-class          | sampleMetadata                    |\n++---------------------------------------------+-----------------------------------+\n+| Names of sample-classes                     | HU_13[48]                         |\n++---------------------------------------------+-----------------------------------+\n+| Use 'wild-cards' or 'regular expressions'   | regular-expressions               |\n++---------------------------------------------+-----------------------------------+\n+| Exclude/include named classes               | filter-out                        |\n++---------------------------------------------+-----------------------------------+\n+| Variable range-filters                      | FEATMAX:20.93157:,mz:200:,rt::800 |\n++---------------------------------------------+-----------------------------------+\n+| Data transforamtion                         | log2                              |\n++---------------------------------------------+-----------------------------------+\n+| Missing-value imputation                    | zero                              |\n++---------------------------------------------+-----------------------------------+\n \n **Expected outputs**\n \n"
b
diff -r 9f5c0e23c205 -r 38f509903a0b w4mclassfilter_wrapper.R
--- a/w4mclassfilter_wrapper.R Mon Sep 03 22:34:35 2018 -0400
+++ b/w4mclassfilter_wrapper.R Tue Oct 01 16:57:58 2019 -0400
[
@@ -23,8 +23,8 @@
 
 suppressMessages(library(w4mclassfilter))
 
-if(packageVersion("w4mclassfilter") < "0.98.0")
-    stop("Please use 'w4mclassfilter' versions of 0.98.0 and above")
+if(packageVersion("w4mclassfilter") < "0.98.12")
+    stop("Please use 'w4mclassfilter' versions of 0.98.12 and above")
 
 ## constants
 ##----------
@@ -83,6 +83,16 @@
 # other parameters
 
 transformation <- as.character(argVc["transformation"])
+my_imputation_label <- as.character(argVc["imputation"])
+my_imputation_function <- if (my_imputation_label == "zero") {
+  w4m_filter_zero_imputation
+} else if (my_imputation_label == "center") {
+  w4m_filter_median_imputation
+} else if (my_imputation_label == "none") {
+  w4m_filter_no_imputation
+} else {
+  stop(sprintf("Unknown value %s supplied for 'imputation' parameter.  Expected one of {zero,center,none}."))
+}
 wildcards <- as.logical(argVc["wildcards"])
 sampleclassNames <- as.character(argVc["sampleclassNames"])
 sampleclassNames <- strsplit(x = sampleclassNames, split = ",", fixed = TRUE)[[1]]
@@ -100,37 +110,39 @@
 ## -----------------------------
 ## Transformation and imputation
 ## -----------------------------
-my_w4m_filter_imputation <- if (transformation == "log10") {
+my_transformation_and_imputation <- if (transformation == "log10") {
   function(m) {
     if (!is.matrix(m))
-      stop("Cannot impute and transform data - the supplied data is not in matrix form")
+      stop("Cannot transform and impute data - the supplied data is not in matrix form")
     if (nrow(m) == 0)
-      stop("Cannot impute and transform data - data matrix has no rows")
+      stop("Cannot transform and impute data - data matrix has no rows")
     if (ncol(m) == 0)
-      stop("Cannot impute and transform data - data matrix has no columns")
-    suppressWarnings(
+      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 <- log10(m)
-    )
-    return ( w4m_filter_imputation(m) )
+      m[is.na(m)] <- NA
+    })
+    return ( my_imputation_function(m) )
   }
 } else if (transformation == "log2") {
   function(m) {
     if (!is.matrix(m))
-      stop("Cannot impute and transform data - the supplied data is not in matrix form")
+      stop("Cannot transform and impute data - the supplied data is not in matrix form")
     if (nrow(m) == 0)
-      stop("Cannot impute and transform data - data matrix has no rows")
+      stop("Cannot transform and impute data - data matrix has no rows")
     if (ncol(m) == 0)
-      stop("Cannot impute and transform data - data matrix has no columns")
-    suppressWarnings(
+      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 <- log2(m)
-    )
-    return ( w4m_filter_imputation(m) )
+      m[is.na(m)] <- NA
+    })
+    return ( my_imputation_function(m) )
   }
 } else {
   # use the method from the w4mclassfilter class
-  w4m_filter_imputation
+  my_imputation_function
 }
 
 ##------------------------------
@@ -150,7 +162,7 @@
 , samplename_column     = samplenameColumn
 , variable_range_filter = variable_range_filter
 , failure_action        = my_print
-, data_imputation       = my_w4m_filter_imputation
+, data_imputation       = my_transformation_and_imputation
 )
 
 my_print("\nResult of '", modNamC, "' Galaxy module call to 'w4mclassfilter::w4m_filter_by_sample_class' R function: ",