tTestPerRow: T-test (Student or Welch) on each row of a data frame.

Description Usage Arguments Details Value Author(s) Examples

Description

Apply a t-test (Welch or Student) to each row of a a data frame containing multivariate data for two samples.

The estimators of central tendency and dispersion can either be computed with the moments (mean, standard deviation) or with robust esimators (median, IQR).

Usage

1
2
3
4
tTestPerRow(x, cl, P.threshold = NA, E.threshold = NA, FDR.threshold = NA,
  robust.est = F, verbosity = 1, volcanoPlot = FALSE,
  alternative = "two.sided", var.equal = FALSE, group.col.names = FALSE,
  test.group = cl[1], alpha = 0.05, ...)

Arguments

x

A matrix or data frame

cl

A vector describing class assignment (length should equal the number of columns of the data table)

...

Additional parameters are passed to the function tTestPerRow.plotVolcano()

P.threshold=NA

p-value threshold. If specified, the result table only contains rows passing this threshold.

E.threshold=NA

e-value threshold. If specified, the result table only contains rows passing this threshold.

FDR.threshold=NA

Threshold on the False Discovery Rate (FDR). If specified, the result table only contains rows passing this threshold.

robust.est=F

Use robust estimators for central tendency and dispersion

verbosity=1

Level of verbosity

volcanoPlot=T

Draw a volcano plot.

alternative="two-sided"

Alternative hypothesis for the Welch test. Supported: "two.sided" (default), "less", "greater".

var.equal=F

Assume or nt var.equaliable. Apply Student test if true, Welch test if false.

test.group=cl[1]

Specify which group should be considered as first term for the difference (d=m_{test}-m_{others}). By default the first label of the class vector (cl) is considered as test group.

group.col.name

Include group labels in the column name of the output table

alpha=0.05

Alpha value, used to define the confidence interval width

Details

First version: 2003-09 Last modification: 2015-02

Value

A data.frame with one row per test result, and one column per statistics.

Author(s)

Jacques van Helden (Jacques.van-Helden@univ-amu.fr)

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
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
## Load example data set from Den Boer, 2009
library(denboer2009)
data(denboer2009.expr)     ## Load expression table
data(denboer2009.pheno)    ## Load phenotypic data
data(denboer2009.group.labels)    ## Load phenotypic data

## Print cancer types and associated group labels
print(data.frame(denboer2009.group.labels))

## Compute the number of samples per subtype of cancer (ALL)
sort(table(denboer2009.pheno$sample.labels), decreasing=TRUE)

## Create a vector with group labels per sample,
## For the Welch test we compare one group of interest (e.g. Bh)
## to all the other ones (labeled as "other").
goi <- "Bh" ## Group of interest
sample.groups <- denboer2009.pheno$sample.labels
sample.groups[sample.groups != goi] <- "other"

## Check number of samples per group
sort(table(sample.groups))

## Run Welch test on each row of the DenBoer dataset
welch.result <- tTestPerRow(x=denboer2009.expr, cl=sample.groups, test.group="Bh", var.equal=FALSE)

## Draw a volcano plot with Welch result table
tTestPerRow.plotVolcano(welch.result, 
     main=paste(sep="", "Welch test: Den Boer (2009), ", goi, " vs others"),
     legend.corner = "topleft")

## Run Student test on each row of the DenBoer dataset
student.result <- tTestPerRow(x=denboer2009.expr, cl=sample.groups, test.group="Bh", var.equal=TRUE)

## Draw a volcano plot with Student result table
tTestPerRow.plotVolcano(student.result, 
            main=paste(sep="", "Student test: Den Boer (2009), ", goi, " vs others"),
            legend.corner="topleft")

## Draw a volcano plot with confidence interval bars for Student result table
tTestPerRow.plotVolcano(student.result, 
            main=paste(sep="", "Student test: Den Boer (2009), ", goi, " vs others"),
            legend.corner="topleft", plot.ci=TRUE, alpha=0.05)

## Compare e-values from Student and Welch tests
plotPvalCompa(data.frame(
   "Student"=student.result$table$e.value,
   "Welch"=welch.result$table$e.value), score="e-value", alpha=0.05)
   
## Compare FDR from Student and Welch tests
plotPvalCompa(data.frame(
   "Student"=student.result$table$fdr,
   "Welch"=welch.result$table$fdr), score="FDR", alpha=0.05)
   
## Confusion table between Student and Welch tests
table(student.result$table$fdr < 0.05, welch.result$table$fdr < 0.05) ## Lenient threshold on FDR
table(student.result$table$e.value < 0.05, welch.result$table$e.value < 0.05) ## Lenient threshold on E-value
table(student.result$table$e.value < 1, welch.result$table$e.value < 1) ## Intermediate threshold on E-value

jvanheld/stats4bioinfo documentation built on May 20, 2019, 5:16 a.m.