# HG changeset patch # User eschen42 # Date 1578067659 18000 # Node ID 87ec0d3c226660583cf1c311e07b617bf66edcba # Parent c18040b6e8b92b724905aba9358d09b83e9e881c "planemo upload for repository https://github.com/HegemanLab/w4mclassfilter_galaxy_wrapper/tree/master commit a9664e9a04e49d436ebbb643ba1755397ab759dc" 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 @@ -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 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 @@ -1,8 +1,17 @@ Galaxy Wrapper for the w4mclassfilter R Package - +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 -to wrap the w4mclassfilter R package -for use with the Workflow4Metabolomics -flavor of Galaxy . -The tool is built with Planemo . +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 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 @@ -1,40 +1,49 @@ - - Filter W4m data by values or metadata - + + Filter W4M data by values or metadata + - r-base + r-base r-batch - w4mclassfilter + w4mclassfilter &2); + [ ! 1 ]; + else + Rscript + $__tool_directory__/w4mclassfilter_wrapper.R + dataMatrix_in '$dataMatrix_in' + sampleMetadata_in '$sampleMetadata_in' + variableMetadata_in '$variableMetadata_in' + sampleclassNames '$sampleclassNames' + inclusive '$inclusive' + wildcards '$wildcards' + classnameColumn '$classnameColumn' + samplenameColumn 'sampleMetadata' + variable_range_filter '$variableRangeFilter' + transformation '$transformation' + imputation '$imputation' + dataMatrix_out '$dataMatrix_out' + sampleMetadata_out '$sampleMetadata_out' + variableMetadata_out '$variableMetadata_out' + order_vrbl '$order_vrbl' + order_smpl '$order_smpl' + centering '$centering'; + fi ]]> - - - - + + + + @@ -43,14 +52,14 @@ - + - + - + @@ -62,26 +71,25 @@ - + - + - - - + + + - - - + + + + help="List of filters, each specifying the range of permitted values in a column of 'Variable metadata' (specified as 'column:min:max'), as described in '<i>Variable-range filters</i>' section below. List should be comma-separated with no stray space characters. (Leave this empty for no filtering.) [default: empty]"> @@ -92,38 +100,46 @@ - - - - + + + + - - - + help="Choose imputation for missing values. See '<i>Data transformation and imputation</i>' section below. [default: 'zero']"> + + + - + + - + + + + + + + + @@ -194,7 +210,7 @@ - + @@ -203,13 +219,13 @@ - - + + - + @@ -518,7 +534,7 @@ - + @@ -542,7 +558,7 @@ - + @@ -556,6 +572,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + éé - + 10.1093/bioinformatics/btu813 - + 10.1016/j.biocel.2017.07.002 10.1021/ac202450g 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