Mercurial > repos > eschen42 > w4mcorcov
annotate w4mcorcov_salience.R @ 14:90708fdbc22d draft default tip
"planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 5fd9687d543a48a715b1180caf93abebebd58b0e"
author | eschen42 |
---|---|
date | Wed, 18 Nov 2020 18:53:37 +0000 |
parents | 2ae2d26e3270 |
children |
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 w4msalience <- function( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
2 data_matrix # a matrix of intensities; features as rows, and samples as columns |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
3 , sample_class # a vector of sample class-levels; length(sample_class) == ncol(data_matrix) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
4 , failure_action = stop |
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 library(stats) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
7 # begin sanity checks |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
8 if ( !is.vector(sample_class) || !( is.character(sample_class) || is.factor(sample_class) ) ) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
9 failure_action("w4msalience: Expected sample_class to be a vector of characters of factor-levels") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
10 return (NULL) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
11 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
12 if ( !is.matrix(data_matrix) && !is.data.frame(data_matrix) ) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
13 failure_action("w4msalience: Expected data_matrix to be a matrix (or data.frame) of numeric") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
14 return (NULL) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
15 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
16 # transpose data_matrix so that columns are the features |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
17 t_data_matrix <- t(data_matrix) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
18 if ( !is.matrix(t_data_matrix) || !is.numeric(t_data_matrix) ) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
19 failure_action("w4msalience: Expected data_matrix to be a matrix (or data.frame) of numeric") |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
20 return (NULL) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
21 } |
13
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
22 |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
23 feature_names <- colnames(t_data_matrix) |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
24 |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
25 n_features <- ncol(t_data_matrix) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
26 n_samples <- nrow(t_data_matrix) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
27 if ( length(sample_class) != n_samples ) { |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
28 strF(data_matrix) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
29 strF(sample_class) |
13
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
30 failure_action( |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
31 sprintf( |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
32 "w4msalience: The data_matrix has %d samples but sample_class has %d" |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
33 , n_samples |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
34 , length(sample_class) |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
35 ) |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
36 ) |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
37 return (NULL) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
38 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
39 # end sanity checks |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
40 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
41 # "For each feature, 'select sample_class, median(intensity) from feature group by sample_class'." |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
42 # The first column(s) of the result of aggregate has the classifier value(s) specified in the 'by' list. |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
43 medianOfFeatureBySampleClassLevel <- aggregate( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
44 x = as.data.frame(t_data_matrix) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
45 , by = list(sample_class) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
46 , FUN = "median" |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
47 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
48 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
49 # "For each feature, 'select sample_class, rcv(intensity) from feature group by sample_class'." |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
50 # cv is less robust; deviation from normality degrades performance |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
51 # cv(x) == sd(x) / mean(x) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
52 # rcv is a "robust" coefficient of variation, expressed as a proportion |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
53 # rcv(x) == mad(x) / median(x) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
54 madOfFeatureBySampleClassLevel <- aggregate( |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
55 x = as.data.frame(t_data_matrix) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
56 , by = list(sample_class) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
57 , FUN = "mad" |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
58 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
59 |
13
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
60 # Note that `apply(X=array(1:10), MARGIN = 1, FUN = function(x) return(c(x,x^2)))` |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
61 # produces a matrix with two rows and ten columns |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
62 |
13
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
63 my_list <- apply( |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
64 X = array(1:n_features) |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
65 , MARGIN = 1 |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
66 , FUN = function(x) { |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
67 my_df <- data.frame( |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
68 median = medianOfFeatureBySampleClassLevel[ , 1 + x] |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
69 , mad = madOfFeatureBySampleClassLevel[ , 1 + x] |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
70 ) |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
71 my_df$salient_level <- medianOfFeatureBySampleClassLevel[ , 1] |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
72 my_df <- my_df[ order(my_df$median, decreasing = TRUE), ] |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
73 my_dist_df <- my_df[ 1:2, ] |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
74 # "robust coefficient of variation", i.e., |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
75 # mad(feature-intensity for class-level max_level) / median(feature-intensity for class-level max_level) |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
76 rcv_result <- my_dist_df$mad[1] / my_dist_df$median[1] |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
77 dist_result <- |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
78 ( my_dist_df$median[1] - my_dist_df$median[2] ) / |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
79 sqrt( my_dist_df$mad[1] * my_dist_df$mad[2] ) |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
80 if (is.infinite(dist_result) || is.nan(dist_result)) |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
81 dist_result <- 0 |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
82 mean_median <- mean(my_df$median) |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
83 salience_result <- if (mean_median > 0) my_df$median[1] / mean_median else 0 |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
84 return ( |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
85 data.frame( |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
86 dist_result = dist_result |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
87 , max_median = my_df$median[1] |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
88 , mean_median = mean_median |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
89 , salience_result = salience_result |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
90 , salient_level = my_df$salient_level[1] |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
91 , rcv_result = rcv_result |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
92 ) |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
93 ) |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
94 } |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
95 ) |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
96 results_matrix <- sapply(X = 1:n_features, FUN = function(i) my_list[[i]]) |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
97 results_df <- as.data.frame(t(results_matrix)) |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
98 |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
99 relative_salient_distance <- unlist(results_df$dist_result) |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
100 salience <- unlist(results_df$salience_result) |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
101 salient_level <- unlist(results_df$salient_level) |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
102 max_median <- unlist(results_df$max_median) |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
103 mean_median <- unlist(results_df$mean_median) |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
104 rcv_result <- unlist(results_df$rcv_result) |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
105 |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
106 salience_df <- |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
107 data.frame( |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
108 # the feature name |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
109 feature = feature_names |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
110 # the name (or factor-level) of the class-level with the highest median intensity for the feature |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
111 , max_level = salient_level |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
112 # the median intensity for the feature and the level max_level |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
113 , max_median = max_median |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
114 # the distance between the maximum intensities for the feature at the two highest levels |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
115 , relative_salient_distance = relative_salient_distance |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
116 # the coefficient of variation (expressed as a proportion) for the intensity for the feature and the level max_level |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
117 , salience_rcv = rcv_result |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
118 # the mean of the medians of intensity for all class-levels for the feature |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
119 , mean_median = mean_median |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
120 # raw salience is the ratio of the most-prominent level to the mean of all levels for the feature |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
121 , salience = salience |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
122 # don't coerce strings to factors (this is a parameter for the data.frame constructor, not a column of the data.frame) |
2ae2d26e3270
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit e89c652c0849eb1d5a1e6c9100c72c64a8d388b4
eschen42
parents:
9
diff
changeset
|
123 , stringsAsFactors = FALSE |
0
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
124 ) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
125 |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
126 return (salience_df) |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
127 } |
23f9fad4edfc
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit bd26542b811de06c1a877337a2840a9f899c2b94
eschen42
parents:
diff
changeset
|
128 |