Mercurial > repos > eschen42 > w4mclassfilter
comparison 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 |
comparison
equal
deleted
inserted
replaced
7:582a8a42a93b | 8:d5cf23369d12 |
---|---|
80 variableMetadata_in <- as.character(argVc["variableMetadata_in"]) | 80 variableMetadata_in <- as.character(argVc["variableMetadata_in"]) |
81 variableMetadata_out <- as.character(argVc["variableMetadata_out"]) | 81 variableMetadata_out <- as.character(argVc["variableMetadata_out"]) |
82 | 82 |
83 # other parameters | 83 # other parameters |
84 | 84 |
85 transformation <- as.character(argVc["transformation"]) | |
85 wildcards <- as.logical(argVc["wildcards"]) | 86 wildcards <- as.logical(argVc["wildcards"]) |
86 sampleclassNames <- as.character(argVc["sampleclassNames"]) | 87 sampleclassNames <- as.character(argVc["sampleclassNames"]) |
87 sampleclassNames <- strsplit(x = sampleclassNames, split = ",", fixed = TRUE)[[1]] | 88 sampleclassNames <- strsplit(x = sampleclassNames, split = ",", fixed = TRUE)[[1]] |
88 if (wildcards) { | 89 if (wildcards) { |
89 sampleclassNames <- gsub("[.]", "[.]", sampleclassNames) | 90 sampleclassNames <- gsub("[.]", "[.]", sampleclassNames) |
93 classnameColumn <- as.character(argVc["classnameColumn"]) | 94 classnameColumn <- as.character(argVc["classnameColumn"]) |
94 samplenameColumn <- as.character(argVc["samplenameColumn"]) | 95 samplenameColumn <- as.character(argVc["samplenameColumn"]) |
95 | 96 |
96 variable_range_filter <- as.character(argVc["variable_range_filter"]) | 97 variable_range_filter <- as.character(argVc["variable_range_filter"]) |
97 variable_range_filter <- strsplit(x = variable_range_filter, split = ",", fixed = TRUE)[[1]] | 98 variable_range_filter <- strsplit(x = variable_range_filter, split = ",", fixed = TRUE)[[1]] |
99 | |
100 ## ----------------------------- | |
101 ## Transformation and imputation | |
102 ## ----------------------------- | |
103 my_w4m_filter_imputation <- if (transformation == "log10") { | |
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") | |
111 suppressWarnings( | |
112 # suppress warnings here since non-positive values will produce NaN's that will be fixed in the next step | |
113 m <- log10(m) | |
114 ) | |
115 return ( w4m_filter_imputation(m) ) | |
116 } | |
117 } else if (transformation == "log2") { | |
118 function(m) { | |
119 if (!is.matrix(m)) | |
120 stop("Cannot impute and transform data - the supplied data is not in matrix form") | |
121 if (nrow(m) == 0) | |
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) ) | |
130 } | |
131 } else { | |
132 # use the method from the w4mclassfilter class | |
133 w4m_filter_imputation | |
134 } | |
98 | 135 |
99 ##------------------------------ | 136 ##------------------------------ |
100 ## Computation | 137 ## Computation |
101 ##------------------------------ | 138 ##------------------------------ |
102 | 139 |
111 , include = inclusive | 148 , include = inclusive |
112 , class_column = classnameColumn | 149 , class_column = classnameColumn |
113 , samplename_column = samplenameColumn | 150 , samplename_column = samplenameColumn |
114 , variable_range_filter = variable_range_filter | 151 , variable_range_filter = variable_range_filter |
115 , failure_action = my_print | 152 , failure_action = my_print |
153 , data_imputation = my_w4m_filter_imputation | |
116 ) | 154 ) |
117 | 155 |
118 my_print("\nResult of '", modNamC, "' Galaxy module call to 'w4mclassfilter::w4m_filter_by_sample_class' R function: ", | 156 my_print("\nResult of '", modNamC, "' Galaxy module call to 'w4mclassfilter::w4m_filter_by_sample_class' R function: ", |
119 as.character(result), "\n", sep = "") | 157 as.character(result), "\n", sep = "") |
120 | 158 |