Mercurial > repos > eschen42 > w4mcorcov
annotate w4mcorcov_calc.R @ 0:23f9fad4edfc draft
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
author | eschen42 |
---|---|
date | Mon, 16 Oct 2017 14:56:52 -0400 |
parents | |
children | 0c2ad44b6c9c |
rev | line source |
---|---|
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
1 # center with 'colMeans()' - ref: http://gastonsanchez.com/visually-enforced/how-to/2014/01/15/Center-data-in-R/ |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
2 center_colmeans <- function(x) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
3 xcenter = colMeans(x) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
4 x - rep(xcenter, rep.int(nrow(x), ncol(x))) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
5 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
6 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
7 #### OPLS-DA |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
8 algoC <- "nipals" |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
9 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
10 do_detail_plot <- function(x_dataMatrix, x_predictor, x_is_match, x_algorithm, x_prefix, x_show_labels, x_progress = print, x_env) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
11 off <- function(x) if (x_show_labels) x else 0 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
12 salience_lookup <- x_env$salience_lookup |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
13 salient_rcv_lookup <- x_env$salient_rcv_lookup |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
14 # x_progress("head(salience_df): ", head(salience_df)) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
15 # x_progress("head(salience): ", head(salience)) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
16 if (x_is_match && ncol(x_dataMatrix) > 0 && length(unique(x_predictor))> 1) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
17 my_oplsda <- opls( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
18 x = x_dataMatrix |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
19 , y = x_predictor |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
20 , algoC = x_algorithm |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
21 , predI = 1 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
22 , orthoI = if (ncol(x_dataMatrix) > 1) 1 else 0 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
23 , printL = FALSE |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
24 , plotL = FALSE |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
25 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
26 my_oplsda_suppLs_y_levels <- levels(as.factor(my_oplsda@suppLs$y)) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
27 fctr_lvl_1 <- my_oplsda_suppLs_y_levels[1] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
28 fctr_lvl_2 <- my_oplsda_suppLs_y_levels[2] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
29 my_cor_vs_cov <- cor_vs_cov( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
30 matrix_x = x_dataMatrix |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
31 , ropls_x = my_oplsda |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
32 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
33 with( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
34 my_cor_vs_cov |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
35 , { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
36 min_x <- min(covariance) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
37 max_x <- max(covariance) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
38 lim_x <- max(sapply(X=c(min_x, max_x), FUN=abs)) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
39 covariance <- covariance / lim_x |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
40 lim_x <- 1.2 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
41 main_label <- sprintf("%s for levels %s versus %s", x_prefix, fctr_lvl_1, fctr_lvl_2) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
42 # print("main_label") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
43 # print(main_label) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
44 main_cex <- min(1.0, 46.0/nchar(main_label)) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
45 # "It is generally accepted that a variable should be selected if vj>1, [27–29], |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
46 # but a proper threshold between 0.83 and 1.21 can yield more relevant variables according to [28]." |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
47 # (Mehmood 2012 doi:10.1186/1748-7188-6-27) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
48 vipco <- pmax(0, pmin(1,(vip4p-0.83)/(1.21-0.83))) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
49 alpha <- 0.1 + 0.4 * vipco |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
50 red <- as.numeric(correlation < 0) * vipco |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
51 blue <- as.numeric(correlation > 0) * vipco |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
52 minus_cor <- -correlation |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
53 minus_cov <- -covariance |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
54 # cex <- salience_lookup(feature = names(minus_cor)) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
55 # cex <- 0.25 + (1.25 * cex / max(cex)) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
56 cex <- 0.75 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
57 plot( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
58 y = minus_cor |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
59 , x = minus_cov |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
60 , type="p" |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
61 , xlim=c(-lim_x, lim_x + off(0.1)) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
62 , ylim=c(-1.0 - off(0.1), 1.0) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
63 , xlab = sprintf("relative covariance(feature,t1)") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
64 , ylab = sprintf("correlation(feature,t1)") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
65 , main = main_label |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
66 , cex.main = main_cex |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
67 , cex = cex |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
68 , pch = 16 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
69 , col = rgb(blue = blue, red = red, green = 0, alpha = alpha) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
70 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
71 low_x <- -0.7 * lim_x |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
72 high_x <- 0.7 * lim_x |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
73 text(x = low_x, y = -0.15, labels = fctr_lvl_1) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
74 text(x = high_x, y = 0.15, labels = fctr_lvl_2) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
75 if (x_show_labels) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
76 text( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
77 y = minus_cor - 0.013 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
78 , x = minus_cov + 0.020 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
79 , cex = 0.3 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
80 , labels = tsv1$featureID |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
81 , col = rgb(blue = blue, red = red, green = 0, alpha = 0.2 + 0.8 * alpha) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
82 , srt = -30 # slant 30 degrees downward |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
83 , adj = 0 # left-justified |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
84 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
85 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
86 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
87 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
88 typeVc <- c("correlation", # 1 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
89 "outlier", # 2 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
90 "overview", # 3 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
91 "permutation", # 4 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
92 "predict-train", # 5 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
93 "predict-test", # 6 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
94 "summary", # 7 = c(2,3,4,9) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
95 "x-loading", # 8 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
96 "x-score", # 9 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
97 "x-variance", # 10 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
98 "xy-score", # 11 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
99 "xy-weight" # 12 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
100 ) # [c(3,8,9)] # [c(4,3,8,9)] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
101 if ( length(my_oplsda@orthoVipVn) > 0 ) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
102 my_typevc <- typeVc[c(9,3,8)] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
103 } else { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
104 my_typevc <- c("(dummy)","overview","(dummy)") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
105 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
106 for (my_type in my_typevc) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
107 if (my_type %in% typeVc) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
108 # print(sprintf("plotting type %s", my_type)) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
109 plot( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
110 x = my_oplsda |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
111 , typeVc = my_type |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
112 , parCexN = 0.4 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
113 , parDevNewL = FALSE |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
114 , parLayL = TRUE |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
115 , parEllipsesL = TRUE |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
116 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
117 } else { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
118 # print("plotting dummy graph") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
119 plot(x=1, y=1, xaxt="n", yaxt="n", xlab="", ylab="", type="n") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
120 text(x=1, y=1, labels="no orthogonal projection is possible") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
121 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
122 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
123 return (my_cor_vs_cov) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
124 } else { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
125 # x_progress(sprintf("x_is_match = %s, ncol(x_dataMatrix) = %d, length(unique(x_predictor)) = %d",x_is_match, ncol(x_dataMatrix), length(unique(x_predictor)))) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
126 return (NULL) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
127 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
128 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
129 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
130 # S-PLOT and OPLS reference: Wiklund_2008 doi:10.1021/ac0713510 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
131 corcov_calc <- function(calc_env, failure_action = stop, progress_action = function(x){}, corcov_tsv_action = function(t){}, salience_tsv_action = function(t){}) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
132 if ( ! is.environment(calc_env) ) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
133 failure_action("corcov_calc: fatal error - 'calc_env' is not an environment") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
134 return ( FALSE ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
135 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
136 if ( ! is.function(corcov_tsv_action) ) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
137 failure_action("corcov_calc: fatal error - 'corcov_tsv_action' is not a function") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
138 return ( FALSE ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
139 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
140 if ( ! is.function(salience_tsv_action) ) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
141 failure_action("salience_calc: fatal error - 'salience_tsv_action' is not a function") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
142 return ( FALSE ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
143 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
144 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
145 # extract parameters from the environment |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
146 vrbl_metadata <- calc_env$vrbl_metadata |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
147 vrbl_metadata_names <- vrbl_metadata[,1] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
148 smpl_metadata <- calc_env$smpl_metadata |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
149 data_matrix <- calc_env$data_matrix |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
150 pairSigFeatOnly <- calc_env$pairSigFeatOnly |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
151 facC <- calc_env$facC |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
152 tesC <- calc_env$tesC |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
153 # extract the levels from the environment |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
154 originalLevCSV <- levCSV <- calc_env$levCSV |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
155 # matchingC is one of { "none", "wildcard", "regex" } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
156 matchingC <- calc_env$matchingC |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
157 labelFeatures <- calc_env$labelFeatures |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
158 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
159 # arg/env checking |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
160 if (!(facC %in% names(smpl_metadata))) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
161 failure_action(sprintf("bad parameter! Factor name '%s' not found in sampleMetadata", facC)) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
162 return ( FALSE ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
163 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
164 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
165 # calculate salience_df as data.frame(feature, max_level, max_median, max_rcv, mean_median, salience, salient_rcv) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
166 salience_df <- calc_env$salience_df <- w4msalience( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
167 data_matrix = data_matrix |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
168 , sample_class = smpl_metadata[,facC] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
169 , failure_action = failure_action |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
170 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
171 salience_tsv_action({ |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
172 my_df <- data.frame( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
173 featureID = salience_df$feature |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
174 , salientLevel = salience_df$max_level |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
175 , salientRCV = salience_df$salient_rcv |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
176 , salience = salience_df$salience |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
177 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
178 my_df[order(-my_df$salience),] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
179 }) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
180 salience <- salience_df$salience |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
181 names(salience) <- salience_df$feature |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
182 salience_lookup <- calc_env$salience_lookup <- function(feature) unname(salience[feature]) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
183 salient_rcv <- salience_df$salient_rcv |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
184 names(salient_rcv) <- salience_df$feature |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
185 salient_rcv_lookup <- calc_env$salient_rcv_lookup <- function(feature) unname(salient_rcv[feature]) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
186 salient_level <- salience_df$max_level |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
187 names(salient_level) <- salience_df$feature |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
188 salient_level_lookup <- calc_env$salient_level_lookup <- function(feature) unname(salient_level[feature]) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
189 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
190 # transform wildcards to regexen |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
191 if (matchingC == "wildcard") { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
192 # strsplit(x = "hello,wild,world", split = ",") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
193 levCSV <- gsub("[.]", "[.]", levCSV) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
194 levCSV <- strsplit(x = levCSV, split = ",") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
195 levCSV <- sapply(levCSV, utils::glob2rx, trim.tail = FALSE) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
196 levCSV <- paste(levCSV, collapse = ",") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
197 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
198 # function to determine whether level is a member of levCSV |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
199 isLevelSelected <- function(lvl) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
200 matchFun <- if (matchingC != "none") grepl else `==` |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
201 return( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
202 Reduce( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
203 f = "||" |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
204 , x = sapply( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
205 X = strsplit( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
206 x = levCSV |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
207 , split = "," |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
208 , fixed = TRUE |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
209 )[[1]] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
210 , FUN = matchFun |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
211 , lvl |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
212 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
213 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
214 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
215 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
216 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
217 # transpose matrix because ropls matrix is the transpose of XCMS matrix |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
218 # Wiklund_2008 centers and pareto-scales data before OPLS-DA S-plot |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
219 # center |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
220 cdm <- center_colmeans(t(data_matrix)) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
221 # pareto-scale |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
222 my_scale <- sqrt(apply(cdm, 2, sd, na.rm=TRUE)) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
223 scdm <- sweep(cdm, 2, my_scale, "/") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
224 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
225 # pattern to match column names like k10_kruskal_k4.k3_sig |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
226 col_pattern <- sprintf('^%s_%s_(.*)[.](.*)_sig$', facC, tesC) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
227 # column name like k10_kruskal_sig |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
228 intersample_sig_col <- sprintf('%s_%s_sig', facC, tesC) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
229 # get the facC column from sampleMetadata, dropping to one dimension |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
230 smpl_metadata_facC <- smpl_metadata[,facC] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
231 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
232 # allocate a slot in the environment for the contrast_list, each element of which will be a data.frame with this structure: |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
233 # - feature ID |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
234 # - value1 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
235 # - value2 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
236 # - Wiklund_2008 correlation |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
237 # - Wiklund_2008 covariance |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
238 # - Wiklund_2008 VIP |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
239 calc_env$contrast_list <- list() |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
240 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
241 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
242 did_plot <- FALSE |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
243 if (tesC != "none") { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
244 # for each column name, extract the parts of the name matched by 'col_pattern', if any |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
245 the_colnames <- colnames(vrbl_metadata) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
246 if ( ! Reduce( f = "||", x = grepl(tesC, the_colnames) ) ) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
247 failure_action(sprintf("bad parameter! variableMetadata must contain results of W4M Univariate test '%s'.", tesC)) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
248 return ( FALSE ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
249 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
250 col_matches <- lapply( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
251 X = the_colnames, |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
252 FUN = function(x) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
253 regmatches( x, regexec(col_pattern, x) )[[1]] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
254 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
255 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
256 ## first contrast each selected level with all other levels combined into one "super-level" ## |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
257 # process columns matching the pattern |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
258 level_union <- c() |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
259 for (i in 1:length(col_matches)) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
260 col_match <- col_matches[[i]] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
261 if (length(col_match) > 0) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
262 # it's an actual match; extract the pieces, e.g., k10_kruskal_k4.k3_sig |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
263 vrbl_metadata_col <- col_match[1] # ^^^^^^^^^^^^^^^^^^^^^ # Column name |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
264 fctr_lvl_1 <- col_match[2] # ^^ # Factor-level 1 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
265 fctr_lvl_2 <- col_match[3] # ^^ # Factor-level 2 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
266 # only process this column if both factors are members of lvlCSV |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
267 is_match <- isLevelSelected(fctr_lvl_1) && isLevelSelected(fctr_lvl_2) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
268 if (is_match) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
269 level_union <- c(level_union, col_match[2], col_match[3]) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
270 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
271 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
272 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
273 level_union <- unique(sort(level_union)) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
274 overall_significant <- 1 == vrbl_metadata[,intersample_sig_col] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
275 if ( length(level_union) > 1 ) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
276 chosen_samples <- smpl_metadata_facC %in% level_union |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
277 chosen_facC <- as.character(smpl_metadata_facC[chosen_samples]) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
278 col_selector <- vrbl_metadata_names[ overall_significant ] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
279 my_matrix <- scdm[ chosen_samples, col_selector, drop = FALSE ] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
280 fctr_lvl_2 <- "other" |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
281 for ( fctr_lvl_1 in level_union[1:length(level_union)] ) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
282 progress_action(sprintf("calculating/plotting contrast of %s vs. %s", fctr_lvl_1, fctr_lvl_2)) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
283 predictor <- sapply( X = chosen_facC, FUN = function(fac) if ( fac == fctr_lvl_1 ) fctr_lvl_1 else fctr_lvl_2 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
284 my_cor_cov <- do_detail_plot( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
285 x_dataMatrix = my_matrix |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
286 , x_predictor = predictor |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
287 , x_is_match = is_match |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
288 , x_algorithm = algoC |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
289 , x_prefix = if (pairSigFeatOnly) "Significantly contrasting features" else "Significant features" |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
290 , x_show_labels = labelFeatures |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
291 , x_progress = progress_action |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
292 , x_env = calc_env |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
293 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
294 if ( is.null(my_cor_cov) ) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
295 progress_action("NOTHING TO PLOT.") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
296 } else { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
297 tsv <- my_cor_cov$tsv1 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
298 # tsv$salientLevel <- salient_level_lookup(tsv$featureID) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
299 # tsv$salientRCV <- salient_rcv_lookup(tsv$featureID) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
300 # tsv$salience <- salience_lookup(tsv$featureID) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
301 tsv["level1Level2Sig"] <- vrbl_metadata[ match(tsv$featureID, vrbl_metadata_names), vrbl_metadata_col ] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
302 corcov_tsv_action(tsv) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
303 did_plot <- TRUE |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
304 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
305 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
306 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
307 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
308 ## next, contrast each selected level with each of the other levels individually ## |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
309 # process columns matching the pattern |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
310 for (i in 1:length(col_matches)) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
311 # for each potential match of the pattern |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
312 col_match <- col_matches[[i]] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
313 if (length(col_match) > 0) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
314 # it's an actual match; extract the pieces, e.g., k10_kruskal_k4.k3_sig |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
315 vrbl_metadata_col <- col_match[1] # ^^^^^^^^^^^^^^^^^^^^^ # Column name |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
316 fctr_lvl_1 <- col_match[2] # ^^ # Factor-level 1 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
317 fctr_lvl_2 <- col_match[3] # ^^ # Factor-level 2 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
318 # only process this column if both factors are members of lvlCSV |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
319 is_match <- isLevelSelected(fctr_lvl_1) && isLevelSelected(fctr_lvl_2) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
320 progress_action(sprintf("calculating/plotting contrast of %s vs. %s", fctr_lvl_1, fctr_lvl_2)) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
321 # TODO delete next line displaying currently-processed column |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
322 # cat(sprintf("%s %s %s %s\n", vrbl_metadata_col, fctr_lvl_1, fctr_lvl_2, is_match)) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
323 # choose only samples with one of the two factors for this column |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
324 chosen_samples <- smpl_metadata_facC %in% c(fctr_lvl_1, fctr_lvl_2) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
325 predictor <- smpl_metadata_facC[chosen_samples] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
326 # extract only the significantly-varying features and the chosen samples |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
327 fully_significant <- 1 == vrbl_metadata[,vrbl_metadata_col] * vrbl_metadata[,intersample_sig_col] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
328 col_selector <- vrbl_metadata_names[ if ( pairSigFeatOnly ) fully_significant else overall_significant ] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
329 my_matrix <- scdm[ chosen_samples, col_selector, drop = FALSE ] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
330 my_cor_cov <- do_detail_plot( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
331 x_dataMatrix = my_matrix |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
332 , x_predictor = predictor |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
333 , x_is_match = is_match |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
334 , x_algorithm = algoC |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
335 , x_prefix = if (pairSigFeatOnly) "Significantly contrasting features" else "Significant features" |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
336 , x_show_labels = labelFeatures |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
337 , x_progress = progress_action |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
338 , x_env = calc_env |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
339 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
340 if ( is.null(my_cor_cov) ) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
341 progress_action("NOTHING TO PLOT.") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
342 } else { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
343 tsv <- my_cor_cov$tsv1 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
344 # tsv$salientLevel <- salient_level_lookup(tsv$featureID) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
345 # tsv$salientRCV <- salient_rcv_lookup(tsv$featureID) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
346 # tsv$salience <- salience_lookup(tsv$featureID) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
347 tsv["level1Level2Sig"] <- vrbl_metadata[ match(tsv$featureID, vrbl_metadata_names), vrbl_metadata_col ] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
348 corcov_tsv_action(tsv) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
349 did_plot <- TRUE |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
350 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
351 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
352 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
353 } else { # tesC == "none" |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
354 level_union <- unique(sort(smpl_metadata_facC)) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
355 if ( length(level_union) > 1 ) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
356 ## pass 1 - contrast each selected level with all other levels combined into one "super-level" ## |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
357 completed <- c() |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
358 lapply( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
359 X = level_union |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
360 , FUN = function(x) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
361 fctr_lvl_1 <- x[1] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
362 fctr_lvl_2 <- { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
363 if ( fctr_lvl_1 %in% completed ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
364 return("DUMMY") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
365 # strF(completed) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
366 completed <<- c(completed, fctr_lvl_1) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
367 setdiff(level_union, fctr_lvl_1) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
368 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
369 chosen_samples <- smpl_metadata_facC %in% c(fctr_lvl_1, fctr_lvl_2) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
370 fctr_lvl_2 <- "other" |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
371 # print( sprintf("sum(chosen_samples) %d, factor_level_2 %s", sum(chosen_samples), fctr_lvl_2) ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
372 progress_action(sprintf("calculating/plotting contrast of %s vs. %s", fctr_lvl_1, fctr_lvl_2)) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
373 if (length(unique(chosen_samples)) < 1) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
374 progress_action("NOTHING TO PLOT...") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
375 } else { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
376 chosen_facC <- as.character(smpl_metadata_facC[chosen_samples]) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
377 predictor <- sapply( X = chosen_facC, FUN = function(fac) if ( fac == fctr_lvl_1 ) fctr_lvl_1 else fctr_lvl_2 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
378 my_matrix <- scdm[ chosen_samples, , drop = FALSE ] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
379 # only process this column if both factors are members of lvlCSV |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
380 is_match <- isLevelSelected(fctr_lvl_1) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
381 my_cor_cov <- do_detail_plot( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
382 x_dataMatrix = my_matrix |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
383 , x_predictor = predictor |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
384 , x_is_match = is_match |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
385 , x_algorithm = algoC |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
386 , x_prefix = "Features" |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
387 , x_show_labels = labelFeatures |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
388 , x_progress = progress_action |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
389 , x_env = calc_env |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
390 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
391 if ( is.null(my_cor_cov) ) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
392 progress_action("NOTHING TO PLOT") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
393 } else { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
394 tsv <- my_cor_cov$tsv1 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
395 # tsv$salientLevel <- salient_level_lookup(tsv$featureID) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
396 # tsv$salientRCV <- salient_rcv_lookup(tsv$featureID) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
397 # tsv$salience <- salience_lookup(tsv$featureID) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
398 corcov_tsv_action(tsv) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
399 did_plot <<- TRUE |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
400 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
401 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
402 #print("baz") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
403 "dummy" # need to return a value; otherwise combn fails with an error |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
404 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
405 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
406 ## pass 2 - contrast each selected level with each of the other levels individually ## |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
407 completed <- c() |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
408 utils::combn( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
409 x = level_union |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
410 , m = 2 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
411 , FUN = function(x) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
412 fctr_lvl_1 <- x[1] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
413 fctr_lvl_2 <- x[2] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
414 chosen_samples <- smpl_metadata_facC %in% c(fctr_lvl_1, fctr_lvl_2) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
415 # print( sprintf("sum(chosen_samples) %d, factor_level_2 %s", sum(chosen_samples), fctr_lvl_2) ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
416 progress_action(sprintf("calculating/plotting contrast of %s vs. %s", fctr_lvl_1, fctr_lvl_2)) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
417 if (length(unique(chosen_samples)) < 1) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
418 progress_action("NOTHING TO PLOT...") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
419 } else { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
420 chosen_facC <- as.character(smpl_metadata_facC[chosen_samples]) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
421 predictor <- chosen_facC |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
422 my_matrix <- scdm[ chosen_samples, , drop = FALSE ] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
423 # only process this column if both factors are members of lvlCSV |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
424 is_match <- isLevelSelected(fctr_lvl_1) && isLevelSelected(fctr_lvl_2) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
425 my_cor_cov <- do_detail_plot( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
426 x_dataMatrix = my_matrix |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
427 , x_predictor = predictor |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
428 , x_is_match = is_match |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
429 , x_algorithm = algoC |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
430 , x_prefix = "Features" |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
431 , x_show_labels = labelFeatures |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
432 , x_progress = progress_action |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
433 , x_env = calc_env |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
434 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
435 if ( is.null(my_cor_cov) ) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
436 progress_action("NOTHING TO PLOT") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
437 } else { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
438 tsv <- my_cor_cov$tsv1 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
439 # tsv$salientLevel <- salient_level_lookup(tsv$featureID) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
440 # tsv$salientRCV <- salient_rcv_lookup(tsv$featureID) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
441 # tsv$salience <- salience_lookup(tsv$featureID) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
442 corcov_tsv_action(tsv) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
443 did_plot <<- TRUE |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
444 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
445 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
446 #print("baz") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
447 "dummy" # need to return a value; otherwise combn fails with an error |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
448 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
449 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
450 } else { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
451 progress_action("NOTHING TO PLOT....") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
452 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
453 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
454 if (!did_plot) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
455 failure_action(sprintf("bad parameter! sampleMetadata must have at least two levels of factor '%s' matching '%s'", facC, originalLevCSV)) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
456 return ( FALSE ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
457 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
458 return ( TRUE ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
459 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
460 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
461 # Calculate data for correlation-versus-covariance plot |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
462 # Adapted from: |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
463 # Wiklund_2008 doi:10.1021/ac0713510 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
464 # Galindo_Prieto_2014 doi:10.1002/cem.2627 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
465 # https://github.com/HegemanLab/extra_tools/blob/master/generic_PCA.R |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
466 cor_vs_cov <- function(matrix_x, ropls_x) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
467 x_class <- class(ropls_x) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
468 if ( !( as.character(x_class) == "opls" ) ) { # || !( attr(class(x_class),"package") == "ropls" ) ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
469 stop( "cor_vs_cov: Expected ropls_x to be of class ropls::opls but instead it was of class ", as.character(x_class) ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
470 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
471 result <- list() |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
472 # suppLs$algoC - Character: algorithm used - "svd" for singular value decomposition; "nipals" for NIPALS |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
473 if ( ropls_x@suppLs$algoC == "nipals") { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
474 # Equations (1) and (2) from *Supplement to* Wiklund 2008, doi:10.1021/ac0713510 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
475 mag <- function(one_dimensional) sqrt(sum(one_dimensional * one_dimensional)) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
476 mag_xi <- sapply(X = 1:ncol(matrix_x), FUN = function(x) mag(matrix_x[,x])) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
477 score_matrix <- ropls_x@scoreMN |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
478 score_matrix_transposed <- t(score_matrix) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
479 score_matrix_magnitude <- mag(score_matrix) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
480 result$covariance <- score_matrix_transposed %*% matrix_x / ( score_matrix_magnitude * score_matrix_magnitude ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
481 result$correlation <- score_matrix_transposed %*% matrix_x / ( score_matrix_magnitude * mag_xi ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
482 } else { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
483 # WARNING - untested code - I don't have test data to exercise this branch |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
484 # Equations (1) and (2) from Wiklund 2008, doi:10.1021/ac0713510 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
485 # scoreMN - Numerical matrix of x scores (T; dimensions: nrow(x) x predI) X = TP' + E; Y = TC' + F |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
486 score_matrix <- ropls_x@scoreMN |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
487 score_matrix_transposed <- t(score_matrix) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
488 cov_divisor <- nrow(matrix_x) - 1 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
489 result$covariance <- sapply( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
490 X = 1:ncol(matrix_x) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
491 , FUN = function(x) score_matrix_transposed %*% matrix_x[,x] / cov_divisor |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
492 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
493 score_sd <- sapply( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
494 X = 1:ncol(score_matrix) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
495 , FUN = function(x) sd(score_matrix[,x]) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
496 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
497 # xSdVn - Numerical vector: variable standard deviations of the 'x' matrix |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
498 xSdVn <- ropls_x@xSdVn |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
499 result$correlation <- sapply( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
500 X = 1:ncol(matrix_x) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
501 , FUN = function(x) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
502 ( score_matrix_transposed / score_sd ) %*% ( matrix_x[,x] / (xSdVn[x] * cov_divisor) ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
503 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
504 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
505 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
506 result$correlation <- result$correlation[1,,drop = TRUE] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
507 result$covariance <- result$covariance[1,,drop = TRUE] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
508 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
509 # Variant 4 of Variable Influence on Projection for OPLS from Galindo_Prieto_2014 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
510 # Length = number of features; labels = feature identifiers. (The same is true for $correlation and $covariance.) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
511 result$vip4p <- as.numeric(ropls_x@vipVn) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
512 result$vip4o <- as.numeric(ropls_x@orthoVipVn) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
513 # get the level names |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
514 level_names <- sort(levels(as.factor(ropls_x@suppLs$y))) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
515 feature_count <- length(ropls_x@vipVn) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
516 result$level1 <- rep.int(x = level_names[1], times = feature_count) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
517 result$level2 <- rep.int(x = level_names[2], times = feature_count) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
518 # print(sprintf("sd(covariance) = %f; sd(correlation) = %f", sd(result$covariance), sd(result$correlation))) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
519 superresult <- list() |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
520 if (length(result$vip4o) == 0) result$vip4o <- NA |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
521 superresult$tsv1 <- data.frame( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
522 featureID = names(ropls_x@vipVn) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
523 , factorLevel1 = result$level1 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
524 , factorLevel2 = result$level2 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
525 , correlation = result$correlation |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
526 , covariance = result$covariance |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
527 , vip4p = result$vip4p |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
528 , vip4o = result$vip4o |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
529 , row.names = NULL |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
530 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
531 rownames(superresult$tsv1) <- superresult$tsv1$featureID |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
532 superresult$covariance <- result$covariance |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
533 superresult$correlation <- result$correlation |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
534 superresult$vip4p <- result$vip4p |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
535 superresult$vip4o <- result$vip4o |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
536 superresult$details <- result |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
537 # #print(superresult$tsv1) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
538 result$superresult <- superresult |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
539 # Include thise in case future consumers of this routine want to use it in currently unanticipated ways |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
540 result$oplsda <- ropls_x |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
541 result$predictor <- ropls_x@suppLs$y # in case future consumers of this routine want to use it in currently unanticipated ways |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
542 return (superresult) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
543 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
544 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
545 |