comparison 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
comparison
equal deleted inserted replaced
11:ba427b16556a 12:518cc205f289
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 suppressWarnings(
106 # suppress warnings here since non-positive values will produce NaN's that will be fixed in the next step
107 m <- log10(m)
108 )
109 # replace NaN values with zero
110 m[is.nan(m)] <- 0
111 # replace NA values with zero
112 m[is.na(m)] <- 0
113 # replace negative values with zero, if applicable (It should never be applicable!)
114 m[m<0] <- 0
115 # return matrix as the result
116 return (m)
117 }
118 } else {
119 # use the method from the w4mclassfilter class
120 w4m_filter_imputation
121 }
98 122
99 ##------------------------------ 123 ##------------------------------
100 ## Computation 124 ## Computation
101 ##------------------------------ 125 ##------------------------------
102 126
111 , include = inclusive 135 , include = inclusive
112 , class_column = classnameColumn 136 , class_column = classnameColumn
113 , samplename_column = samplenameColumn 137 , samplename_column = samplenameColumn
114 , variable_range_filter = variable_range_filter 138 , variable_range_filter = variable_range_filter
115 , failure_action = my_print 139 , failure_action = my_print
140 , data_imputation = my_w4m_filter_imputation
116 ) 141 )
117 142
118 my_print("\nResult of '", modNamC, "' Galaxy module call to 'w4mclassfilter::w4m_filter_by_sample_class' R function: ", 143 my_print("\nResult of '", modNamC, "' Galaxy module call to 'w4mclassfilter::w4m_filter_by_sample_class' R function: ",
119 as.character(result), "\n", sep = "") 144 as.character(result), "\n", sep = "")
120 145