# HG changeset patch # User eschen42 # Date 1536201081 14400 # Node ID ddcc33ff32051eb27076992f4c84941f5e66030b # Parent 9a52306991b3d9f6de7c89c03d81c08b8c1324ee planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7 diff -r 9a52306991b3 -r ddcc33ff3205 w4mcorcov.xml --- a/w4mcorcov.xml Sat Sep 01 11:33:03 2018 -0400 +++ b/w4mcorcov.xml Wed Sep 05 22:31:21 2018 -0400 @@ -1,4 +1,4 @@ - + OPLS-DA Contrasts of Univariate Results @@ -419,20 +419,20 @@ - - - - + + + + - - - - + + + + - + @@ -461,6 +461,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + 1 ) { if ( length(level_union) > 2 ) { ## pass 1 - contrast each selected level with all other levels combined into one "super-level" ## @@ -687,12 +705,11 @@ } chosen_samples <- smpl_metadata_facC %in% c(fctr_lvl_1, fctr_lvl_2) fctr_lvl_2 <- "other" - progress_action( - sprintf("calculating/plotting contrast of %s vs. %s" - , fctr_lvl_1, fctr_lvl_2) - ) if (length(unique(chosen_samples)) < 1) { - progress_action("NOTHING TO PLOT...") + progress_action( + sprintf("Skipping contrast of %s vs. %s; there are no chosen samples." + , fctr_lvl_1, fctr_lvl_2) + ) } else { chosen_facC <- as.character(smpl_metadata_facC[chosen_samples]) predictor <- sapply( @@ -704,25 +721,32 @@ my_matrix <- tdm[ chosen_samples, , drop = FALSE ] # only process this column if both factors are members of lvlCSV is_match <- isLevelSelected(fctr_lvl_1) - my_cor_cov <- do_detail_plot( - x_dataMatrix = my_matrix - , x_predictor = predictor - , x_is_match = is_match - , x_algorithm = algoC - , x_prefix = "Features" - , x_show_labels = labelFeatures - , x_progress = progress_action - , x_crossval_i = min(7, length(chosen_samples)) - , x_env = calc_env - ) - if ( is.null(my_cor_cov) ) { - progress_action("NOTHING TO PLOT") + if (is_match) { + progress_action( + sprintf("Calculating/plotting contrast of %s vs. %s" + , fctr_lvl_1, fctr_lvl_2) + ) + my_cor_cov <- do_detail_plot( + x_dataMatrix = my_matrix + , x_predictor = predictor + , x_is_match = is_match + , x_algorithm = algoC + , x_prefix = "Features" + , x_show_labels = labelFeatures + , x_progress = progress_action + , x_crossval_i = min(7, length(chosen_samples)) + , x_env = calc_env + ) + if ( is.null(my_cor_cov) ) { + progress_action("NOTHING TO PLOT...") + } else { + tsv <- my_cor_cov$tsv1 + tsv$mz <- mz_lookup(tsv$featureID) + tsv$rt <- rt_lookup(tsv$featureID) + corcov_tsv_action(tsv) + did_plot <<- TRUE + } } else { - tsv <- my_cor_cov$tsv1 - tsv$mz <- mz_lookup(tsv$featureID) - tsv$rt <- rt_lookup(tsv$featureID) - corcov_tsv_action(tsv) - did_plot <<- TRUE } } "dummy" # need to return a value; otherwise combn fails with an error @@ -738,43 +762,56 @@ fctr_lvl_1 <- x[1] fctr_lvl_2 <- x[2] chosen_samples <- smpl_metadata_facC %in% c(fctr_lvl_1, fctr_lvl_2) - progress_action( - sprintf("calculating/plotting contrast of %s vs. %s" - , fctr_lvl_1, fctr_lvl_2)) if (length(unique(chosen_samples)) < 1) { - progress_action("NOTHING TO PLOT...") + progress_action( + sprintf("Skipping contrast of %s vs. %s. - There are no chosen samples." + , fctr_lvl_1, fctr_lvl_2 + ) + ) } else { chosen_facC <- as.character(smpl_metadata_facC[chosen_samples]) predictor <- chosen_facC my_matrix <- tdm[ chosen_samples, , drop = FALSE ] # only process this column if both factors are members of lvlCSV is_match <- isLevelSelected(fctr_lvl_1) && isLevelSelected(fctr_lvl_2) - my_cor_cov <- do_detail_plot( - x_dataMatrix = my_matrix - , x_predictor = predictor - , x_is_match = is_match - , x_algorithm = algoC - , x_prefix = "Features" - , x_show_labels = labelFeatures - , x_progress = progress_action - , x_crossval_i = min(7, length(chosen_samples)) - , x_env = calc_env - ) - if ( is.null(my_cor_cov) ) { - progress_action("NOTHING TO PLOT") + if (is_match) { + progress_action( + sprintf("Calculating/plotting contrast of %s vs. %s." + , fctr_lvl_1, fctr_lvl_2) + ) + my_cor_cov <- do_detail_plot( + x_dataMatrix = my_matrix + , x_predictor = predictor + , x_is_match = is_match + , x_algorithm = algoC + , x_prefix = "Features" + , x_show_labels = labelFeatures + , x_progress = progress_action + , x_crossval_i = min(7, length(chosen_samples)) + , x_env = calc_env + ) + if ( is.null(my_cor_cov) ) { + progress_action("NOTHING TO PLOT.....") + } else { + tsv <- my_cor_cov$tsv1 + tsv$mz <- mz_lookup(tsv$featureID) + tsv$rt <- rt_lookup(tsv$featureID) + corcov_tsv_action(tsv) + did_plot <<- TRUE + } } else { - tsv <- my_cor_cov$tsv1 - tsv$mz <- mz_lookup(tsv$featureID) - tsv$rt <- rt_lookup(tsv$featureID) - corcov_tsv_action(tsv) - did_plot <<- TRUE + progress_action( + sprintf("Skipping contrast of %s vs. %s." + , fctr_lvl_1, fctr_lvl_2 + ) + ) } } "dummy" # need to return a value; otherwise combn fails with an error } ) } else { - progress_action("NOTHING TO PLOT....") + progress_action("NOTHING TO PLOT......") } } if (!did_plot) { diff -r 9a52306991b3 -r ddcc33ff3205 w4mcorcov_lib.R --- a/w4mcorcov_lib.R Sat Sep 01 11:33:03 2018 -0400 +++ b/w4mcorcov_lib.R Wed Sep 05 22:31:21 2018 -0400 @@ -1,12 +1,3 @@ suppressMessages(library(batch)) -# suppressMessages(library(foreach)) suppressMessages(library(ropls)) suppressMessages(library(methods)) - -# cat("Installed packages:",stderr()) -# write.table((installed.packages(.Library, priority = "high"))[, c(1,3:5)], stderr()) -# cat("Loaded packages:",stderr()) -# write(.packages(), stderr()) - -print(sessionInfo()) - diff -r 9a52306991b3 -r ddcc33ff3205 w4mcorcov_util.R --- a/w4mcorcov_util.R Sat Sep 01 11:33:03 2018 -0400 +++ b/w4mcorcov_util.R Wed Sep 05 22:31:21 2018 -0400 @@ -21,10 +21,54 @@ return (retval) } +errorSink <- function(which_function, ...) { + var_args <- "..." + tryCatch( + var_args <<- (deparse(..., width.cutoff = 60)) + , error = function(e) {print(e$message)} + ) + if (var_args == "...") + return + # format error for logging + format_error <- function(e) { + sprintf( + "Error\n{ message: %s\n, arguments: %s\n}\n" + , e$message + , Reduce(f = paste, x = var_args) + ) + } + format_warning <- function(e) { + sprintf( + "Warning\n{ message: %s\n, arguments: %s\n}\n" + , e$message + , Reduce(f = paste, x = var_args) + ) + } + sink_number <- sink.number() + sink(stderr()) + tryCatch( + var_args <- (deparse(..., width.cutoff = 60)) + , expr = { + retval <- which_function(...) + } + , error = function(e) cat(format_error(e), file = stderr()) + , warning = function(w) cat(format_warning(w), file = stderr()) + ) + while (sink.number() > sink_number) { + sink() + } +} +errorPrint <- function(...) { + errorSink(which_function = print, ...) +} +errorCat <- function(...) { + errorSink(which_function = cat, ..., "\n") +} + # # pseudo-inverse - computational inverse of non-square matrix a # p.i <- function(a) { # solve(t(a) %*% a) %*% t(a) # } - +# vim: sw=2 ts=2 et ai : diff -r 9a52306991b3 -r ddcc33ff3205 w4mcorcov_wrapper.R --- a/w4mcorcov_wrapper.R Sat Sep 01 11:33:03 2018 -0400 +++ b/w4mcorcov_wrapper.R Wed Sep 05 22:31:21 2018 -0400 @@ -72,7 +72,12 @@ # MAIN # ######## +errorPrint(sessionInfo()) + argVc <- unlist(parseCommandArgs(evaluate=FALSE)) +errorCat("\n\n---\n\nArguments that were passed to R are as follows:\n") +errorPrint(argVc) + my_env <- new.env() ##------------------------------