WWtest: Multivariate Generalization of the Wald-Wolfowitz Runs Test

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/WWtest.R

Description

Performs two-sample nonparametric multivariate generalization of the Wald-Wolfowitz runs test based on the minimum spanning tree (MST). It tests the alternative hypothesis that a set of features has different distributions in two conditions against the null hypothesis of having the same distribution.

Usage

1
WWtest(object, group, nperm=1000, pvalue.only=TRUE)

Arguments

object

a numeric matrix with columns and rows respectively corresponding to samples and features.

group

a numeric vector indicating group associations for samples. Possible values are 1 and 2.

nperm

number of permutations used to estimate the null distribution of the test statistic. If not given, a default value 1000 is used.

pvalue.only

logical. If TRUE (default), the p-value is returned. If FALSE a list of length three containing the observed statistic, the vector of permuted statistics, and the p-value is returned.

Details

This function tests the alternative hypothesis that a set of features has different distributions in two conditions against the null hypothesis of having the same distribution. It performs the two-sample nonparametric multivariate generalization of the Wald-Wolfowitz runs test based on the minimum spanning tree (MST) as proposed by Friedman and Rafsky (1979). The performance of this test under different alternative hypotheses was thoroughly examind in Rahmatallah et. al. (2012). The null distribution of the test statistic is estimated by permuting sample labels nperm times and calculating the test statistic for each. P-value is calculated as

p.value = \frac{∑_{k=1}^{nperm} I ≤ft[ W_{k} ≤q W_{obs} \right] + 1}{nperm + 1}

where W_{k} is the test statistic for permutation k, W_{obs} is the observed test statistic, and I is the indicator function.

Value

When pvalue.only=TRUE (default), function WWtest returns the p-value indicating the attained significance level. When pvalue.only=FALSE, function WWtest produces a list of length 3 with the following components:

statistic

the value of the observed test statistic.

perm.stat

numeric vector of the resulting test statistic for nperm random permutations of sample labels.

p.value

p-value indicating the attained significance level.

Author(s)

Yasir Rahmatallah and Galina Glazko

References

Rahmatallah Y., Emmert-Streib F. and Glazko G. (2012) Gene set analysis for self-contained tests: complex null and specific alternative hypotheses. Bioinformatics 28, 3073–3080.

Friedman J. and Rafsky L. (1979) Multivariate generalization of the Wald-Wolfowitz and Smirnov two-sample tests. Ann. Stat. 7, 697–717.

See Also

KStest, RKStest, MDtest, RMDtest.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## generate a feature set of length 20 in two conditions
## each condition has 20 samples
## use multivariate normal distribution
library(MASS)
ngenes <- 20
nsamples <- 40
## let the mean vector have zeros of length 20 for condition 1
zero_vector <- array(0,c(1,ngenes))
## let the mean vector have 2s of length 20 for condition 2
mu_vector <- array(2,c(1,ngenes))
## set the covariance matrix to be an identity matrix
cov_mtrx <- diag(ngenes)
gp1 <- mvrnorm((nsamples/2), zero_vector, cov_mtrx)
gp2 <- mvrnorm((nsamples/2), mu_vector, cov_mtrx)
## combine the data of two conditions into one dataset
gp <- rbind(gp1,gp2)
dataset <- aperm(gp, c(2,1))
## first 20 samples belong to group 1
## second 20 samples belong to group 2
pvalue <- WWtest(object=dataset, group=c(rep(1,20),rep(2,20))) 

GSAR documentation built on Nov. 8, 2020, 7:16 p.m.