Mercurial > repos > eschen42 > w4mclassfilter
comparison 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 |
comparison
equal
deleted
inserted
replaced
12:518cc205f289 | 13:b24ca78a425b |
---|---|
100 ## ----------------------------- | 100 ## ----------------------------- |
101 ## Transformation and imputation | 101 ## Transformation and imputation |
102 ## ----------------------------- | 102 ## ----------------------------- |
103 my_w4m_filter_imputation <- if (transformation == "log10") { | 103 my_w4m_filter_imputation <- if (transformation == "log10") { |
104 function(m) { | 104 function(m) { |
105 if (!is.matrix(m)) | |
106 stop("Cannot impute and transform data - the supplied data is not in matrix form") | |
107 if (nrow(m) == 0) | |
108 stop("Cannot impute and transform data - data matrix has no rows") | |
109 if (ncol(m) == 0) | |
110 stop("Cannot impute and transform data - data matrix has no columns") | |
105 suppressWarnings( | 111 suppressWarnings( |
106 # suppress warnings here since non-positive values will produce NaN's that will be fixed in the next step | 112 # suppress warnings here since non-positive values will produce NaN's that will be fixed in the next step |
107 m <- log10(m) | 113 m <- log10(m) |
108 ) | 114 ) |
109 # replace NaN values with zero | 115 return ( w4m_filter_imputation(m) ) |
110 m[is.nan(m)] <- 0 | 116 } |
111 # replace NA values with zero | 117 } else if (transformation == "log2") { |
112 m[is.na(m)] <- 0 | 118 function(m) { |
113 # replace negative values with zero, if applicable (It should never be applicable!) | 119 if (!is.matrix(m)) |
114 m[m<0] <- 0 | 120 stop("Cannot impute and transform data - the supplied data is not in matrix form") |
115 # return matrix as the result | 121 if (nrow(m) == 0) |
116 return (m) | 122 stop("Cannot impute and transform data - data matrix has no rows") |
123 if (ncol(m) == 0) | |
124 stop("Cannot impute and transform data - data matrix has no columns") | |
125 suppressWarnings( | |
126 # suppress warnings here since non-positive values will produce NaN's that will be fixed in the next step | |
127 m <- log2(m) | |
128 ) | |
129 return ( w4m_filter_imputation(m) ) | |
117 } | 130 } |
118 } else { | 131 } else { |
119 # use the method from the w4mclassfilter class | 132 # use the method from the w4mclassfilter class |
120 w4m_filter_imputation | 133 w4m_filter_imputation |
121 } | 134 } |