mod.t.test: Moderated t-Test

Description Usage Arguments Details Value References See Also Examples

View source: R/mod.t.test.R

Description

Performs moderated t-tests based on Bioconductor package limma.

Usage

1
2
mod.t.test(x, group = NULL, paired = FALSE, adjust.method = "BH",
           sort.by = "none")

Arguments

x

a (non-empty) numeric matrix of data values.

group

an optional factor representing the groups.

paired

a logical indicating whether you want a paired test.

adjust.method

see p.adjust

sort.by

see toptable

, where "logFC" corresponds to difference in means.

Details

The function uses Bioconductor package limma to compute moderated t-tests. For more details we refer to ebayes.

Value

A data.frame with the results.

References

B. Phipson, S. Lee, I.J. Majewski, W.S. Alexander, G.H. Smyth (2016). Robust hyperparameter estimation protects against hypervariable genes and improves power to detect differential expression. Annals of Applied Statistics 10(2), 946-963.

See Also

t.test

Examples

 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
## One-sample test
X <- matrix(rnorm(10*20, mean = 1), nrow = 10, ncol = 20)

mod.t.test(X)
## corresponds to
library(limma)
design <- matrix(1, nrow = ncol(X), ncol = 1)
colnames(design) <- "A"
fit1 <- lmFit(X, design)
fit2 <- eBayes(fit1)
topTable(fit2, coef = 1, number = Inf, confint = TRUE, sort.by = "none")[,-4]

## Two-sample test
set.seed(123)
X <- rbind(matrix(rnorm(5*20), nrow = 5, ncol = 20),
           matrix(rnorm(5*20, mean = 1), nrow = 5, ncol = 20))
g2 <- factor(c(rep("group 1", 10), rep("group 2", 10)))

mod.t.test(X, group = g2)
## corresponds to
design <- model.matrix(~ 0 + g2)
colnames(design) <- c("group1", "group2")
fit1 <- lmFit(X, design)
cont.matrix <- makeContrasts(group1vsgroup2="group1-group2", levels=design)
fit2 <- contrasts.fit(fit1, cont.matrix)
fit3 <- eBayes(fit2)
topTable(fit3, coef = 1, number = Inf, confint = TRUE, sort.by = "none")[,-4]

## Paired two-sample test
mod.t.test(X, group = g2, paired = TRUE)

Example output

        mean       2.5%     97.5%        t      p.value  adj.p.value         B
1  0.7329972 0.30244132 1.1635531 3.358118 9.480720e-04 1.053413e-03 -1.064550
2  0.8911231 0.46056720 1.3216790 4.082549 6.556928e-05 9.367040e-05  1.581783
3  0.5272793 0.09672344 0.9578352 2.415652 1.665382e-02 1.665382e-02 -3.736086
4  0.9274839 0.49692800 1.3580398 4.249130 3.359039e-05 6.718079e-05  2.263173
5  1.0898935 0.65933762 1.5204494 4.993186 1.339574e-06 6.697869e-06  5.639326
6  0.8980587 0.46750279 1.3286146 4.114323 5.780408e-05 9.367040e-05  1.709651
7  1.0963458 0.66578995 1.5269017 5.022746 1.169711e-06 6.697869e-06  5.784683
8  0.7363582 0.30580234 1.1669141 3.373516 8.994488e-04 1.053413e-03 -1.013661
9  1.0528640 0.62230815 1.4834199 4.823541 2.885199e-06 7.212997e-06  4.821720
10 1.0625255 0.63196960 1.4930814 4.867804 2.366043e-06 7.212997e-06  5.032319
       logFC       CI.L      CI.R        t      P.Value    adj.P.Val         B
1  0.7329972 0.30244132 1.1635531 3.358118 9.480720e-04 1.053413e-03 -1.064550
2  0.8911231 0.46056720 1.3216790 4.082549 6.556928e-05 9.367040e-05  1.581783
3  0.5272793 0.09672344 0.9578352 2.415652 1.665382e-02 1.665382e-02 -3.736086
4  0.9274839 0.49692800 1.3580398 4.249130 3.359039e-05 6.718079e-05  2.263173
5  1.0898935 0.65933762 1.5204494 4.993186 1.339574e-06 6.697869e-06  5.639326
6  0.8980587 0.46750279 1.3286146 4.114323 5.780408e-05 9.367040e-05  1.709651
7  1.0963458 0.66578995 1.5269017 5.022746 1.169711e-06 6.697869e-06  5.784683
8  0.7363582 0.30580234 1.1669141 3.373516 8.994488e-04 1.053413e-03 -1.013661
9  1.0528640 0.62230815 1.4834199 4.823541 2.885199e-06 7.212997e-06  4.821720
10 1.0625255 0.63196960 1.4930814 4.867804 2.366043e-06 7.212997e-06  5.032319
   difference in means       2.5%     97.5%           t   p.value adj.p.value
1          -0.30099317 -1.1337943 0.5318079 -0.71317027 0.4766640   0.9665915
2           0.13637650 -0.6964246 0.9691776  0.32312914 0.7469725   0.9665915
3          -0.49260925 -1.3254104 0.3401919 -1.16718354 0.2446801   0.8156005
4           0.15266680 -0.6801343 0.9854679  0.36172723 0.7179801   0.9665915
5          -0.05546448 -0.8882656 0.7773366 -0.13141699 0.8955922   0.9665915
6          -0.03152278 -0.8643239 0.8012783 -0.07468976 0.9405445   0.9665915
7          -0.69311916 -1.5259203 0.1396820 -1.64226977 0.1022800   0.8156005
8          -0.17595066 -1.0087518 0.6568505 -0.41689577 0.6772514   0.9665915
9          -0.54524220 -1.3780433 0.2875589 -1.29189154 0.1980510   0.8156005
10         -0.01770155 -0.8505027 0.8150996 -0.04194188 0.9665915   0.9665915
           B mean of group 1 mean of group 2
1  -4.608912      0.07083562     0.371828786
2  -4.619655      0.13562592    -0.000750575
3  -4.586223     -0.30436677     0.188242477
4  -4.618953      0.18497579     0.032308986
5  -4.621971      0.08494719     0.140411667
6  -4.622282      1.11828347     1.149806246
7  -4.550748      0.67404426     1.367163425
8  -4.617811      0.53111339     0.707064052
9  -4.578072      0.92210638     1.467348578
10 -4.622384      0.48495033     0.502651884
         logFC       CI.L      CI.R           t   P.Value adj.P.Val         B
1  -0.30099317 -1.1337943 0.5318079 -0.71317027 0.4766640 0.9665915 -4.608912
2   0.13637650 -0.6964246 0.9691776  0.32312914 0.7469725 0.9665915 -4.619655
3  -0.49260925 -1.3254104 0.3401919 -1.16718354 0.2446801 0.8156005 -4.586223
4   0.15266680 -0.6801343 0.9854679  0.36172723 0.7179801 0.9665915 -4.618953
5  -0.05546448 -0.8882656 0.7773366 -0.13141699 0.8955922 0.9665915 -4.621971
6  -0.03152278 -0.8643239 0.8012783 -0.07468976 0.9405445 0.9665915 -4.622282
7  -0.69311916 -1.5259203 0.1396820 -1.64226977 0.1022800 0.8156005 -4.550748
8  -0.17595066 -1.0087518 0.6568505 -0.41689577 0.6772514 0.9665915 -4.617811
9  -0.54524220 -1.3780433 0.2875589 -1.29189154 0.1980510 0.8156005 -4.578072
10 -0.01770155 -0.8505027 0.8150996 -0.04194188 0.9665915 0.9665915 -4.622384
   mean of differences       2.5%       97.5%           t     p.value
1          -0.30099317 -0.7260027  0.12401634 -1.39744874 0.163998732
2           0.13637650 -0.2886330  0.56138600  0.63316773 0.527427738
3          -0.49260925 -0.9176188 -0.06759974 -2.28708237 0.023354856
4           0.15266680 -0.2723427  0.57767631  0.70880025 0.479365424
5          -0.05546448 -0.4804740  0.36954503 -0.25751005 0.797079211
6          -0.03152278 -0.4565323  0.39348673 -0.14635370 0.883805952
7          -0.69311916 -1.1181287 -0.26810966 -3.21800824 0.001531067
8          -0.17595066 -0.6009602  0.24905885 -0.81690235 0.415064109
9          -0.54524220 -0.9702517 -0.12023269 -2.53144623 0.012215144
10         -0.01770155 -0.4427111  0.40730796 -0.08218462 0.934591222
   adj.p.value         B
1   0.40999683 -5.193223
2   0.75346820 -5.932720
3   0.07784952 -3.631339
4   0.75346820 -5.884358
5   0.93459122 -6.092149
6   0.93459122 -6.113540
7   0.01531067 -1.189400
8   0.75346820 -5.805769
9   0.06107572 -3.070283
10  0.93459122 -6.120528

MKmisc documentation built on Aug. 8, 2021, 5:06 p.m.