Skip to content

Calculate the column-wise fold-change matrix of an ADAT. The clustering method "OLO" (Optimal-leaf-ordering) produces an optimal leaf ordering with respect to the minimizing the sum of the distances along the (Hamiltonian) path connecting the leaves in the given order. The time complexity of the algorithm is O(n^3). Note that non-finite distance values are not allowed.

Usage

calcFoldchangeMatrix(
  data,
  anno_tbl = NULL,
  apt.order = c(NA, "dilution", "cluster"),
  sample.order = NULL,
  max = 3,
  threshold = NULL
)

# S3 method for foldchange_matrix
print(x, ...)

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. If NULL, a table is generated internally from data (if possible), and the analytes are plotted in dilution order.

apt.order

Character. How should the columns (features) be ordered. By dilution mix, clustered, or as is in the data object?

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 in data.

max

Max value for the range to evaluate. Defaults to 3 which is typically good for most RFU data.

threshold

A threshold for the fold-change values. Values less than the threshold are set to zero. Threshold must be less than "max".

x

An object of class "foldchange_matrix".

...

Arguments for S3 print methods.

Value

A list of class c("foldchange_matrix", "Map") containing:

matrix

A matrix containing the protein fold-change values of each sample.

x.lab

A character string containing the plot x-axis label.

title

A character string containing the plot title.

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().

Functions

  • print(foldchange_matrix): There is a S3 print method for "foldchange_matrix".

See also

Author

Stu Field

Examples

sample.adat <- SomaDataIO::example_data
fc <- calcFoldchangeMatrix(sample.adat)
class(fc)
#> [1] "foldchange_matrix" "Map"               "list"             

# S3 print method
fc
#> ══ SomaLogic Fold-Change Matrix ══════════════════════════════════════════
#>   Fold-change matrix dim    '192 x 5284'
#>   Title                     'Fold-Change Matrix: log2(x / median(x))'
#>   x-label                   'Proteins Ordered in Adat'
#>   Sample Order              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
#>   Class Table               NA
#>   Legend Sub-title          'Proteins'
#> ══════════════════════════════════════════════════════════════════════════

# Sample Order
# specified by user
fc <- calcFoldchangeMatrix(sample.adat, sample.order = 192:1)  # by row indices
fc$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

# specified by field
fc <- calcFoldchangeMatrix(sample.adat, sample.order = "Sex")
fc$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

# specified by 2 fields in ADAT
fc <- calcFoldchangeMatrix(sample.adat,
                           sample.order = c("Sex", "TimePoint"))
fc$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