Skip to contents

Computes the two-sample Wilcoxon test for each feature.

See the Details section below for further information.

Usage

rowTwoSampleWilcoxonT(
  x,
  g,
  alternative = c("two.sided", "greater", "less"),
  paired = FALSE,
  null = 0,
  exact = NA,
  correct = TRUE
)

Arguments

x

matrix or data.frame.

g

a vector or factor object giving the group for the corresponding elements of x.

alternative

character string or vector of length nrow(x). The alternative hypothesis for each row of x. Values must be one of "two.sided" (default), "greater" or "less".

paired

logical, whether to compute a paired Wilcoxon test.

null

numerical value or numeric vector of length nrow(x). The true values of the difference in means between the two groups of observations for each row.

exact

logical or NA (default) indicator whether an exact p-value should be computed (see Details). A single value or a logical vector with values for each observation.

correct

logical indicator whether continuity correction should be applied in the cases where p-values are obtained using normal approximation. A single value or logical vector with values for each observation.

Value

A list containing two elements:

statistic

A numeric vector, the values of the test statistic

significance

A numeric vector, the p-values of the selected test

Details

The function internally calls row_wilcoxon_paired for the paired test, and row_wilcoxon_twosample for the unpaired test.

Author

Alessandro Barberis

Examples

#Seed
set.seed(1010)

#Data
x = matrix(rnorm(100 * 20), 100, 20)
g = c(rep(0,10),rep(1,10))

#Compute
rowTwoSampleWilcoxonT(x = x, g = g)
#> $statistic
#>   [1] 48 35 64 35 85 59 57 51 41 59 38 22 36 33 80 42 55 29 53 47 42 81 16 35 48
#>  [26] 61 58 41 36 24 39 92 69 45 34 68 43 43 41 38 53 44 35 60 61 40 76 66 66 85
#>  [51] 79 64 30 63 63 19 53 47 70 32 60 18 59 52 52 35 36 37 35 49 52 22 44 46 45
#>  [76] 25 51 72 44 57 46 39 51 41 57 40 67 50 55 27 66 81 40 61 69 56 39 32 63 29
#> 
#> $significance
#>   [1] 0.9117971811 0.2798610059 0.3149992422 0.2798610059 0.0068414558
#>   [6] 0.5288488601 0.6305289138 0.9705124597 0.5288488601 0.5288488601
#>  [11] 0.3930481283 0.0354629890 0.3149992422 0.2175626231 0.0232306393
#>  [16] 0.5787416917 0.7393643508 0.1230054775 0.8534283054 0.8534283054
#>  [21] 0.5787416917 0.0185433761 0.0089306978 0.2798610059 0.9117971811
#>  [26] 0.4358721774 0.5787416917 0.5288488601 0.3149992422 0.0524259023
#>  [31] 0.4358721774 0.0007252809 0.1654939488 0.7393643508 0.2474506917
#>  [36] 0.1903158761 0.6305289138 0.6305289138 0.5288488601 0.3930481283
#>  [41] 0.8534283054 0.6842105263 0.2798610059 0.4812509472 0.4358721774
#>  [46] 0.4812509472 0.0524259023 0.2474506917 0.2474506917 0.0068414558
#>  [51] 0.0288055598 0.3149992422 0.1431401416 0.3526813744 0.3526813744
#>  [56] 0.0185433761 0.8534283054 0.8534283054 0.1431401416 0.1903158761
#>  [61] 0.4812509472 0.0146896447 0.5288488601 0.9117971811 0.9117971811
#>  [66] 0.2798610059 0.3149992422 0.3526813744 0.2798610059 0.9705124597
#>  [71] 0.9117971811 0.0354629890 0.6842105263 0.7959362619 0.7393643508
#>  [76] 0.0630128386 0.9705124597 0.1051224317 0.6842105263 0.6305289138
#>  [81] 0.7959362619 0.4358721774 0.9705124597 0.5288488601 0.6305289138
#>  [86] 0.4812509472 0.2175626231 1.0000000000 0.7393643508 0.0892095521
#>  [91] 0.2474506917 0.0185433761 0.4812509472 0.4358721774 0.1654939488
#>  [96] 0.6842105263 0.4358721774 0.1903158761 0.3526813744 0.1230054775
#> 

#Compute paired
rowTwoSampleWilcoxonT(x = x, g = g, paired = TRUE)
#> $statistic
#>   [1] 30 18 36 16 52 38 37 19 22 35 22  8 19 12 37 24 28 12 30 30 23 51  9 16 27
#>  [26] 33 31 20 18 12 20 52 43 30 12 40 21 17 14 20 27 29 17 33 29 22 44 36 39 52
#>  [51] 48 40 13 40 33  7 28 26 42 14 35  6 33 30 26 15 21  7 18 28 27  8 24 18 21
#>  [76]  8 29 44 22 36 21 18 28 23 32 19 35 30 32 16 38 44 20 35 46 37 19 15 37 11
#> 
#> $significance
#>   [1] 0.845703125 0.375000000 0.431640625 0.275390625 0.009765625 0.322265625
#>   [7] 0.375000000 0.431640625 0.625000000 0.492187500 0.625000000 0.048828125
#>  [13] 0.431640625 0.130859375 0.375000000 0.769531250 1.000000000 0.130859375
#>  [19] 0.845703125 0.845703125 0.695312500 0.013671875 0.064453125 0.275390625
#>  [25] 1.000000000 0.625000000 0.769531250 0.492187500 0.375000000 0.130859375
#>  [31] 0.492187500 0.009765625 0.130859375 0.845703125 0.130859375 0.232421875
#>  [37] 0.556640625 0.322265625 0.193359375 0.492187500 1.000000000 0.921875000
#>  [43] 0.322265625 0.625000000 0.921875000 0.625000000 0.105468750 0.431640625
#>  [49] 0.275390625 0.009765625 0.037109375 0.232421875 0.160156250 0.232421875
#>  [55] 0.625000000 0.037109375 1.000000000 0.921875000 0.160156250 0.193359375
#>  [61] 0.492187500 0.027343750 0.625000000 0.845703125 0.921875000 0.232421875
#>  [67] 0.556640625 0.037109375 0.375000000 1.000000000 1.000000000 0.048828125
#>  [73] 0.769531250 0.375000000 0.556640625 0.048828125 0.921875000 0.105468750
#>  [79] 0.625000000 0.431640625 0.556640625 0.375000000 1.000000000 0.695312500
#>  [85] 0.695312500 0.431640625 0.492187500 0.845703125 0.695312500 0.275390625
#>  [91] 0.322265625 0.105468750 0.492187500 0.492187500 0.064453125 0.375000000
#>  [97] 0.431640625 0.232421875 0.375000000 0.105468750
#>