comparison w4mcorcov_wrapper.R @ 6:7bd523ca1f9a draft

planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
author eschen42
date Wed, 18 Jul 2018 12:35:55 -0400
parents 50f60f94c034
children 342570ad880c
comparison
equal deleted inserted replaced
5:50f60f94c034 6:7bd523ca1f9a
31 31
32 ## log file 32 ## log file
33 ##--------- 33 ##---------
34 34
35 my_log <- function(x, ...) { cat(paste(iso8601.znow(), " ", x, ..., nl, sep=""))} 35 my_log <- function(x, ...) { cat(paste(iso8601.znow(), " ", x, ..., nl, sep=""))}
36 my_fatal <- function(x, ...) { 36 my_fatal <- function(x, ...) {
37 my_log("ERROR: ", x, ...) 37 my_log("ERROR: ", x, ...)
38 quit(save = "no", status = 11, runLast = TRUE) 38 quit(save = "no", status = 11, runLast = TRUE)
39 } 39 }
40 40
41 my_log("Start of the '", modNamC, "' Galaxy module call: ") 41 my_log("Start of the '", modNamC, "' Galaxy module call: ")
70 my_env$facC <- as.character(argVc["facC"]) 70 my_env$facC <- as.character(argVc["facC"])
71 my_env$pairSigFeatOnly <- as.logical(argVc["pairSigFeatOnly"]) 71 my_env$pairSigFeatOnly <- as.logical(argVc["pairSigFeatOnly"])
72 my_env$levCSV <- as.character(argVc["levCSV"]) 72 my_env$levCSV <- as.character(argVc["levCSV"])
73 my_env$matchingC <- as.character(argVc["matchingC"]) 73 my_env$matchingC <- as.character(argVc["matchingC"])
74 my_env$labelFeatures <- as.character(argVc["labelFeatures"]) # number of features to label at each extreme of the loadings or 'ALL' 74 my_env$labelFeatures <- as.character(argVc["labelFeatures"]) # number of features to label at each extreme of the loadings or 'ALL'
75 my_env$cplot_o <- as.logical(argVc["cplot_o"]) # TRUE if orthogonal C-plot is requested
76 my_env$cplot_p <- as.logical(argVc["cplot_p"]) # TRUE if parallel C-plot is requested
77 my_env$cplot_y <- as.character(argVc["cplot_y"]) # Choice of covariance/correlation for Y-axis on C-plot
75 78
76 label_features <- my_env$labelFeatures 79 label_features <- my_env$labelFeatures
77 labelfeatures_check <- TRUE 80 labelfeatures_check <- TRUE
78 if ( is.na(label_features) ) { 81 if ( is.na(label_features) ) {
79 labelfeatures_check <- FALSE 82 labelfeatures_check <- FALSE
126 # receiver for result of the call to corcov_calc 129 # receiver for result of the call to corcov_calc
127 my_result <- NULL 130 my_result <- NULL
128 131
129 # compute and plot the correlation_vs_covariance details plot 132 # compute and plot the correlation_vs_covariance details plot
130 # The parameter settings here are generally taken from bioconductor ropls::plot.opls source. 133 # The parameter settings here are generally taken from bioconductor ropls::plot.opls source.
131 marVn <- c(4.6, 4.1, 2.6, 1.6) 134 if ( my_env$cplot_p || my_env$cplot_o ) {
132 old_par <- par( 135 old_par <- par(
133 font = 2 # bold font face 136 font = 2 # bold font face
134 , font.axis = 2 # bold font face for axis 137 , font.axis = 2 # bold font face for axis
135 , font.lab = 2 # bold font face for x and y labels 138 , font.lab = 2 # bold font face for x and y labels
136 , lwd = 2 # line-width - interpretation is device spcific 139 , lwd = 2 # line-width - interpretation is device spcific
137 , mar = marVn # margins 140 , pch = 18 # black diamond plot-character, see help for graphics::points
138 , pch = 18 # black diamond plot-character, see help for graphics::points 141 , pty = "m" # do not force plots to be square
139 # , mfrow = c(2,2) # two rows by two columns 142 , no.readonly = TRUE # only save writable parameters
140 , pty = "s" # force plots to be square 143 )
141 ) 144 pdf_height <- 12
145 pdf_width <- 8
146 my_layout <- function() {
147 # lay out 2 columns by 3 rows with extra width at the margin of individual plots
148 layout(
149 matrix(
150 # blank row plot 1 & 2 blank row plot 3 & 4 blank row plot 5 & 6 blank row
151 c(0,0,0,0,0, 0,1,0,2,0, 0,0,0,0,0, 0,3,0,4,0, 0,0,0,0,0, 0,5,0,6,0, 0,0,0,0,0)
152 , nrow = 7
153 , ncol = 5
154 , byrow = TRUE
155 )
156 # slim columns 1, 3, and 5
157 , widths = c(0.1, 0.9, 0.1, 0.9, 0.1)
158 # slim rows 1, 3, 5, and 7
159 , heights = c(0.1, 0.9, 0.1, 0.9, 0.1, 0.9, 0.1)
160 )
161 }
162 } else {
163 old_par <- par(
164 font = 2 # bold font face
165 , font.axis = 2 # bold font face for axis
166 , font.lab = 2 # bold font face for x and y labels
167 , lwd = 2 # line-width - interpretation is device spcific
168 , pch = 18 # black diamond plot-character, see help for graphics::points
169 , pty = "m" # do not force plots to be square
170 , no.readonly = TRUE # only save writable parameters
171 )
172 pdf_height <- 8
173 pdf_width <- 8
174 my_layout <- function() {
175 # lay out 2 columns by 2 rows with extra width at the margin of individual plots
176 layout(
177 matrix(
178 # blank row plot 1 & 2 blank row plot 3 & 4 blank row
179 c(0,0,0,0,0, 0,1,0,2,0, 0,0,0,0,0, 0,3,0,4,0, 0,0,0,0,0)
180 , nrow = 5
181 , ncol = 5
182 , byrow = TRUE
183 )
184 # slim columns 1, 3, and 5
185 , widths = c(0.1, 0.9, 0.1, 0.9, 0.1)
186 # slim rows 1, 3, and 5
187 , heights = c(0.1, 0.9, 0.1, 0.9, 0.1)
188 )
189 }
190 }
142 plot2pdf( 191 plot2pdf(
143 file.name = my_env$contrast_detail 192 file.name = my_env$contrast_detail
144 , width = 8 193 , width = pdf_width
145 , height = 8 194 , height = pdf_height
146 , plot.function = function() { 195 , plot.function = function() {
147 # plot layout four plots per page 196 # plot layout four or six plots per page
148 layout(matrix(1:4, byrow = TRUE, nrow = 2)) 197 my_layout()
149 my_result <<- corcov_calc( 198 my_result <<- corcov_calc(
150 calc_env = my_env 199 calc_env = my_env
151 , failure_action = my_fatal 200 , failure_action = my_fatal
152 , progress_action = my_log 201 , progress_action = my_log
153 , corcov_tsv_action = corcov_tsv_action 202 , corcov_tsv_action = corcov_tsv_action
154 , salience_tsv_action = salience_tsv_action 203 , salience_tsv_action = salience_tsv_action
155 ) 204 )
156 } 205 }
157 ) 206 )
158 par(old_par) 207 par(old_par)
159 208
160 my_log( "-------------------------- Finished data processing --------------------------") 209 my_log( "-------------------------- Finished data processing --------------------------")
161 } 210 }
162 211
163 my_log( "End of the '", modNamC, "' Galaxy module call") 212 my_log( "End of the '", modNamC, "' Galaxy module call")
164 213