Mercurial > repos > eschen42 > w4mclassfilter
diff w4mclassfilter_wrapper.R @ 13:b24ca78a425b draft
planemo upload for repository https://github.com/HegemanLab/w4mclassfilter_galaxy_wrapper/tree/master commit 32cf96ed6c39a93eb9c6cf00494b128bd3c3febe
author | eschen42 |
---|---|
date | Mon, 03 Sep 2018 22:28:03 -0400 |
parents | 518cc205f289 |
children |
line wrap: on
line diff
--- a/w4mclassfilter_wrapper.R Fri Mar 02 08:29:53 2018 -0500 +++ b/w4mclassfilter_wrapper.R Mon Sep 03 22:28:03 2018 -0400 @@ -102,18 +102,31 @@ ## ----------------------------- 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) ) - # 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) + 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