Mercurial > repos > eschen42 > w4mcorcov
annotate w4mcorcov_calc.R @ 9:06c51af11531 draft
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit fda7ea61f0a082fd0c28730e471e66c92aaa04d0
author | eschen42 |
---|---|
date | Fri, 10 Aug 2018 11:15:31 -0400 |
parents | 066b1f409e9f |
children | ddcc33ff3205 |
rev | line source |
---|---|
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
1 # center with 'colMeans()' - ref: http://gastonsanchez.com/visually-enforced/how-to/2014/01/15/Center-data-in-R/ |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
2 center_colmeans <- function(x) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
3 xcenter = colMeans(x) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
4 x - rep(xcenter, rep.int(nrow(x), ncol(x))) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
5 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
6 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
7 #### OPLS-DA |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
8 algoC <- "nipals" |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
9 |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
10 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
|
11 x_dataMatrix |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
12 , x_predictor |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
13 , x_is_match |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
14 , x_algorithm |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
15 , x_prefix |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
16 , x_show_labels |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
17 , x_progress = print |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
18 , x_env |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
19 , x_crossval_i |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
20 ) { |
2
e03582f26617
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 7682e8e7ae2bfb926d94b414b9a1649389f33582
eschen42
parents:
1
diff
changeset
|
21 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
|
22 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
|
23 && ncol(x_dataMatrix) > 0 |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
24 && length(unique(x_predictor))> 1 |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
25 && 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
|
26 ) { |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
27 my_oplsda <- opls( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
28 x = x_dataMatrix |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
29 , y = x_predictor |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
30 , algoC = x_algorithm |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
31 , predI = 1 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
32 , 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
|
33 , printL = FALSE |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
34 , plotL = FALSE |
3
5aaab36bc523
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 88004a3cf8868d68da1ec5bd2c1be53746350367
eschen42
parents:
2
diff
changeset
|
35 , 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
|
36 , 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
|
37 ) |
7
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
38 # strip out variables having negligible variance |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
39 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
|
40 my_oplsda_suppLs_y_levels <- levels(as.factor(my_oplsda@suppLs$y)) |
7
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
41 # x_progress(strF(x_dataMatrix)) |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
42 # x_progress(strF(my_oplsda)) |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
43 #x_progress(head(my_oplsda_suppLs_y_levels)) |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
44 #x_progress(unique(my_oplsda_suppLs_y_levels)) |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
45 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
|
46 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
|
47 do_s_plot <- function( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
48 x_env |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
49 , 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
|
50 , cplot_x = FALSE |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
51 , cor_vs_cov_x = NULL |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
52 ) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
53 { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
54 #print(ls(x_env)) # "cplot_y" etc |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
55 #print(str(x_env$cplot_y)) # chr "covariance" |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
56 if (cplot_x) { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
57 #print(x_env$cplot_y) # "covariance" |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
58 cplot_y_correlation <- (x_env$cplot_y == "correlation") |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
59 #print(cplot_y_correlation) # FALSE |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
60 } |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
61 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
|
62 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
|
63 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
|
64 , 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
|
65 , 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
|
66 , x_progress |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
67 ) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
68 } else { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
69 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
|
70 } |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
71 # print("str(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
|
72 # str(my_cor_vs_cov) |
7
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
73 if (is.null(my_cor_vs_cov) || sum(!is.na(my_cor_vs_cov$tsv1$covariance)) < 2) { |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
74 x_progress("No cor_vs_cov data produced") |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
75 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
|
76 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
|
77 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
|
78 } |
5
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
79 with( |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
80 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
|
81 , { |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
82 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
|
83 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
|
84 lim_x <- max(sapply(X=c(min_x, max_x), FUN=abs)) |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
85 covariance <- covariance / lim_x |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
86 lim_x <- 1.2 |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
87 # "It is generally accepted that a variable should be selected if vj>1, [27–29], |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
88 # 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
|
89 # (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
|
90 plus_cor <- correlation |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
91 plus_cov <- covariance |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
92 cex <- 0.65 |
5
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
93 which_projection <- if (projection == 1) "t1" else "o1" |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
94 which_loading <- if (projection == 1) "parallel" else "orthogonal" |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
95 if (projection == 1) { # predictor-projection |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
96 vipcp <- pmax(0, pmin(1,(vip4p-0.83)/(1.21-0.83))) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
97 if (!cplot_x) { # S-plot predictor-projection |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
98 my_xlab <- "relative covariance(feature,t1)" |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
99 my_x <- plus_cov |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
100 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
|
101 my_y <- plus_cor |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
102 } else { # C-plot predictor-projection |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
103 my_xlab <- "variable importance in predictor-projection" |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
104 my_x <- vip4p |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
105 if (cplot_y_correlation) { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
106 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
|
107 my_y <- plus_cor |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
108 } else { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
109 my_ylab <- "relative covariance(feature,t1)" |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
110 my_y <- plus_cov |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
111 } |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
112 } |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
113 if (cplot_x) { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
114 lim_x <- max(my_x, na.rm = TRUE) * 1.1 |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
115 my_xlim <- c( 0, lim_x + off(0.2) ) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
116 } else { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
117 my_xlim <- c( -lim_x - off(0.2), lim_x + off(0.2) ) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
118 } |
5
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
119 my_ylim <- c( -1.0 - off(0.2), 1.0 + off(0.2) ) |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
120 my_load_distal <- loadp |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
121 my_load_proximal <- loado |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
122 red <- as.numeric(correlation > 0) * vipcp |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
123 blue <- as.numeric(correlation < 0) * vipcp |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
124 alpha <- 0.1 + 0.4 * vipcp |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
125 red[is.na(red)] <- 0 |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
126 blue[is.na(blue)] <- 0 |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
127 alpha[is.na(alpha)] <- 0 |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
128 my_col <- rgb(blue = blue, red = red, green = 0, alpha = alpha) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
129 main_label <- sprintf("%s for level %s versus %s" |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
130 , x_prefix, fctr_lvl_1, fctr_lvl_2) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
131 } else { # orthogonal projection |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
132 vipco <- pmax(0, pmin(1,(vip4o-0.83)/(1.21-0.83))) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
133 if (!cplot_x) { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
134 my_xlab <- "relative covariance(feature,to1)" |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
135 my_x <- -plus_cov |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
136 } else { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
137 my_xlab <- "variable importance in orthogonal projection" |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
138 my_x <- vip4o |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
139 } |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
140 if (!cplot_x) { # S-plot orthogonal projection |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
141 my_xlim <- c( -lim_x - off(0.2), lim_x + off(0.2) ) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
142 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
|
143 my_y <- plus_cor |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
144 } else { # C-plot orthogonal projection |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
145 lim_x <- max(my_x, na.rm = TRUE) * 1.1 |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
146 my_xlim <- c( 0, lim_x + off(0.2) ) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
147 if (cplot_y_correlation) { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
148 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
|
149 my_y <- plus_cor |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
150 } else { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
151 my_ylab <- "relative covariance(feature,to1)" |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
152 my_y <- plus_cov |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
153 } |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
154 } |
5
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
155 my_ylim <- c( -1.0 - off(0.2), 1.0 + off(0.2) ) |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
156 my_load_distal <- loado |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
157 my_load_proximal <- loadp |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
158 alpha <- 0.1 + 0.4 * vipco |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
159 alpha[is.na(alpha)] <- 0 |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
160 my_col <- rgb(blue = 0, red = 0, green = 0, alpha = alpha) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
161 main_label <- sprintf( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
162 "Features influencing orthogonal projection for %s versus %s" |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
163 , fctr_lvl_1, fctr_lvl_2) |
1
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
164 } |
5
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
165 main_cex <- min(1.0, 46.0/nchar(main_label)) |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
166 my_feature_label_slant <- -30 # slant feature labels 30 degrees downward |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
167 plot( |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
168 y = my_y |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
169 , x = my_x |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
170 , type = "p" |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
171 , xlim = my_xlim |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
172 , ylim = my_ylim |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
173 , xlab = my_xlab |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
174 , ylab = my_ylab |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
175 , main = main_label |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
176 , cex.main = main_cex |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
177 , cex = cex |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
178 , pch = 16 |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
179 , col = my_col |
1
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
180 ) |
5
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
181 low_x <- -0.7 * lim_x |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
182 high_x <- 0.7 * lim_x |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
183 if (projection == 1 && !cplot_x) { |
5
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
184 text(x = low_x, y = -0.05, labels = fctr_lvl_1, col = "blue") |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
185 text(x = high_x, y = 0.05, labels = fctr_lvl_2, col = "red") |
2
e03582f26617
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 7682e8e7ae2bfb926d94b414b9a1649389f33582
eschen42
parents:
1
diff
changeset
|
186 } |
5
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
187 if ( x_show_labels != "0" ) { |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
188 names(my_load_distal) <- tsv1$featureID |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
189 names(my_load_proximal) <- tsv1$featureID |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
190 if ( x_show_labels == "ALL" ) { |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
191 n_labels <- length(my_load_distal) |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
192 } else { |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
193 n_labels <- as.numeric(x_show_labels) |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
194 } |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
195 n_labels <- min( n_labels, (1 + length(my_load_distal)) / 2 ) |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
196 labels_to_show <- c( |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
197 names(head(sort(my_load_distal),n = n_labels)) |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
198 , names(tail(sort(my_load_distal),n = n_labels)) |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
199 ) |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
200 labels <- unname( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
201 sapply( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
202 X = tsv1$featureID |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
203 , FUN = function(x) if( x %in% labels_to_show ) x else "" |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
204 ) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
205 ) |
5
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
206 x_text_offset <- 0.024 |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
207 y_text_off <- 0.017 |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
208 if (!cplot_x) { # S-plot |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
209 y_text_offset <- if (projection == 1) -y_text_off else y_text_off |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
210 } else { # C-plot |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
211 y_text_offset <- |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
212 sapply( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
213 X = (my_y > 0) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
214 , FUN = function(x) { if (x) y_text_off else -y_text_off } |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
215 ) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
216 } |
5
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
217 label_features <- function(x_arg, y_arg, labels_arg, slant_arg) { |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
218 # print("str(x_arg)") |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
219 # print(str(x_arg)) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
220 # print("str(y_arg)") |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
221 # print(str(y_arg)) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
222 # print("str(labels_arg)") |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
223 # print(str(labels_arg)) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
224 if (length(labels_arg) > 0) { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
225 unique_slant <- unique(slant_arg) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
226 if (length(unique_slant) == 1) { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
227 text( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
228 y = y_arg |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
229 , x = x_arg + x_text_offset |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
230 , cex = 0.4 |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
231 , labels = labels_arg |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
232 , col = rgb(blue = 0, red = 0, green = 0, alpha = 0.5) # grey semi-transparent labels |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
233 , srt = slant_arg |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
234 , adj = 0 # left-justified |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
235 ) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
236 } else { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
237 for (slant in unique_slant) { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
238 text( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
239 y = y_arg[slant_arg == slant] |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
240 , x = x_arg[slant_arg == slant] + x_text_offset |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
241 , cex = 0.4 |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
242 , labels = labels_arg[slant_arg == slant] |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
243 , col = rgb(blue = 0, red = 0, green = 0, alpha = 0.5) # grey semi-transparent labels |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
244 , srt = slant |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
245 , adj = 0 # left-justified |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
246 ) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
247 } |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
248 } |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
249 } |
5
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
250 } |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
251 if (!cplot_x) { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
252 my_slant <- (if (projection == 1) 1 else -1) * my_feature_label_slant |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
253 } else { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
254 my_slant <- sapply( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
255 X = (my_y > 0) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
256 , FUN = function(x) if (x) 2 else -2 |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
257 ) * my_feature_label_slant |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
258 } |
5
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
259 if (length(my_x) > 1) { |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
260 label_features( |
5
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
261 x_arg = my_x [my_x > 0] |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
262 , y_arg = my_y [my_x > 0] - y_text_offset |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
263 , labels_arg = labels[my_x > 0] |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
264 , slant_arg = (if (!cplot_x) -my_slant else (my_slant)) |
5
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
265 ) |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
266 if (!cplot_x) { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
267 label_features( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
268 x_arg = my_x [my_x < 0] |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
269 , y_arg = my_y [my_x < 0] + y_text_offset |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
270 , labels_arg = labels[my_x < 0] |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
271 , slant_arg = my_slant |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
272 ) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
273 } |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
274 } else { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
275 if (!cplot_x) { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
276 my_slant <- (if (my_x > 1) -1 else 1) * my_slant |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
277 my_y_arg = my_y + (if (my_x > 1) -1 else 1) * y_text_offset |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
278 } else { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
279 my_slant <- (if (my_y > 1) -1 else 1) * my_slant |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
280 my_y_arg = my_y + (if (my_y > 1) -1 else 1) * y_text_offset |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
281 } |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
282 label_features( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
283 x_arg = my_x |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
284 , y_arg = my_y_arg |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
285 , labels_arg = labels |
5
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
286 , slant_arg = my_slant |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
287 ) |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
288 } |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
289 } |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
290 } |
5
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
291 ) |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
292 return (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
|
293 } |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
294 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
|
295 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
|
296 , 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
|
297 , cplot_x = FALSE |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
298 ) |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
299 typeVc <- c("correlation", # 1 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
300 "outlier", # 2 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
301 "overview", # 3 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
302 "permutation", # 4 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
303 "predict-train", # 5 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
304 "predict-test", # 6 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
305 "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
|
306 "x-loading", # 8 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
307 "x-score", # 9 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
308 "x-variance", # 10 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
309 "xy-score", # 11 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
310 "xy-weight" # 12 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
311 ) # [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
|
312 if ( length(my_oplsda@orthoVipVn) > 0 ) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
313 my_typevc <- typeVc[c(9,3,8)] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
314 } else { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
315 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
|
316 } |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
317 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
|
318 for (my_type in my_typevc) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
319 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
|
320 tryCatch({ |
5
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
321 if ( my_type != "x-loading" ) { |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
322 plot( |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
323 x = my_oplsda |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
324 , typeVc = my_type |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
325 , parCexN = 0.4 |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
326 , parDevNewL = FALSE |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
327 , parLayL = TRUE |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
328 , parEllipsesL = TRUE |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
329 ) |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
330 if (my_type == "overview") { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
331 sub_label <- sprintf("%s versus %s", fctr_lvl_1, fctr_lvl_2) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
332 title(sub = sub_label) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
333 } |
5
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
334 } else { |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
335 my_ortho_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
|
336 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
|
337 , 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
|
338 , cplot_x = FALSE |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
339 ) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
340 my_ortho_cor_vs_cov_exists <- TRUE |
5
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
341 } |
4
8bba31f628da
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 8f2dc8b66666340275cd8967e09c504720528462
eschen42
parents:
3
diff
changeset
|
342 }, 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
|
343 x_progress( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
344 sprintf( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
345 "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
|
346 , fctr_lvl_1 |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
347 , fctr_lvl_2 |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
348 , e$message |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
349 ) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
350 ) |
4
8bba31f628da
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 8f2dc8b66666340275cd8967e09c504720528462
eschen42
parents:
3
diff
changeset
|
351 }) |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
352 } else { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
353 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
|
354 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
|
355 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
356 } |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
357 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
|
358 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
|
359 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
|
360 if (cplot_p) { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
361 do_s_plot( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
362 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
|
363 , 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
|
364 , cplot_x = TRUE |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
365 , cor_vs_cov_x = 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
|
366 ) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
367 did_plots <- 1 |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
368 } else { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
369 did_plots <- 0 |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
370 } |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
371 if (cplot_o) { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
372 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
|
373 do_s_plot( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
374 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
|
375 , 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
|
376 , cplot_x = TRUE |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
377 , 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
|
378 ) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
379 } else { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
380 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
|
381 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
|
382 } |
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 + did_plots |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
384 } |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
385 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
|
386 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
|
387 } |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
388 } |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
389 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
|
390 } else { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
391 return (NULL) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
392 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
393 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
394 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
395 # 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
|
396 corcov_calc <- function( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
397 calc_env |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
398 , failure_action = stop |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
399 , 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
|
400 , 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
|
401 , 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
|
402 , extra_plots = c() |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
403 ) { |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
404 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
|
405 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
|
406 return ( FALSE ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
407 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
408 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
|
409 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
|
410 return ( FALSE ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
411 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
412 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
|
413 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
|
414 return ( FALSE ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
415 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
416 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
417 # 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
|
418 vrbl_metadata <- calc_env$vrbl_metadata |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
419 vrbl_metadata_names <- vrbl_metadata[,1] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
420 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
|
421 data_matrix <- calc_env$data_matrix |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
422 pairSigFeatOnly <- calc_env$pairSigFeatOnly |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
423 facC <- calc_env$facC |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
424 tesC <- calc_env$tesC |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
425 # 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
|
426 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
|
427 # 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
|
428 matchingC <- calc_env$matchingC |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
429 labelFeatures <- calc_env$labelFeatures |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
430 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
431 # arg/env checking |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
432 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
|
433 failure_action( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
434 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
|
435 , facC)) |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
436 return ( FALSE ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
437 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
438 |
1
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
439 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
|
440 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
|
441 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
|
442 |
1
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
443 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
|
444 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
|
445 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
|
446 |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
447 # calculate salience_df as data.frame(feature, max_level, max_median, max_rcv, mean_median, salience, salient_rcv) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
448 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
|
449 data_matrix = data_matrix |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
450 , 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
|
451 , failure_action = failure_action |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
452 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
453 salience_tsv_action({ |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
454 my_df <- data.frame( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
455 featureID = salience_df$feature |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
456 , salientLevel = salience_df$max_level |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
457 , salientRCV = salience_df$salient_rcv |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
458 , salience = salience_df$salience |
1
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
459 , mz = mz_lookup(salience_df$feature) |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
460 , rt = rt_lookup(salience_df$feature) |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
461 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
462 my_df[order(-my_df$salience),] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
463 }) |
1
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
464 |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
465 # transform wildcards to regexen |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
466 if (matchingC == "wildcard") { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
467 # 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
|
468 levCSV <- gsub("[.]", "[.]", levCSV) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
469 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
|
470 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
|
471 levCSV <- paste(levCSV, collapse = ",") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
472 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
473 # 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
|
474 isLevelSelected <- function(lvl) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
475 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
|
476 return( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
477 Reduce( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
478 f = "||" |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
479 , x = sapply( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
480 X = strsplit( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
481 x = levCSV |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
482 , split = "," |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
483 , fixed = TRUE |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
484 )[[1]] |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
485 , FUN = matchFun |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
486 , lvl |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
487 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
488 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
489 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
490 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
491 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
492 # 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
|
493 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
|
494 # 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
|
495 # 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
|
496 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
497 # 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
|
498 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
|
499 # 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
|
500 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
|
501 # 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
|
502 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
|
503 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
504 # 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
|
505 # - feature ID |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
506 # - value1 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
507 # - value2 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
508 # - Wiklund_2008 correlation |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
509 # - Wiklund_2008 covariance |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
510 # - Wiklund_2008 VIP |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
511 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
|
512 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
513 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
514 did_plot <- FALSE |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
515 if (tesC != "none") { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
516 # 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
|
517 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
|
518 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
|
519 failure_action( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
520 sprintf( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
521 "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
|
522 , tesC)) |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
523 return ( FALSE ) |
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 col_matches <- lapply( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
526 X = the_colnames, |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
527 FUN = function(x) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
528 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
|
529 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
530 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
531 ## 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
|
532 # 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
|
533 level_union <- c() |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
534 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
|
535 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
|
536 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
|
537 # 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
|
538 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
|
539 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
|
540 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
|
541 # 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
|
542 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
|
543 if (is_match) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
544 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
|
545 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
546 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
547 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
548 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
|
549 overall_significant <- 1 == ( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
550 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
|
551 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
|
552 } else { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
553 1 |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
554 } |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
555 ) |
1
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
556 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
|
557 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
|
558 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
|
559 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
|
560 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
|
561 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
|
562 progress_action( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
563 sprintf("calculating/plotting contrast of %s vs. %s" |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
564 , fctr_lvl_1, fctr_lvl_2)) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
565 predictor <- sapply( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
566 X = chosen_facC |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
567 , 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
|
568 ) |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
569 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
|
570 x_dataMatrix = my_matrix |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
571 , x_predictor = predictor |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
572 , x_is_match = is_match |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
573 , x_algorithm = algoC |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
574 , x_prefix = if (pairSigFeatOnly) { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
575 "Significantly contrasting features" |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
576 } else { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
577 "Significant features" |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
578 } |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
579 , x_show_labels = labelFeatures |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
580 , 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
|
581 , 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
|
582 , x_env = calc_env |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
583 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
584 if ( is.null(my_cor_cov) ) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
585 progress_action("NOTHING TO PLOT.") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
586 } else { |
1
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
587 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
|
588 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
|
589 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
|
590 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
|
591 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
|
592 , vrbl_metadata_col |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
593 ] |
1
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
594 tsv <<- my_tsv |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
595 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
|
596 did_plot <<- TRUE |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
597 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
598 } |
1
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
599 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
|
600 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
|
601 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
|
602 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
|
603 } |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
604 } else { |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
605 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
|
606 } |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
607 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
608 |
1
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
609 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
|
610 ## 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
|
611 # 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
|
612 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
|
613 # 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
|
614 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
|
615 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
|
616 # 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
|
617 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
|
618 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
|
619 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
|
620 # 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
|
621 is_match <- isLevelSelected(fctr_lvl_1) && isLevelSelected(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
|
622 progress_action( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
623 sprintf("calculating/plotting contrast of %s vs. %s" |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
624 , fctr_lvl_1, fctr_lvl_2)) |
1
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
625 # choose only samples with one of the two factors for this column |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
626 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
|
627 predictor <- smpl_metadata_facC[chosen_samples] |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
628 # extract only the significantly-varying features and the chosen samples |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
629 fully_significant <- 1 == vrbl_metadata[,vrbl_metadata_col] * |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
630 ( 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
|
631 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
|
632 } else { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
633 1 |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
634 } |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
635 ) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
636 col_selector <- vrbl_metadata_names[ |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
637 if ( pairSigFeatOnly ) fully_significant else overall_significant |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
638 ] |
7
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
639 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
|
640 my_cor_cov <- do_detail_plot( |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
641 x_dataMatrix = my_matrix |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
642 , x_predictor = predictor |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
643 , x_is_match = is_match |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
644 , x_algorithm = algoC |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
645 , x_prefix = if (pairSigFeatOnly) { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
646 "Significantly contrasting features" |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
647 } else { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
648 "Significant features" |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
649 } |
1
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
650 , x_show_labels = labelFeatures |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
651 , 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
|
652 , x_crossval_i = min(7, length(chosen_samples)) |
1
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
653 , x_env = calc_env |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
654 ) |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
655 if ( is.null(my_cor_cov) ) { |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
656 progress_action("NOTHING TO PLOT.") |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
657 } else { |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
658 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
|
659 tsv$mz <- mz_lookup(tsv$featureID) |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
660 tsv$rt <- rt_lookup(tsv$featureID) |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
661 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
|
662 match(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
|
663 , vrbl_metadata_col |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
664 ] |
1
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
665 corcov_tsv_action(tsv) |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
666 did_plot <- TRUE |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
667 } |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
668 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
669 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
670 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
671 } else { # tesC == "none" |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
672 level_union <- unique(sort(smpl_metadata_facC)) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
673 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
|
674 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
|
675 ## 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
|
676 completed <- c() |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
677 lapply( |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
678 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
|
679 , 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
|
680 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
|
681 fctr_lvl_2 <- { |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
682 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
|
683 return("DUMMY") |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
684 # strF(completed) |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
685 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
|
686 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
|
687 } |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
688 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
|
689 fctr_lvl_2 <- "other" |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
690 progress_action( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
691 sprintf("calculating/plotting contrast of %s vs. %s" |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
692 , fctr_lvl_1, fctr_lvl_2) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
693 ) |
1
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
694 if (length(unique(chosen_samples)) < 1) { |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
695 progress_action("NOTHING TO PLOT...") |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
696 } else { |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
697 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
|
698 predictor <- sapply( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
699 X = chosen_facC |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
700 , FUN = function(fac) { |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
701 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
|
702 } |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
703 ) |
7
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
704 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
|
705 # 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
|
706 is_match <- isLevelSelected(fctr_lvl_1) |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
707 my_cor_cov <- do_detail_plot( |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
708 x_dataMatrix = my_matrix |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
709 , x_predictor = predictor |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
710 , x_is_match = is_match |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
711 , x_algorithm = algoC |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
712 , x_prefix = "Features" |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
713 , x_show_labels = labelFeatures |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
714 , 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
|
715 , x_crossval_i = min(7, length(chosen_samples)) |
1
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
716 , x_env = calc_env |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
717 ) |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
718 if ( is.null(my_cor_cov) ) { |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
719 progress_action("NOTHING TO PLOT") |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
720 } else { |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
721 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
|
722 tsv$mz <- mz_lookup(tsv$featureID) |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
723 tsv$rt <- rt_lookup(tsv$featureID) |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
724 corcov_tsv_action(tsv) |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
725 did_plot <<- TRUE |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
726 } |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
727 } |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
728 "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
|
729 } |
1
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
730 ) |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
731 } |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
732 ## 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
|
733 completed <- c() |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
734 utils::combn( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
735 x = level_union |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
736 , m = 2 |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
737 , FUN = function(x) { |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
738 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
|
739 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
|
740 chosen_samples <- smpl_metadata_facC %in% c(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
|
741 progress_action( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
742 sprintf("calculating/plotting contrast of %s vs. %s" |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
743 , fctr_lvl_1, fctr_lvl_2)) |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
744 if (length(unique(chosen_samples)) < 1) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
745 progress_action("NOTHING TO PLOT...") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
746 } else { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
747 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
|
748 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
|
749 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
|
750 # 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
|
751 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
|
752 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
|
753 x_dataMatrix = my_matrix |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
754 , x_predictor = predictor |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
755 , x_is_match = is_match |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
756 , x_algorithm = algoC |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
757 , x_prefix = "Features" |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
758 , x_show_labels = labelFeatures |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
759 , 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
|
760 , 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
|
761 , x_env = calc_env |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
762 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
763 if ( is.null(my_cor_cov) ) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
764 progress_action("NOTHING TO PLOT") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
765 } else { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
766 tsv <- my_cor_cov$tsv1 |
1
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
767 tsv$mz <- mz_lookup(tsv$featureID) |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
768 tsv$rt <- rt_lookup(tsv$featureID) |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
769 corcov_tsv_action(tsv) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
770 did_plot <<- TRUE |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
771 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
772 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
773 "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
|
774 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
775 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
776 } else { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
777 progress_action("NOTHING TO PLOT....") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
778 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
779 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
780 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
|
781 failure_action( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
782 sprintf( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
783 "bad parameter! sampleMetadata must have at least two levels of factor '%s' matching '%s'" |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
784 , facC, originalLevCSV)) |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
785 return ( FALSE ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
786 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
787 return ( TRUE ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
788 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
789 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
790 # 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
|
791 # Adapted from: |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
792 # 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
|
793 # 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
|
794 # 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
|
795 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
|
796 matrix_x |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
797 , ropls_x |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
798 , 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
|
799 , x_progress = print |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
800 ) { |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
801 tryCatch({ |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
802 return( |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
803 cor_vs_cov_try( matrix_x, ropls_x, predictor_projection_x, x_progress) |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
804 ) |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
805 }, error = function(e) { |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
806 x_progress( |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
807 sprintf( |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
808 "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
|
809 , 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
|
810 ) |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
811 ) |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
812 return ( NULL ) |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
813 }) |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
814 } |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
815 |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
816 cor_vs_cov_try <- function( |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
817 matrix_x |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
818 , ropls_x |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
819 , predictor_projection_x = TRUE |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
820 , x_progress = print |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
821 ) { |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
822 x_class <- class(ropls_x) |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
823 if ( !( as.character(x_class) == "opls" ) ) { # || !( attr(class(x_class),"package") == "ropls" ) ) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
824 stop( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
825 paste( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
826 "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
|
827 , 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
|
828 ) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
829 ) |
0
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 result <- list() |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
832 result$projection <- projection <- if (predictor_projection_x) 1 else 2 |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
833 # suppLs$algoC - Character: algorithm used - "svd" for singular value decomposition; "nipals" for NIPALS |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
834 if ( ropls_x@suppLs$algoC == "nipals") { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
835 # Equations (1) and (2) from *Supplement to* Wiklund 2008, doi:10.1021/ac0713510 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
836 mag <- function(one_dimensional) sqrt(sum(one_dimensional * one_dimensional)) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
837 mag_xi <- sapply(X = 1:ncol(matrix_x), FUN = function(x) mag(matrix_x[,x])) |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
838 if (predictor_projection_x) |
5
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
839 score_matrix <- ropls_x@scoreMN |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
840 else |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
841 score_matrix <- ropls_x@orthoScoreMN |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
842 score_matrix_transposed <- t(score_matrix) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
843 score_matrix_magnitude <- mag(score_matrix) |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
844 result$covariance <- |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
845 score_matrix_transposed %*% matrix_x / ( score_matrix_magnitude * score_matrix_magnitude ) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
846 result$correlation <- |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
847 score_matrix_transposed %*% matrix_x / ( score_matrix_magnitude * mag_xi ) |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
848 } else { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
849 # WARNING - untested code - I don't have test data to exercise this branch |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
850 # Equations (1) and (2) from Wiklund 2008, doi:10.1021/ac0713510 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
851 # scoreMN - Numerical matrix of x scores (T; dimensions: nrow(x) x predI) X = TP' + E; Y = TC' + F |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
852 if (predictor_projection_x) |
5
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
853 score_matrix <- ropls_x@scoreMN |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
854 else |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
855 score_matrix <- ropls_x@orthoScoreMN |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
856 score_matrix_transposed <- t(score_matrix) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
857 cov_divisor <- nrow(matrix_x) - 1 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
858 result$covariance <- sapply( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
859 X = 1:ncol(matrix_x) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
860 , FUN = function(x) score_matrix_transposed %*% matrix_x[,x] / cov_divisor |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
861 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
862 score_sd <- sapply( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
863 X = 1:ncol(score_matrix) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
864 , FUN = function(x) sd(score_matrix[,x]) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
865 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
866 # xSdVn - Numerical vector: variable standard deviations of the 'x' matrix |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
867 xSdVn <- ropls_x@xSdVn |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
868 result$correlation <- sapply( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
869 X = 1:ncol(matrix_x) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
870 , FUN = function(x) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
871 ( score_matrix_transposed / score_sd ) %*% ( matrix_x[,x] / (xSdVn[x] * cov_divisor) ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
872 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
873 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
874 } |
5
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
875 result$correlation <- result$correlation[ 1, , drop = TRUE ] |
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
876 result$covariance <- result$covariance [ 1, , drop = TRUE ] |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
877 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
878 # Variant 4 of Variable Influence on Projection for OPLS from Galindo_Prieto_2014 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
879 # Length = number of features; labels = feature identifiers. (The same is true for $correlation and $covariance.) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
880 result$vip4p <- as.numeric(ropls_x@vipVn) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
881 result$vip4o <- as.numeric(ropls_x@orthoVipVn) |
1
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
882 result$loadp <- as.numeric(ropls_x@loadingMN) |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
883 result$loado <- as.numeric(ropls_x@orthoLoadingMN) |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
884 # get the level names |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
885 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
|
886 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
|
887 fctr_lvl_2 <- level_names[2] |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
888 feature_count <- length(ropls_x@vipVn) |
1
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
889 result$level1 <- rep.int(x = fctr_lvl_1, times = feature_count) |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
890 result$level2 <- rep.int(x = fctr_lvl_2, times = feature_count) |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
891 superresult <- list() |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
892 if (length(result$vip4o) == 0) result$vip4o <- NA |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
893 greaterLevel <- sapply( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
894 X = result$correlation |
7
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
895 , FUN = function(my_corr) |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
896 tryCatch({ |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
897 if ( is.nan( my_corr ) ) { |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
898 print("my_corr is NaN") |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
899 NA |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
900 } else { |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
901 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
|
902 } |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
903 }, error = function(e) { |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
904 x_progress( |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
905 sprintf( |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
906 "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
|
907 , as.character(e) |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
908 ) |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
909 ) |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
910 NA |
066b1f409e9f
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e73fabe1b3c871abbcb2e89914c181149c8e2066
eschen42
parents:
6
diff
changeset
|
911 }) |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
912 ) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
913 |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
914 # begin fixes for https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/issues/1 |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
915 featureID <- names(ropls_x@vipVn) |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
916 greaterLevel <- greaterLevel[featureID] |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
917 result$correlation <- result$correlation[featureID] |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
918 result$covariance <- result$covariance[featureID] |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
919 # end fixes for https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/issues/1 |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
920 |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
921 tsv1 <- data.frame( |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
922 featureID = featureID |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
923 , factorLevel1 = result$level1 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
924 , factorLevel2 = result$level2 |
1
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
925 , greaterLevel = greaterLevel |
5
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
926 , projection = result$projection |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
927 , correlation = result$correlation |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
928 , covariance = result$covariance |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
929 , vip4p = result$vip4p |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
930 , 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
|
931 , loadp = result$loadp |
0c2ad44b6c9c
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 01d4a951cf09e7b88fcec96b8043bc7568cc5c92
eschen42
parents:
0
diff
changeset
|
932 , loado = result$loado |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
933 , row.names = NULL |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
934 ) |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
935 tsv1 <- tsv1[!is.na(tsv1$correlation),] |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
936 tsv1 <- tsv1[!is.na(tsv1$covariance),] |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
937 superresult$tsv1 <- tsv1 |
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
938 rownames(superresult$tsv1) <- tsv1$featureID |
5
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
939 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
|
940 superresult$covariance <- result$covariance |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
941 superresult$correlation <- result$correlation |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
942 superresult$vip4p <- result$vip4p |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
943 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
|
944 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
|
945 superresult$loado <- result$loado |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
946 superresult$details <- result |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
947 result$superresult <- superresult |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
948 # Include thise in case future consumers of this routine want to use it in currently unanticipated ways |
6
7bd523ca1f9a
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
eschen42
parents:
5
diff
changeset
|
949 result$oplsda <- ropls_x |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
950 result$predictor <- ropls_x@suppLs$y # in case future consumers of this routine want to use it in currently unanticipated ways |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
951 return (superresult) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
952 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
953 |
5
50f60f94c034
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit aff1790e25523d038a1e9528de748191c096132f
eschen42
parents:
4
diff
changeset
|
954 # vim: sw=2 ts=2 et : |