annotate w4mcorcov_calc.R @ 13:2ae2d26e3270 draft

planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
author eschen42
date Wed, 12 Dec 2018 09:20:02 -0500
parents ddaf84e15d06
children 90708fdbc22d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1 # compute and output detail plots
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
2 do_detail_plot <- function(
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
3 x_dataMatrix
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
4 , x_predictor
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
5 , x_is_match
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
6 , x_algorithm
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
7 , x_prefix
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
8 , x_show_labels
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
9 , x_progress = print
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
10 , x_env
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
11 , x_crossval_i
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
12 ) {
2
e03582f26617 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 7682e8e7ae2bfb926d94b414b9a1649389f33582
eschen42
parents: 1
diff changeset
13 off <- function(x) if (x_show_labels == "0") 0 else x
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
14 if ( x_is_match
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
15 && ncol(x_dataMatrix) > 0
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
16 && length(unique(x_predictor)) > 1
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
17 && x_crossval_i < nrow(x_dataMatrix)
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
18 ) {
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
19 my_oplsda <- opls(
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
20 x = x_dataMatrix
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
21 , y = x_predictor
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
22 , algoC = x_algorithm
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
23 , predI = 1
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
24 , 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
25 , printL = FALSE
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
26 , plotL = FALSE
3
5aaab36bc523 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 88004a3cf8868d68da1ec5bd2c1be53746350367
eschen42
parents: 2
diff changeset
27 , crossvalI = x_crossval_i
7
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
28 , scaleC = "pareto" # data centered and pareto scaled here only. This line fixes issue #2.
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
29 )
7
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
30 # strip out variables having negligible variance
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
31 x_dataMatrix <- x_dataMatrix[ , names(my_oplsda@vipVn), drop = FALSE]
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
32 my_oplsda_suppLs_y_levels <- levels(as.factor(my_oplsda@suppLs$y))
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
33
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
34 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
35 fctr_lvl_2 <- my_oplsda_suppLs_y_levels[2]
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
36 do_s_plot <- function(
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
37 x_env
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
38 , predictor_projection_x = TRUE
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
39 , cplot_x = FALSE
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
40 , cor_vs_cov_x = NULL
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
41 ) {
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
42 if (cplot_x) {
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
43 cplot_y_correlation <- (x_env$cplot_y == "correlation")
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
44 default_lim_x <- 10
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
45 } else {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
46 default_lim_x <- 1.2
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
47 }
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
48 if (is.null(cor_vs_cov_x)) {
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
49 my_cor_vs_cov <- cor_vs_cov(
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
50 matrix_x = x_dataMatrix
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
51 , ropls_x = my_oplsda
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
52 , predictor_projection_x = predictor_projection_x
7
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
53 , x_progress
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
54 , x_env
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
55 )
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
56 } else {
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
57 my_cor_vs_cov <- cor_vs_cov_x
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
58 }
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
59
7
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
60 if (is.null(my_cor_vs_cov) || sum(!is.na(my_cor_vs_cov$tsv1$covariance)) < 2) {
11
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
61 if (is.null(cor_vs_cov_x)) {
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
62 x_progress(
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
63 sprintf("No cor_vs_cov data produced for level %s versus %s", fctr_lvl_1, fctr_lvl_2)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
64 )
11
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
65 }
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
66 plot(x=1, y=1, xaxt="n", yaxt="n", xlab="", ylab="", type="n")
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
67 text(x=1, y=1, labels="too few covariance data")
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
68 return(my_cor_vs_cov)
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
69 }
5
50f60f94c034 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents: 4
diff changeset
70 with(
50f60f94c034 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents: 4
diff changeset
71 my_cor_vs_cov
50f60f94c034 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents: 4
diff changeset
72 , {
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
73 min_x <- min(covariance, na.rm = TRUE)
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
74 max_x <- max(covariance, na.rm = TRUE)
5
50f60f94c034 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents: 4
diff changeset
75 lim_x <- max(sapply(X=c(min_x, max_x), FUN=abs))
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
76
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
77 # Regarding using VIP as a guide to selecting a biomarker:
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
78 # "It is generally accepted that a variable should be selected if vj>1, [27–29],
5
50f60f94c034 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents: 4
diff changeset
79 # but a proper threshold between 0.83 and 1.21 can yield more relevant variables according to [28]."
50f60f94c034 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents: 4
diff changeset
80 # (Mehmood 2012 doi:10.1186/1748-7188-6-27)
50f60f94c034 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents: 4
diff changeset
81 plus_cor <- correlation
50f60f94c034 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents: 4
diff changeset
82 plus_cov <- covariance
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
83 if (length(plus_cor) != 0 && length(plus_cor) != 0) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
84 cex <- 0.65
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
85 if (projection == 1) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
86 # predictor-projection
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
87 vipcp <- pmax(0, pmin(1, (vip4p - 0.83) / (1.21 - 0.83)))
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
88 if (!cplot_x) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
89 # S-plot predictor-projection
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
90 my_xlab <- "covariance(feature,t1)"
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
91 my_x <- plus_cov
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
92 my_ylab <- "correlation(feature,t1)"
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
93 my_y <- plus_cor
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
94 # X,Y limits for S-PLOT
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
95 my_xlim <- c( -lim_x, lim_x ) * (1.0 + off(0.3))
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
96 my_ylim <- c( -1.0, 1.0 ) * (1.0 + off(0.2) )
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
97 } else {
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
98 # C-plot predictor-projection
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
99 my_xlab <- "variable importance in predictor-projection"
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
100 my_x <- vip4p
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
101 if (cplot_y_correlation) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
102 my_ylab <- "correlation(feature,t1)"
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
103 my_y <- plus_cor
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
104 my_ylim <- c( -1.0, 1.0 ) * (1.0 + off(0.2) )
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
105 } else {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
106 my_ylab <- "covariance(feature,t1)"
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
107 my_y <- plus_cov
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
108 my_ylim <- max(abs(plus_cov))
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
109 my_ylim <- c( -my_ylim, my_ylim ) * (1.0 + off(0.2) )
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
110 }
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
111 # X,Y limits for C-plot
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
112 lim_x <- max(my_x, na.rm = TRUE) * 1.1
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
113 lim_x <- min(lim_x, default_lim_x)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
114 my_xlim <- c( 0, lim_x ) # + off(0.2) )
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
115 }
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
116 my_load_distal <- loadp
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
117 my_load_proximal <- loado
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
118 red <- as.numeric(correlation > 0) * vipcp
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
119 blue <- as.numeric(correlation < 0) * vipcp
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
120 alpha <- 0.1 + 0.4 * vipcp
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
121 red[is.na(red)] <- 0
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
122 blue[is.na(blue)] <- 0
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
123 alpha[is.na(alpha)] <- 0
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
124 my_col <- rgb(blue = blue, red = red, green = 0, alpha = alpha)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
125 main_label <- sprintf("%s for level %s versus %s"
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
126 , x_prefix, fctr_lvl_1, fctr_lvl_2)
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
127 } else {
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
128 # orthogonal projection
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
129 vipco <- pmax(0, pmin(1, (vip4o - 0.83) / (1.21 - 0.83)))
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
130 if (!cplot_x) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
131 # S-PLOT orthogonal-projection
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
132 my_xlab <- "covariance(feature,to1)"
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
133 my_x <- -plus_cov
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
134 # X,Y limits for S-PLOT
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
135 my_xlim <- c( -lim_x, lim_x ) * (1.0 + off(0.3))
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
136 my_ylab <- "correlation(feature,to1)"
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
137 my_y <- plus_cor
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
138 my_ylim <- c( -1.0, 1.0 ) * (1.0 + off(0.2) )
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
139 } else {
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
140 # C-plot orthogonal-projection
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
141 my_xlab <- "variable importance in orthogonal projection"
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
142 my_x <- vip4o
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
143 # C-plot orthogonal projection
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
144 # X,Y limits for C-plot
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
145 lim_x <- max(my_x, na.rm = TRUE) * 1.1
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
146 my_xlim <- c( 0, lim_x ) # + off(0.2) )
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
147 if (cplot_y_correlation) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
148 my_ylab <- "correlation(feature,to1)"
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
149 my_y <- plus_cor
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
150 my_ylim <- c( -1.0, 1.0 ) * (1.0 + off(0.2) )
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
151 } else {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
152 my_ylab <- "covariance(feature,to1)"
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
153 my_y <- plus_cov
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
154 my_ylim <- max(abs(plus_cov))
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
155 my_ylim <- c( -my_ylim, my_ylim ) * (1.0 + off(0.2) )
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
156 }
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
157 }
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
158 my_load_distal <- loado
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
159 my_load_proximal <- loadp
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
160 alpha <- 0.1 + 0.4 * vipco
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
161 alpha[is.na(alpha)] <- 0
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
162 my_col <- rgb(blue = 0, red = 0, green = 0, alpha = alpha)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
163 main_label <- sprintf(
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
164 "Features influencing orthogonal projection for %s versus %s"
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
165 , fctr_lvl_1, fctr_lvl_2)
5
50f60f94c034 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents: 4
diff changeset
166 }
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
167 main_cex <- min(1.0, 46.0/nchar(main_label))
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
168 my_feature_label_slant <- -30 # slant feature labels 30 degrees downward
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
169 my_pch <- sapply(X = cor_p_value, function(x) if (x < 0.01) 16 else if (x < 0.05) 17 else 18)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
170 if ( sum(is.infinite(my_xlim)) == 0 ) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
171 plot(
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
172 y = my_y
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
173 , x = my_x
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
174 , type = "p"
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
175 , xlim = my_xlim
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
176 , ylim = my_ylim
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
177 , xlab = my_xlab
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
178 , ylab = my_ylab
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
179 , main = main_label
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
180 , cex.main = main_cex
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
181 , cex = cex
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
182 , pch = my_pch
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
183 , col = my_col
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
184 )
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
185 low_x <- -0.7 * lim_x
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
186 high_x <- 0.7 * lim_x
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
187 if (projection == 1 && !cplot_x) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
188 text(x = low_x, y = -0.05, labels = fctr_lvl_1, col = "blue")
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
189 text(x = high_x, y = 0.05, labels = fctr_lvl_2, col = "red")
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
190 }
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
191 if ( x_show_labels != "0" ) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
192 names(my_load_distal) <- tsv1$featureID
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
193 names(my_load_proximal) <- tsv1$featureID
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
194 if ( x_show_labels == "ALL" ) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
195 n_labels <- length(my_load_distal)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
196 } else {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
197 n_labels <- as.numeric(x_show_labels)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
198 }
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
199 n_labels <- min( n_labels, (1 + length(my_load_distal)) / 2 )
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
200 labels_to_show <- c(
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
201 names(head(sort(my_load_distal), n = n_labels))
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
202 , names(tail(sort(my_load_distal), n = n_labels))
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
203 )
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
204 labels <- unname(
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
205 sapply(
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
206 X = tsv1$featureID
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
207 , FUN = function(x) if ( x %in% labels_to_show ) x else ""
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
208 )
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
209 )
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
210 x_text_offset <- 0.024
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
211 y_text_off <- 0.017
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
212 if (!cplot_x) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
213 # S-plot
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
214 y_text_offset <- if (projection == 1) -y_text_off else y_text_off
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
215 } else {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
216 # C-plot
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
217 y_text_offset <-
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
218 sapply(
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
219 X = (my_y > 0)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
220 , FUN = function(x) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
221 if (x) y_text_off else -y_text_off
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
222 }
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
223 )
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
224 }
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
225 label_features <- function(x_arg, y_arg, labels_arg, slant_arg) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
226 if (length(labels_arg) > 0) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
227 unique_slant <- unique(slant_arg)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
228 if (length(unique_slant) == 1) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
229 text(
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
230 y = y_arg
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
231 , x = x_arg + x_text_offset
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
232 , cex = 0.4
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
233 , labels = labels_arg
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
234 , col = rgb(blue = 0, red = 0, green = 0, alpha = 0.5) # grey semi-transparent labels
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
235 , srt = slant_arg
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
236 , adj = 0 # left-justified
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
237 )
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
238 } else {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
239 for (slant in unique_slant) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
240 text(
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
241 y = y_arg[slant_arg == slant]
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
242 , x = x_arg[slant_arg == slant] + x_text_offset
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
243 , cex = 0.4
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
244 , labels = labels_arg[slant_arg == slant]
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
245 , col = rgb(blue = 0, red = 0, green = 0, alpha = 0.5) # grey semi-transparent labels
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
246 , srt = slant
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
247 , adj = 0 # left-justified
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
248 )
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
249 }
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
250 }
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
251 }
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
252 }
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
253 if (!cplot_x) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
254 my_slant <- (if (projection == 1) 1 else -1) * my_feature_label_slant
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
255 } else {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
256 my_slant <- sapply(
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
257 X = (my_y > 0)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
258 , FUN = function(x) if (x) 2 else -2
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
259 ) * my_feature_label_slant
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
260 }
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
261 if (length(my_x) > 1) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
262 label_features(
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
263 x_arg = my_x [my_x > 0]
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
264 , y_arg = my_y [my_x > 0] - y_text_offset
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
265 , labels_arg = labels[my_x > 0]
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
266 , slant_arg = (if (!cplot_x) -my_slant else (my_slant))
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
267 )
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
268 if (!cplot_x) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
269 label_features(
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
270 x_arg = my_x [my_x < 0]
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
271 , y_arg = my_y [my_x < 0] + y_text_offset
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
272 , labels_arg = labels[my_x < 0]
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
273 , slant_arg = my_slant
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
274 )
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
275 }
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
276 } else {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
277 if (!cplot_x) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
278 my_slant <- (if (my_x > 1) -1 else 1) * my_slant
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
279 my_y_arg <- my_y + (if (my_x > 1) -1 else 1) * y_text_offset
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
280 } else {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
281 my_slant <- (if (my_y > 1) -1 else 1) * my_slant
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
282 my_y_arg <- my_y + (if (my_y > 1) -1 else 1) * y_text_offset
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
283 }
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
284 label_features(
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
285 x_arg = my_x
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
286 , y_arg = my_y_arg
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
287 , labels_arg = labels
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
288 , slant_arg = my_slant
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
289 )
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
290 } # end if (length(my_x) > 1)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
291 } # end if ( x_show_labels != "0" )
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
292 } else {
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
293 plot(x=1, y=1, xaxt="n", yaxt="n", xlab="", ylab="", type="n")
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
294 text(x=1, y=1, labels="no S-plot is possible")
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
295 } # end if (sum(is.infinte(my_xlim))==0)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
296 } else {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
297 plot(x=1, y=1, xaxt="n", yaxt="n", xlab="", ylab="", type="n")
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
298 text(x=1, y=1, labels="no S-plot is possible")
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
299 } # end if (length(plus_cor) != 0 && length(plus_cor) != 0)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
300 } # end action
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
301 ) # end with( my_cor_vs_cov, action )
5
50f60f94c034 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents: 4
diff changeset
302 return (my_cor_vs_cov)
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
303 } # end function do_s_plot
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
304 my_cor_vs_cov <- do_s_plot(
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
305 x_env = x_env
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
306 , predictor_projection_x = TRUE
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
307 , cplot_x = FALSE
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
308 )
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
309 typevc <- c("correlation", # 1
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
310 "outlier", # 2
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
311 "overview", # 3
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
312 "permutation", # 4
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
313 "predict-train", # 5
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
314 "predict-test", # 6
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
315 "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
316 "x-loading", # 8
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
317 "x-score", # 9
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
318 "x-variance", # 10
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
319 "xy-score", # 11
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
320 "xy-weight" # 12
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
321 ) # [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
322 if ( length(my_oplsda@orthoVipVn) > 0 ) {
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
323 my_typevc <- typevc[c(9,3,8)]
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
324 } else {
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
325 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
326 }
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
327 my_ortho_cor_vs_cov_exists <- FALSE
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
328 for (my_type in my_typevc) {
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
329 if (my_type %in% typevc) {
4
8bba31f628da planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 8f2dc8b66666340275cd8967e09c504720528462
eschen42
parents: 3
diff changeset
330 tryCatch({
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
331 if ( my_type != "x-loading" ) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
332 plot(
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
333 x = my_oplsda
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
334 , typeVc = my_type
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
335 , parCexN = 0.4
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
336 , parDevNewL = FALSE
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
337 , parLayL = TRUE
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
338 , parEllipsesL = TRUE
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
339 )
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
340 if (my_type == "overview") {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
341 sub_label <- sprintf("%s versus %s", fctr_lvl_1, fctr_lvl_2)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
342 title(sub = sub_label)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
343 }
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
344 } else {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
345 my_ortho_cor_vs_cov <- do_s_plot(
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
346 x_env = x_env
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
347 , predictor_projection_x = FALSE
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
348 , cplot_x = FALSE
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
349 )
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
350 my_ortho_cor_vs_cov_exists <- TRUE
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
351 }
5
50f60f94c034 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents: 4
diff changeset
352 }
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
353 , error = function(e) {
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
354 x_progress(
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
355 sprintf(
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
356 "factor level %s or %s may have only one sample - %s"
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
357 , fctr_lvl_1
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
358 , fctr_lvl_2
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
359 , e$message
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
360 )
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
361 )
4
8bba31f628da planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 8f2dc8b66666340275cd8967e09c504720528462
eschen42
parents: 3
diff changeset
362 })
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
363 } else {
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
364 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
365 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
366 }
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
367 }
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
368 cplot_p <- x_env$cplot_p
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
369 cplot_o <- x_env$cplot_o
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
370 if (cplot_p || cplot_o) {
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
371 if (cplot_p) {
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
372 if (!is.null(my_cor_vs_cov)) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
373 do_s_plot(
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
374 x_env = x_env
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
375 , predictor_projection_x = TRUE
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
376 , cplot_x = TRUE
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
377 , cor_vs_cov_x = my_cor_vs_cov
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
378 )
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
379 } else {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
380 plot(x=1, y=1, xaxt="n", yaxt="n", xlab="", ylab="", type="n")
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
381 text(x=1, y=1, labels="no predictor projection is possible")
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
382 }
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
383 did_plots <- 1
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
384 } else {
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
385 did_plots <- 0
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
386 }
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
387 if (cplot_o) {
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
388 if (my_ortho_cor_vs_cov_exists) {
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
389 do_s_plot(
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
390 x_env = x_env
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
391 , predictor_projection_x = FALSE
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
392 , cplot_x = TRUE
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
393 , cor_vs_cov_x = my_ortho_cor_vs_cov
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
394 )
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
395 } else {
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
396 plot(x=1, y=1, xaxt="n", yaxt="n", xlab="", ylab="", type="n")
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
397 text(x=1, y=1, labels="no orthogonal projection is possible")
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
398 }
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
399 did_plots <- 1 + did_plots
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
400 }
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
401 if (did_plots == 1) {
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
402 plot(x=1, y=1, xaxt="n", yaxt="n", xlab="", ylab="", type="n", fg = "white")
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
403 }
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
404 }
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
405 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
406 } else {
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
407 return (NULL)
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
408 }
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
409 }
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
410
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
411 # S-PLOT and OPLS reference: Wiklund_2008 doi:10.1021/ac0713510
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
412 corcov_calc <- function(
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
413 calc_env
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
414 , failure_action = stop
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
415 , progress_action = function(x) { }
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
416 , corcov_tsv_action = function(t) { }
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
417 , salience_tsv_action = function(t) { }
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
418 , extra_plots = c()
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
419 ) {
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
420 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
421 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
422 return ( FALSE )
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
423 }
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
424 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
425 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
426 return ( FALSE )
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
427 }
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
428 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
429 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
430 return ( FALSE )
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
431 }
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
432
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
433 # 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
434 vrbl_metadata <- calc_env$vrbl_metadata
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
435 vrbl_metadata_names <- vrbl_metadata[, 1]
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
436 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
437 data_matrix <- calc_env$data_matrix
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
438 pair_significant_features_only <- calc_env$pairSigFeatOnly
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
439 facC <- calc_env$facC
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
440 tesC <- calc_env$tesC
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
441 # 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
442 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
443 # 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
444 matchingC <- calc_env$matchingC
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
445 labelFeatures <- calc_env$labelFeatures
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
446
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
447 # arg/env checking
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
448 if (!(facC %in% names(smpl_metadata))) {
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
449 failure_action(
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
450 sprintf("bad parameter! Factor name '%s' not found in sampleMetadata"
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
451 , facC))
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
452 return ( FALSE )
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
1
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
455 mz <- vrbl_metadata$mz
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
456 names(mz) <- vrbl_metadata$variableMetadata
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
457 mz_lookup <- function(feature) unname(mz[feature])
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
458
1
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
459 rt <- vrbl_metadata$rt
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
460 names(rt) <- vrbl_metadata$variableMetadata
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
461 rt_lookup <- function(feature) unname(rt[feature])
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
462
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
463 # calculate salience_df as data.frame(feature, max_level, max_median, salience_rcv, mean_median, salience, salience_rcv)
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
464 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
465 data_matrix = data_matrix
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
466 , 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
467 , failure_action = failure_action
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
468 )
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
469 salience_tsv_action({
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
470 with (
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
471 salience_df
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
472 , {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
473 my_df <<- data.frame(
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
474 featureID = feature
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
475 , salientLevel = max_level
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
476 , salienceRCV = salience_rcv
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
477 , relativeSalientDistance = relative_salient_distance
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
478 , salience = salience
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
479 , mz = mz_lookup(feature)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
480 , rt = rt_lookup(feature)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
481 )
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
482 })
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
483 my_df[order(-my_df$relativeSalientDistance),]
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
484 })
1
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
485
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
486 # transform wildcards to regexen
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
487 if (matchingC == "wildcard") {
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
488 # 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
489 levCSV <- gsub("[.]", "[.]", levCSV)
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
490 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
491 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
492 levCSV <- paste(levCSV, collapse = ",")
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
493 }
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
494 # 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
495 isLevelSelected <- function(lvl) {
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
496 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
497 return(
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
498 Reduce(
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
499 f = "||"
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
500 , x = sapply(
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
501 X = strsplit(
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
502 x = levCSV
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
503 , split = ","
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
504 , fixed = TRUE
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
505 )[[1]]
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
506 , FUN = matchFun
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
507 , lvl
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 )
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
510 )
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
511 }
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
512
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
513 # transpose matrix because ropls matrix is the transpose of XCMS matrix
7
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
514 tdm <- t(data_matrix)
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
515 # Wiklund_2008 centers and pareto-scales data before OPLS-DA S-plot
7
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
516 # However, data should be neither centered nor pareto scaled here because ropls::opls does that; this fixes issue #2.
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
517
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
518 # 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
519 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
520 # 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
521 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
522 # 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
523 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
524
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
525 # 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
526 # - feature ID
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
527 # - value1
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
528 # - value2
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
529 # - Wiklund_2008 correlation
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
530 # - Wiklund_2008 covariance
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
531 # - Wiklund_2008 VIP
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
532 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
533
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
534
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
535 did_plot <- FALSE
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
536 if (tesC != "none") {
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
537 # 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
538 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
539 if ( ! Reduce( f = "||", x = grepl(tesC, the_colnames) ) ) {
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
540 failure_action(
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
541 sprintf(
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
542 "bad parameter! variableMetadata must contain results of W4M Univariate test '%s'."
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
543 , tesC))
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
544 return ( FALSE )
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
545 }
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
546 col_matches <- lapply(
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
547 X = the_colnames,
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
548 FUN = function(x) {
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
549 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
550 }
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
551 )
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
552 ## 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
553 # 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
554 level_union <- c()
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
555 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
556 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
557 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
558 # 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
559 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
560 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
561 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
562 # 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
563 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
564 if (is_match) {
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
565 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
566 }
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
567 }
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
568 }
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
569 level_union <- unique(sort(level_union))
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
570 overall_significant <- 1 == (
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
571 if (intersample_sig_col %in% colnames(vrbl_metadata)) {
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
572 vrbl_metadata[,intersample_sig_col]
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
573 } else {
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
574 1
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
575 }
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
576 )
1
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
577 if ( length(level_union) > 2 ) {
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
578 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
579 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
580 col_selector <- vrbl_metadata_names[ overall_significant ]
7
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
581 my_matrix <- tdm[ chosen_samples, col_selector, drop = FALSE ]
1
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
582 plot_action <- function(fctr_lvl_1, fctr_lvl_2) {
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
583 progress_action(
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
584 sprintf("calculating/plotting contrast of %s vs. %s"
11
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
585 , fctr_lvl_1, fctr_lvl_2)
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
586 )
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
587 predictor <- sapply(
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
588 X = chosen_facC
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
589 , FUN = function(fac) if ( fac == fctr_lvl_1 ) fctr_lvl_1 else fctr_lvl_2
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
590 )
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
591 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
592 x_dataMatrix = my_matrix
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
593 , x_predictor = predictor
11
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
594 , x_is_match = TRUE
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
595 , x_algorithm = "nipals"
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
596 , x_prefix = if (pair_significant_features_only) {
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
597 "Significantly contrasting features"
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
598 } else {
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
599 "Significant features"
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
600 }
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
601 , x_show_labels = labelFeatures
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
602 , x_progress = progress_action
4
8bba31f628da planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 8f2dc8b66666340275cd8967e09c504720528462
eschen42
parents: 3
diff changeset
603 , x_crossval_i = min(7, length(chosen_samples))
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
604 , x_env = calc_env
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
605 )
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
606 if ( is.null(my_cor_cov) ) {
11
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
607 progress_action("NOTHING TO PLOT")
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
608 } else {
1
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
609 my_tsv <- my_cor_cov$tsv1
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
610 my_tsv$mz <- mz_lookup(my_tsv$featureID)
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
611 my_tsv$rt <- rt_lookup(my_tsv$featureID)
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
612 my_tsv["level1Level2Sig"] <- vrbl_metadata[
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
613 match(my_tsv$featureID, vrbl_metadata_names)
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
614 , vrbl_metadata_col
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
615 ]
1
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
616 tsv <<- my_tsv
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
617 corcov_tsv_action(tsv)
1
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
618 did_plot <<- TRUE
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
619 }
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
620 }
1
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
621 if ( length(level_union) != 2 ) {
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
622 fctr_lvl_2 <- "other"
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
623 for ( fctr_lvl_1 in level_union[1:length(level_union)] ) {
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
624 plot_action(fctr_lvl_1, fctr_lvl_2)
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
625 }
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
626 } else {
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
627 plot_action(fctr_lvl_1 = level_union[1], fctr_lvl_2 = level_union[2])
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
628 }
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
629 }
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
630
1
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
631 if ( length(level_union) > 1 ) {
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
632 ## next, contrast each selected level with each of the other levels individually ##
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
633 # process columns matching the pattern
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
634 for (i in 1:length(col_matches)) {
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
635 # for each potential match of the pattern
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
636 col_match <- col_matches[[i]]
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
637 if (length(col_match) > 0) {
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
638 # it's an actual match; extract the pieces, e.g., k10_kruskal_k4.k3_sig
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
639 vrbl_metadata_col <- col_match[1] # ^^^^^^^^^^^^^^^^^^^^^ # Column name
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
640 fctr_lvl_1 <- col_match[2] # ^^ # Factor-level 1
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
641 fctr_lvl_2 <- col_match[3] # ^^ # Factor-level 2
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
642 # only process this column if both factors are members of lvlCSV
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
643 is_match <- isLevelSelected(fctr_lvl_1) && isLevelSelected(fctr_lvl_2)
11
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
644 if (is_match) {
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
645 progress_action(
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
646 sprintf("calculating/plotting contrast of %s vs. %s."
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
647 , fctr_lvl_1, fctr_lvl_2
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
648 )
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
649 )
11
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
650 # choose only samples with one of the two factors for this column
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
651 chosen_samples <- smpl_metadata_facC %in% c(fctr_lvl_1, fctr_lvl_2)
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
652 predictor <- smpl_metadata_facC[chosen_samples]
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
653 # extract only the significantly-varying features and the chosen samples
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
654 fully_significant <- 1 == vrbl_metadata[,vrbl_metadata_col] *
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
655 ( if (intersample_sig_col %in% colnames(vrbl_metadata)) {
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
656 vrbl_metadata[,intersample_sig_col]
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
657 } else {
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
658 1
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
659 }
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
660 )
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
661 col_selector <- vrbl_metadata_names[
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
662 if (pair_significant_features_only) fully_significant else overall_significant
11
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
663 ]
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
664 my_matrix <- tdm[ chosen_samples, col_selector, drop = FALSE ]
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
665 my_cor_cov <- do_detail_plot(
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
666 x_dataMatrix = my_matrix
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
667 , x_predictor = predictor
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
668 , x_is_match = is_match
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
669 , x_algorithm = "nipals"
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
670 , x_prefix = if (pair_significant_features_only) {
11
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
671 "Significantly contrasting features"
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
672 } else {
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
673 "Significant features"
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
674 }
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
675 , x_show_labels = labelFeatures
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
676 , x_progress = progress_action
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
677 , x_crossval_i = min(7, length(chosen_samples))
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
678 , x_env = calc_env
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
679 )
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
680 if ( is.null(my_cor_cov) ) {
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
681 progress_action("NOTHING TO PLOT.")
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
682 } else {
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
683 tsv <- my_cor_cov$tsv1
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
684 tsv$mz <- mz_lookup(tsv$featureID)
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
685 tsv$rt <- rt_lookup(tsv$featureID)
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
686 tsv["level1Level2Sig"] <- vrbl_metadata[
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
687 match(tsv$featureID, vrbl_metadata_names)
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
688 , vrbl_metadata_col
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
689 ]
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
690 corcov_tsv_action(tsv)
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
691 did_plot <- TRUE
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
692 }
1
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
693 } else {
11
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
694 progress_action(
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
695 sprintf("skipping contrast of %s vs. %s."
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
696 , fctr_lvl_1, fctr_lvl_2
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
697 )
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
698 )
1
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
699 }
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
700 }
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
701 }
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
702 }
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
703 } else {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
704 # tesC == "none"
11
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
705 # find all the levels for factor facC in sampleMetadata
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
706 level_union <- unique(sort(smpl_metadata_facC))
11
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
707 # identify the selected levels for factor facC from sampleMetadata
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
708 level_include <- sapply(X = level_union, FUN = isLevelSelected)
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
709 # discard the non-selected levels for factor facC
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
710 level_union <- level_union[level_include]
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
711 if ( length(level_union) > 1 ) {
1
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
712 if ( length(level_union) > 2 ) {
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
713 ## pass 1 - contrast each selected level with all other levels combined into one "super-level" ##
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
714 completed <- c()
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
715 lapply(
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
716 X = level_union
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
717 , FUN = function(x) {
1
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
718 fctr_lvl_1 <- x[1]
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
719 fctr_lvl_2 <- {
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
720 if ( fctr_lvl_1 %in% completed )
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
721 return("DUMMY")
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
722 completed <<- c(completed, fctr_lvl_1)
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
723 setdiff(level_union, fctr_lvl_1)
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
724 }
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
725 chosen_samples <- smpl_metadata_facC %in% c(fctr_lvl_1, fctr_lvl_2)
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
726 fctr_lvl_2 <- "other"
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
727 if (length(unique(chosen_samples)) < 1) {
11
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
728 progress_action(
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
729 sprintf("Skipping contrast of %s vs. %s; there are no chosen samples."
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
730 , fctr_lvl_1, fctr_lvl_2)
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
731 )
1
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
732 } else {
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
733 chosen_facC <- as.character(smpl_metadata_facC[chosen_samples])
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
734 predictor <- sapply(
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
735 X = chosen_facC
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
736 , FUN = function(fac) {
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
737 if ( fac == fctr_lvl_1 ) fctr_lvl_1 else fctr_lvl_2
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
738 }
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
739 )
7
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
740 my_matrix <- tdm[ chosen_samples, , drop = FALSE ]
1
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
741 # only process this column if both factors are members of lvlCSV
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
742 is_match <- isLevelSelected(fctr_lvl_1)
11
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
743 if (is_match) {
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
744 progress_action(
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
745 sprintf("Calculating/plotting contrast of %s vs. %s"
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
746 , fctr_lvl_1, fctr_lvl_2)
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
747 )
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
748 my_cor_cov <- do_detail_plot(
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
749 x_dataMatrix = my_matrix
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
750 , x_predictor = predictor
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
751 , x_is_match = is_match
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
752 , x_algorithm = "nipals"
11
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
753 , x_prefix = "Features"
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
754 , x_show_labels = labelFeatures
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
755 , x_progress = progress_action
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
756 , x_crossval_i = min(7, length(chosen_samples))
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
757 , x_env = calc_env
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
758 )
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
759 if ( is.null(my_cor_cov) ) {
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
760 progress_action("NOTHING TO PLOT...")
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
761 } else {
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
762 tsv <- my_cor_cov$tsv1
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
763 tsv$mz <- mz_lookup(tsv$featureID)
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
764 tsv$rt <- rt_lookup(tsv$featureID)
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
765 corcov_tsv_action(tsv)
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
766 did_plot <<- TRUE
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
767 }
1
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
768 } else {
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
769 }
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
770 }
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
771 "dummy" # need to return a value; otherwise combn fails with an error
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
772 }
1
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
773 )
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
774 }
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
775 ## 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
776 completed <- c()
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
777 utils::combn(
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
778 x = level_union
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
779 , m = 2
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
780 , FUN = function(x) {
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
781 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
782 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
783 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
784 if (length(unique(chosen_samples)) < 1) {
11
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
785 progress_action(
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
786 sprintf("Skipping contrast of %s vs. %s. - There are no chosen samples."
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
787 , fctr_lvl_1, fctr_lvl_2
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
788 )
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
789 )
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
790 } else {
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
791 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
792 predictor <- chosen_facC
7
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
793 my_matrix <- tdm[ chosen_samples, , drop = FALSE ]
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
794 # 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
795 is_match <- isLevelSelected(fctr_lvl_1) && isLevelSelected(fctr_lvl_2)
11
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
796 if (is_match) {
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
797 progress_action(
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
798 sprintf("Calculating/plotting contrast of %s vs. %s."
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
799 , fctr_lvl_1, fctr_lvl_2)
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
800 )
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
801 my_cor_cov <- do_detail_plot(
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
802 x_dataMatrix = my_matrix
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
803 , x_predictor = predictor
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
804 , x_is_match = is_match
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
805 , x_algorithm = "nipals"
11
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
806 , x_prefix = "Features"
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
807 , x_show_labels = labelFeatures
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
808 , x_progress = progress_action
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
809 , x_crossval_i = min(7, length(chosen_samples))
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
810 , x_env = calc_env
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
811 )
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
812 if ( is.null(my_cor_cov) ) {
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
813 progress_action("NOTHING TO PLOT.....")
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
814 } else {
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
815 tsv <- my_cor_cov$tsv1
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
816 tsv$mz <- mz_lookup(tsv$featureID)
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
817 tsv$rt <- rt_lookup(tsv$featureID)
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
818 corcov_tsv_action(tsv)
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
819 did_plot <<- TRUE
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
820 }
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
821 } else {
11
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
822 progress_action(
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
823 sprintf("Skipping contrast of %s vs. %s."
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
824 , fctr_lvl_1, fctr_lvl_2
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
825 )
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
826 )
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
827 }
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
828 }
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
829 "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
830 }
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
831 )
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
832 } else {
11
ddcc33ff3205 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 4428e3252d54c8a8e0e5d85e8eaaeb13e9b21de7
eschen42
parents: 7
diff changeset
833 progress_action("NOTHING TO PLOT......")
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
834 }
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
835 }
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
836 if (!did_plot) {
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
837 failure_action(
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
838 sprintf(
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
839 "Did not plot. Does sampleMetadata have at least two levels of factor '%s' matching '%s' ?"
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
840 , facC, originalLevCSV))
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
841 return ( FALSE )
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
842 }
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
843 return ( TRUE )
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
844 }
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
845
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
846 # 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
847 # Adapted from:
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
848 # 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
849 # 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
850 # https://github.com/HegemanLab/extra_tools/blob/master/generic_PCA.R
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
851 cor_vs_cov <- function(
7
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
852 matrix_x
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
853 , ropls_x
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
854 , predictor_projection_x = TRUE
7
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
855 , x_progress = print
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
856 , x_env
7
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
857 ) {
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
858 tryCatch({
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
859 return(
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
860 cor_vs_cov_try( matrix_x, ropls_x, predictor_projection_x, x_progress, x_env)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
861 )
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
862 }
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
863 , error = function(e) {
7
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
864 x_progress(
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
865 sprintf(
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
866 "cor_vs_cov fatal error - %s"
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
867 , as.character(e) # e$message
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
868 )
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
869 )
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
870 return ( NULL )
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
871 })
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
872 }
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
873
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
874 cor_vs_cov_try <- function(
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
875 matrix_x # rows are samples; columns, features
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
876 , ropls_x # an instance of ropls::opls
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
877 , predictor_projection_x = TRUE # TRUE for predictor projection; FALSE for orthogonal projection
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
878 , x_progress = print # function to produce progress and error messages
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
879 , x_env
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
880 ) {
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
881 my_matrix_x <- matrix_x
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
882 my_matrix_x[my_matrix_x==0] <- NA
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
883 fdr_features <- x_env$fdr_features
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
884
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
885 x_class <- class(ropls_x)
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
886 if ( !( as.character(x_class) == "opls" ) ) {
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
887 stop(
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
888 paste(
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
889 "cor_vs_cov: Expected ropls_x to be of class ropls::opls but instead it was of class "
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
890 , as.character(x_class)
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
891 )
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
892 )
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
893 }
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
894 if ( !ropls_x@suppLs$algoC == "nipals" ) {
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
895 # suppLs$algoC - Character: algorithm used - "svd" for singular value decomposition; "nipals" for NIPALS
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
896 stop(
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
897 paste(
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
898 "cor_vs_cov: Expected ropls::opls instance to have been computed by the NIPALS algorithm rather than "
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
899 , ropls_x@suppLs$algoC
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
900 )
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
901 )
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
902 }
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
903 result <- list()
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
904 result$projection <- projection <- if (predictor_projection_x) 1 else 2
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
905
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
906 # I used equations (1) and (2) from Wiklund 2008, doi:10.1021/ac0713510
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
907 # (and not from the supplement despite the statement that, for the NIPALS algorithm,
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
908 # the equations from the supplement should be used) because of the definition of the
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
909 # Pearson/Galton coefficient of correlation is defined as
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
910 # $$
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
911 # \rho_{X,Y}= \frac{\operatorname{cov}(X,Y)}{\sigma_X \sigma_Y}
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
912 # $$
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
913 # as described (among other places) on Wikipedia at
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
914 # https://en.wikipedia.org/wiki/Pearson_correlation_coefficient#For_a_population
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
915 # The equations in the supplement said to use, for the predictive component t1,
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
916 # \rho_{t1,X_i}= \frac{\operatorname{cov}(t1,X_i)}{(\operatorname{mag}(t1))(\operatorname{mag}(X_i))}
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
917 # but the results that I got were dramatically different from published results for S-PLOTs;
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
918 # perhaps my data are not centered exactly the same way that theirs were.
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
919 # The correlations calculated here are in agreement with those calculated with the code from
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
920 # page 22 of https://cran.r-project.org/web/packages/muma/muma.pdf
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
921
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
922
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
923 # count the features/variables (one column for each sample)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
924 # count the features/variables (one column for each sample)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
925 n_features <- ncol(my_matrix_x)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
926 all_n_features <- x_env$fdr_features
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
927 if (length(grep("^[0-9][0-9]*$", all_n_features)) > 0) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
928 all_n_features <- as.integer(all_n_features)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
929 } else {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
930 all_n_features <- n_features
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
931 }
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
932 fdr_n_features <- max(n_features, all_n_features)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
933 # print("n_features")
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
934 # print(n_features)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
935
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
936 # count the samples/observations (one row for each sample)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
937 n_observations <- nrow(my_matrix_x)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
938
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
939 # choose whether to plot the predictive score vector or orthogonal score vector
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
940 if (predictor_projection_x)
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
941 score_vector <- ropls_x@scoreMN
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
942 else
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
943 score_vector <- ropls_x@orthoScoreMN
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
944
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
945 # compute the covariance of each feature with the score vector
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
946 result$covariance <-
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
947 sapply(
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
948 X = 1:n_features
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
949 , FUN = function(i) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
950 cov(score_vector, my_matrix_x[ , i, drop = TRUE], use = "pairwise.complete.obs")
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
951 }
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
952 )
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
953 # access covariance by feature name
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
954 names(result$covariance) <- colnames(my_matrix_x)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
955
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
956 # compute the correlation of each feature with the score vector
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
957 result$correlation <-
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
958 sapply(
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
959 X = 1:n_features
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
960 , FUN = function(i) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
961 cor(score_vector, my_matrix_x[ , i, drop = TRUE], use = "pairwise.complete.obs")
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
962 }
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
963 )
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
964 # access correlation by feature name
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
965 names(result$correlation) <- colnames(my_matrix_x)
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
966
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
967 # eliminate NAs in either correlation or covariance
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
968 nas <- is.na(result$correlation) | is.na(result$covariance)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
969 featureID <- names(ropls_x@vipVn)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
970 featureID <- featureID[!nas]
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
971 result$correlation <- result$correlation[!nas]
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
972 result$covariance <- result$covariance[!nas]
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
973 n_features <- length(featureID)
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
974
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
975 correl_pci <- lapply(
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
976 X = 1:n_features
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
977 , FUN = function(i) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
978 correl.ci(
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
979 r = result$correlation[i]
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
980 , n_obs = n_observations
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
981 , n_vars = fdr_n_features
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
982 )
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
983 }
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
984 )
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
985 result$p_value_raw <- sapply(
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
986 X = 1:n_features
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
987 , FUN = function(i) correl_pci[[i]]$p.value.raw
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
988 )
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
989 result$p_value_raw[is.na(result$p_value_raw)] <- 1.0
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
990 result$p_value <- sapply(
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
991 X = 1:n_features
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
992 , FUN = function(i) correl_pci[[i]]$p.value
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
993 )
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
994 result$p_value[is.na(result$p_value)] <- 1.0
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
995 result$ci_lower <- sapply(
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
996 X = 1:n_features
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
997 , FUN = function(i) correl_pci[[i]]$CI["lower"]
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
998 )
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
999 result$ci_upper <- sapply(
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1000 X = 1:n_features
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1001 , FUN = function(i) correl_pci[[i]]$CI["upper"]
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1002 )
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1003
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1004
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1005 # extract "variant 4 of Variable Influence on Projection for OPLS" (see Galindo_Prieto_2014, DOI 10.1002/cem.2627)
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
1006 # Length = number of features; labels = feature identifiers. (The same is true for $correlation and $covariance.)
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1007 result$vip4p <- as.numeric(ropls_x@vipVn)[!nas]
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1008 result$vip4o <- as.numeric(ropls_x@orthoVipVn)[!nas]
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1009 if (length(result$vip4o) == 0) result$vip4o <- NA
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1010 # extract the loadings
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1011 result$loadp <- as.numeric(ropls_x@loadingMN)[!nas]
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1012 result$loado <- as.numeric(ropls_x@orthoLoadingMN)[!nas]
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
1013 # get the level names
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
1014 level_names <- sort(levels(as.factor(ropls_x@suppLs$y)))
1
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
1015 fctr_lvl_1 <- level_names[1]
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
1016 fctr_lvl_2 <- level_names[2]
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1017 result$level1 <- rep.int(x = fctr_lvl_1, times = n_features)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1018 result$level2 <- rep.int(x = fctr_lvl_2, times = n_features)
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
1019 greaterLevel <- sapply(
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
1020 X = result$correlation
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1021 , FUN = function(my_corr) {
7
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
1022 tryCatch({
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1023 if ( is.na(my_corr) || ! is.numeric( my_corr ) ) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1024 NA
7
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
1025 } else {
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
1026 if ( my_corr < 0 ) fctr_lvl_1 else fctr_lvl_2
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
1027 }
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1028 }
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1029 , error = function(e) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1030 print(my_corr)
7
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
1031 x_progress(
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
1032 sprintf(
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
1033 "cor_vs_cov -> sapply: error - substituting NA - %s"
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
1034 , as.character(e)
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
1035 )
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
1036 )
066b1f409e9f planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents: 6
diff changeset
1037 NA
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1038 }
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1039 )
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1040 }
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
1041 )
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
1042
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1043 # build a data frame to hold the content for the tab-separated values file
6
7bd523ca1f9a planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents: 5
diff changeset
1044 tsv1 <- data.frame(
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1045 featureID = featureID
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1046 , factorLevel1 = result$level1
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1047 , factorLevel2 = result$level2
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1048 , greaterLevel = greaterLevel
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1049 , projection = result$projection
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1050 , correlation = result$correlation
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1051 , covariance = result$covariance
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1052 , vip4p = result$vip4p
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1053 , vip4o = result$vip4o
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1054 , loadp = result$loadp
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1055 , loado = result$loado
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1056 , cor_p_val_raw = result$p_value_raw
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1057 , cor_p_value = result$p_value
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1058 , cor_ci_lower = result$ci_lower
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1059 , cor_ci_upper = result$ci_upper
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
1060 )
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1061 rownames(tsv1) <- tsv1$featureID
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1062
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1063 # build the superresult, i.e., the result returned by this function
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1064 superresult <- list()
5
50f60f94c034 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents: 4
diff changeset
1065 superresult$projection <- result$projection
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
1066 superresult$covariance <- result$covariance
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
1067 superresult$correlation <- result$correlation
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
1068 superresult$vip4p <- result$vip4p
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
1069 superresult$vip4o <- result$vip4o
1
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
1070 superresult$loadp <- result$loadp
0c2ad44b6c9c planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents: 0
diff changeset
1071 superresult$loado <- result$loado
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1072 superresult$cor_p_value <- tsv1$cor_p_value
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
1073 superresult$details <- result
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1074
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1075 # remove any rows having NA for covariance or correlation
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1076 tsv1 <- tsv1[!is.na(tsv1$correlation),]
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1077 tsv1 <- tsv1[!is.na(tsv1$covariance),]
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1078 superresult$tsv1 <- tsv1
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1079
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1080 # # I did not include these but left them commentd out in case future
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1081 # # consumers of this routine want to use it in currently unanticipated ways
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1082 # result$superresult <- superresult
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1083 # result$oplsda <- ropls_x
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1084 # result$predictor <- ropls_x@suppLs$y
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1085
0
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
1086 return (superresult)
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
1087 }
23f9fad4edfc planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff changeset
1088
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1089 # Code for correl.ci was adapted from correl function from:
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1090 # @book{
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1091 # Tsagris_2018,
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1092 # author = {Tsagris, Michail},
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1093 # year = {2018},
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1094 # link = {https://www.researchgate.net/publication/324363311_Multivariate_data_analysis_in_R},
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1095 # title = {Multivariate data analysis in R}
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1096 # }
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1097 # which follows
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1098 # https://en.wikipedia.org/wiki/Fisher_transformation#Definition
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1099
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1100 correl.ci <- function(r, n_obs, n_vars, a = 0.05, rho = 0) {
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1101 ## r is the calculated correlation coefficient for n_obs pairs of observations of one variable
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1102 ## a is the significance level
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1103 ## rho is the hypothesised correlation
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1104 zh0 <- atanh(rho) # 0.5*log((1+rho)/(1-rho)), i.e., Fisher's z-transformation for Ho
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1105 zh1 <- atanh(r) # 0.5*log((1+r)/(1-r)), i.e., Fisher's z-transformation for H1
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1106 se <- (1 - r^2)/sqrt(n_obs - 3) ## standard error for Fisher's z-transformation of Ho
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1107 test <- (zh1 - zh0)/se ### test statistic
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1108 pvalue <- 2*(1 - pnorm(abs(test))) ## p-value
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1109 pvalue.adj <- p.adjust(p = pvalue, method = "BY", n = n_vars)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1110 z_L <- zh1 - qnorm(1 - a/2)*se
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1111 z_h <- zh1 + qnorm(1 - a/2)*se
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1112 fish_l <- tanh(z_L) # (exp(2*z_l)-1)/(exp(2*z_l)+1), i.e., lower confidence limit
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1113 fish_h <- tanh(z_h) # (exp(2*z_h)-1)/(exp(2*z_h)+1), i.e., upper confidence limit
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1114 ci <- c(fish_l, fish_h)
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1115 names(ci) <- c("lower", "upper")
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1116 list(
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1117 correlation = r
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1118 , p.value.raw = pvalue
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1119 , p.value = pvalue.adj
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1120 , CI = ci
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1121 )
12
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1122 }
ddaf84e15d06 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 6775c83b89d9d903c81a2229cdc200fc93538dfe-dirty
eschen42
parents: 11
diff changeset
1123
13
2ae2d26e3270 planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents: 12
diff changeset
1124 # vim: sw=2 ts=2 et ai :