Calculate the median absolute deviation (statistical) outliers measurements
and fold-change criteria from an ADAT. Two values are required for the
calculation: median absolute deviation (MAD) and fold-change (FC). Outliers
are determined based on the result of both 6*MAD
and x*FC
, where x
is the number of fold changes defined.
Arguments
- data
A
soma_adat
object containing RFU feature data.- anno_tbl
An annotations table produced via
getAnalyteInfo()
. Used to calculate analyte dilutions for the matrix column ordering. IfNULL
, a table is generated internally fromdata
(if possible), and the analytes are plotted in dilution order.- apt.order
Character. How should the columns/features be ordered? Options include: by dilution mix ("dilution"), by median overall signal ("signal"), or as-is in
data
(default).- sample.order
Either a character string indicating the column name with entries to be used to order the data frame rows, or a numeric vector representing the order of the data frame rows. The default (
NULL
) leaves the row ordering as it is indata
.- fc.crit
Integer. The fold change criterion to evaluate. Defaults to 5x.
- x
An object of class
"outlier_map"
.- ...
Arguments for S3 print methods.
Value
A list of class c("outlier_map", "Map")
containing:
- matrix
A boolean matrix of
TRUE/FALSE
whether each sample is an outlier according the the stated criteria.- x.lab
A character string containing the plot x-axis label.
- title
A character string containing the plot title.
- rows.by.freq
A logical indicating if the samples are ordered by outlier frequency.
- class.tab
A table containing the frequencies of each class if input
sample.order
is defined as a categorical variable.- sample.order
A numeric vector representing the order of the data frame rows.
- legend.sub
A character string containing the plot legend subtitle.
Details
For the S3 plotting method, see plot.Map()
.
See also
Other Calc Map:
calcFoldchangeMatrix()
,
calcMissingnessMap()
,
getFlaggedIds()
,
plot.Map()
Examples
sample.adat <- SomaDataIO::example_data
om <- calcOutlierMap(sample.adat)
class(om)
#> [1] "outlier_map" "Map" "list"
# S3 print method
om
#> ══ SomaLogic Outlier Map ═════════════════════════════════════════════════
#> Outlier Map dimensions '192 x 5284'
#> Title 'Outlier Map: | x - median(x) | > 6 ● mad(x) & FC > 5x'
#> Class Table NA
#> Rows by Frequency FALSE
#> Sample Order 'Proteins Ordered in Adat'
#> x-label 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192
#> Legend Sub-title 'Proteins'
#> ══════════════════════════════════════════════════════════════════════════
# `sample.order = "frequency"` orders samples by outlier frequency
om <- calcOutlierMap(sample.adat, sample.order = "frequency")
om$rows.by.freq
#> [1] TRUE
om$sample.order
#> [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#> [18] 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
#> [35] 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
#> [52] 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
#> [69] 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
#> [86] 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
#> [103] 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
#> [120] 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
#> [137] 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
#> [154] 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
#> [171] 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
#> [188] 188 189 190 191 192
# order samples by user specified indices
om <- calcOutlierMap(sample.adat, sample.order = 192:1)
om$sample.order
#> [1] 192 191 190 189 188 187 186 185 184 183 182 181 180 179 178 177 176
#> [18] 175 174 173 172 171 170 169 168 167 166 165 164 163 162 161 160 159
#> [35] 158 157 156 155 154 153 152 151 150 149 148 147 146 145 144 143 142
#> [52] 141 140 139 138 137 136 135 134 133 132 131 130 129 128 127 126 125
#> [69] 124 123 122 121 120 119 118 117 116 115 114 113 112 111 110 109 108
#> [86] 107 106 105 104 103 102 101 100 99 98 97 96 95 94 93 92 91
#> [103] 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74
#> [120] 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57
#> [137] 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40
#> [154] 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23
#> [171] 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6
#> [188] 5 4 3 2 1
# order samples field in Adat
om <- calcOutlierMap(sample.adat, sample.order = "Sex")
om$sample.order
#> [1] 1 2 5 6 8 9 11 15 17 19 20 24 25 31 32 33 34
#> [18] 35 39 42 44 46 49 51 53 54 55 58 60 61 65 68 71 74
#> [35] 76 77 79 80 86 89 91 93 94 96 97 101 102 106 107 113 115
#> [52] 117 119 121 125 127 133 134 136 139 141 142 144 148 149 152 154 160
#> [69] 161 162 164 165 166 174 176 177 178 179 182 183 186 187 188 189 192
#> [86] 3 4 7 12 14 18 21 22 23 26 27 28 29 30 37 38 40
#> [103] 41 45 48 52 56 57 59 62 63 64 66 67 70 72 73 75 81
#> [120] 82 83 84 85 88 90 95 99 100 103 104 105 108 109 110 111 112
#> [137] 116 118 120 122 123 124 126 128 129 131 132 135 137 138 145 146 147
#> [154] 150 155 156 157 158 163 167 168 169 170 171 172 175 184 185 190 191
#> [171] 10 13 16 36 43 47 50 69 78 87 92 98 114 130 140 143 151
#> [188] 153 159 173 180 181