Mercurial > repos > eschen42 > w4mclassfilter
diff w4mclassfilter_wrapper.R @ 12:518cc205f289 draft
planemo upload for repository https://github.com/HegemanLab/w4mclassfilter_galaxy_wrapper/tree/master commit aaa20ca94614124d11723bb906dee91636144d05
author | eschen42 |
---|---|
date | Fri, 02 Mar 2018 08:29:53 -0500 |
parents | f1eabb5973b1 |
children | b24ca78a425b |
line wrap: on
line diff
--- a/w4mclassfilter_wrapper.R Mon Jan 15 13:36:02 2018 -0500 +++ b/w4mclassfilter_wrapper.R Fri Mar 02 08:29:53 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,29 @@ 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) { + suppressWarnings( + # suppress warnings here since non-positive values will produce NaN's that will be fixed in the next step + m <- log10(m) + ) + # replace NaN values with zero + m[is.nan(m)] <- 0 + # replace NA values with zero + m[is.na(m)] <- 0 + # replace negative values with zero, if applicable (It should never be applicable!) + m[m<0] <- 0 + # return matrix as the result + return (m) + } +} else { + # use the method from the w4mclassfilter class + w4m_filter_imputation +} + ##------------------------------ ## Computation ##------------------------------ @@ -113,6 +137,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: ",