comparison w4mcorcov_salience.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 23f9fad4edfc
children 2ae2d26e3270
comparison
equal deleted inserted replaced
8:342570ad880c 9:06c51af11531
59 rcvOfFeatureBySampleClassLevel <- as.matrix( 59 rcvOfFeatureBySampleClassLevel <- as.matrix(
60 madOfFeatureBySampleClassLevel[,2:n_features_plus_1] / medianOfFeatureBySampleClassLevel[,2:n_features_plus_1] 60 madOfFeatureBySampleClassLevel[,2:n_features_plus_1] / medianOfFeatureBySampleClassLevel[,2:n_features_plus_1]
61 ) 61 )
62 rcvOfFeatureBySampleClassLevel[is.nan(rcvOfFeatureBySampleClassLevel)] <- max(9999,max(rcvOfFeatureBySampleClassLevel, na.rm = TRUE)) 62 rcvOfFeatureBySampleClassLevel[is.nan(rcvOfFeatureBySampleClassLevel)] <- max(9999,max(rcvOfFeatureBySampleClassLevel, na.rm = TRUE))
63 63
64 # "For each feature, 'select max(median_feature_intensity) from feature'." 64 # "For each feature, 'select max(max_feature_intensity) from feature'."
65 maxApplyMedianOfFeatureBySampleClassLevel <- sapply( 65 maxApplyMaxOfFeatureBySampleClassLevel <- sapply(
66 X = 1:n_features 66 X = 1:n_features
67 , FUN = function(i) { 67 , FUN = function(i) {
68 match( 68 match(
69 max(maxOfFeatureBySampleClassLevel[, i + 1]) 69 max(maxOfFeatureBySampleClassLevel[, i + 1])
70 , maxOfFeatureBySampleClassLevel[, i + 1] 70 , maxOfFeatureBySampleClassLevel[, i + 1]
82 # is for one particular class-level relative to the intensity across all class-levels. 82 # is for one particular class-level relative to the intensity across all class-levels.
83 salience_df <- data.frame( 83 salience_df <- data.frame(
84 # the feature name 84 # the feature name
85 feature = features 85 feature = features
86 # the name (or factor-level) of the class-level with the highest median intensity for the feature 86 # the name (or factor-level) of the class-level with the highest median intensity for the feature
87 , max_level = medianOfFeatureBySampleClassLevel[maxApplyMedianOfFeatureBySampleClassLevel,1] 87 , max_level = medianOfFeatureBySampleClassLevel[maxApplyMaxOfFeatureBySampleClassLevel,1]
88 # the median intensity for the feature and the level max_level 88 # the median intensity for the feature and the level max_level
89 , max_median = sapply( 89 , max_median = sapply(
90 X = 1:n_features 90 X = 1:n_features
91 , FUN = function(i) { 91 , FUN = function(i) {
92 maxOfFeatureBySampleClassLevel[maxApplyMedianOfFeatureBySampleClassLevel[i], 1 + i] 92 maxOfFeatureBySampleClassLevel[maxApplyMaxOfFeatureBySampleClassLevel[i], 1 + i]
93 } 93 }
94 ) 94 )
95 # the coefficient of variation (expressed as a proportion) for the intensity for the feature and the level max_level 95 # the coefficient of variation (expressed as a proportion) for the intensity for the feature and the level max_level
96 , max_rcv = sapply( 96 , max_rcv = sapply(
97 X = 1:n_features 97 X = 1:n_features
98 , FUN = function(i) { 98 , FUN = function(i) {
99 rcvOfFeatureBySampleClassLevel[maxApplyMedianOfFeatureBySampleClassLevel[i], i] 99 rcvOfFeatureBySampleClassLevel[maxApplyMaxOfFeatureBySampleClassLevel[i], i]
100 } 100 }
101 ) 101 )
102 # the mean of the medians of intensity for all class-levels for the feature 102 # the mean of the medians of intensity for all class-levels for the feature
103 , mean_median = meanApplyMedianOfFeatureBySampleClassLevel 103 , mean_median = meanApplyMedianOfFeatureBySampleClassLevel
104 # don't coerce strings to factors (this is a parameter for the data.frame constructor, not a column of the data.frame) 104 # don't coerce strings to factors (this is a parameter for the data.frame constructor, not a column of the data.frame)