Mercurial > repos > eschen42 > w4mclassfilter
diff w4mclassfilter_wrapper.R @ 8:d5cf23369d12 draft
planemo upload for repository https://github.com/HegemanLab/w4mclassfilter_galaxy_wrapper/tree/master commit 7b824bc01884125dc8bb2e4c9ef70fb0a6d88db1
author | eschen42 |
---|---|
date | Sat, 03 Mar 2018 22:58:14 -0500 |
parents | 38ccf6722d54 |
children | 38f509903a0b |
line wrap: on
line diff
--- a/w4mclassfilter_wrapper.R Mon Jan 29 21:20:07 2018 -0500 +++ b/w4mclassfilter_wrapper.R Sat Mar 03 22:58:14 2018 -0500 @@ -82,6 +82,7 @@ # other parameters +transformation <- as.character(argVc["transformation"]) wildcards <- as.logical(argVc["wildcards"]) sampleclassNames <- as.character(argVc["sampleclassNames"]) sampleclassNames <- strsplit(x = sampleclassNames, split = ",", fixed = TRUE)[[1]] @@ -96,6 +97,42 @@ variable_range_filter <- as.character(argVc["variable_range_filter"]) variable_range_filter <- strsplit(x = variable_range_filter, split = ",", fixed = TRUE)[[1]] +## ----------------------------- +## Transformation and imputation +## ----------------------------- +my_w4m_filter_imputation <- if (transformation == "log10") { + function(m) { + if (!is.matrix(m)) + stop("Cannot impute and transform data - the supplied data is not in matrix form") + if (nrow(m) == 0) + stop("Cannot impute and transform data - data matrix has no rows") + if (ncol(m) == 0) + stop("Cannot impute and transform 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) ) + } +} else if (transformation == "log2") { + function(m) { + if (!is.matrix(m)) + stop("Cannot impute and transform data - the supplied data is not in matrix form") + if (nrow(m) == 0) + stop("Cannot impute and transform data - data matrix has no rows") + if (ncol(m) == 0) + stop("Cannot impute and transform 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) ) + } +} else { + # use the method from the w4mclassfilter class + w4m_filter_imputation +} + ##------------------------------ ## Computation ##------------------------------ @@ -113,6 +150,7 @@ , samplename_column = samplenameColumn , variable_range_filter = variable_range_filter , failure_action = my_print +, data_imputation = my_w4m_filter_imputation ) my_print("\nResult of '", modNamC, "' Galaxy module call to 'w4mclassfilter::w4m_filter_by_sample_class' R function: ",