|
8 | 8 | # lfc = 0 |
9 | 9 | # sigma2post = fit$s2.post |
10 | 10 |
|
| 11 | + |
11 | 12 | .toptableTBC <- function(fit, |
12 | 13 | n, |
13 | 14 | design = NULL, |
|
40 | 41 | fit$coefficients <- as.matrix(fit$coefficients) |
41 | 42 | rn <- rownames(fit$coefficients) |
42 | 43 |
|
| 44 | + |
43 | 45 | # Check coef is length 1 |
44 | 46 | if (length(coef) > 1) { |
45 | 47 | coef <- coef[1] |
|
129 | 131 | }) |
130 | 132 | } |
131 | 133 |
|
132 | | - |
133 | 134 | # Extract statistics for table |
134 | 135 | M <- fit$coefficients[, coef] - bias[coef] |
135 | 136 | se_coef <- as.matrix(fit$coefficients / eb$t)[, coef] |
|
178 | 179 | tstat <- as.matrix(M / se_coef) |
179 | 180 | } |
180 | 181 | df_coef <- matrix(eb$df.total, |
181 | | - dimnames = list(names(tstat)) |
| 182 | + |
| 183 | + dimnames = list(names(tstat)) |
182 | 184 | ) |
183 | 185 | P.Value <- as.matrix(2 * pt(abs(tstat), |
184 | | - df = df_coef, lower.tail = FALSE |
185 | | - )) |
186 | | - |
| 186 | + df = df_coef, lower.tail = FALSE |
| 187 | + )) |
| 188 | + |
187 | 189 | # Apply multiple testing adjustment |
188 | 190 | adj.P.Value <- p.adjust(P.Value, method = adjust.method) |
189 | | - |
| 191 | + |
190 | 192 | # Thin out fit by p.value and lfc thresholds |
191 | 193 | if (p.value < 1 || lfc > 0) { |
192 | 194 | sig <- (adj.P.Value <= p.value) & (abs(M) >= lfc) |
|
227 | 229 | none = seq_along(M) |
228 | 230 | ) |
229 | 231 | top <- ord[1:number] |
230 | | - |
231 | 232 | # Assemble output data.frame |
232 | 233 | if (is.null(genelist)) { |
233 | 234 | tab <- data.frame(logFC = M[top]) |
|
253 | 254 | tab <- data.frame(tab, |
254 | 255 | t = tstat[top], P.Value = P.Value[top], |
255 | 256 | adj.P.Val = adj.P.Value[top] |
| 257 | + |
256 | 258 | ) |
257 | 259 | rownames(tab) <- rn[top] |
258 | 260 | } else if (returnVars) { |
|
270 | 272 | var.coef = se_coef[top]^2, |
271 | 273 | var.mode = var_mode[top], |
272 | 274 | cov.mode = cov_mode[top] |
| 275 | + |
273 | 276 | ) |
274 | 277 | } |
275 | 278 | rownames(tab) <- rn[top] |
@@ -559,7 +562,6 @@ topTableBC <- function(fit, |
559 | 562 | # Gordon Smyth |
560 | 563 | # 4 August 2003. Last modified 20 Aug 2022. |
561 | 564 |
|
562 | | - |
563 | 565 | # Check fit |
564 | 566 | if (!is(fit, "MArrayLM")) stop("fit must be an MArrayLM object") |
565 | 567 | if (is.null(fit$t) && is.null(fit$F)) { |
@@ -609,7 +611,6 @@ topTableBC <- function(fit, |
609 | 611 | } |
610 | 612 | } |
611 | 613 |
|
612 | | - |
613 | 614 | # Check adjust.method |
614 | 615 | if (is.null(adjust.method)) adjust.method <- "BH" |
615 | 616 |
|
|
0 commit comments