testPhenotype: Test the Phenotype of Interest for Association with...

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

View source: R/rw5mwas.r

Description

An internal, function for fast association testing. It tests the phenotype of interest for association with methylation coverage (columns of the data parameter).

Usage

1
testPhenotype(phenotype, data1, cvrtqr)

Arguments

phenotype

Vector with phenotype. Can be numerical, character, or factor vector.

data1

Matrix with data (normalized coverage), one variable (CpG) per column.

cvrtqr

Orthonormalized covariates, one covariate per column. See orthonormalizeCovariates.

Details

The testing is performed using matrix operations and C/C++ code, emplying an approach similar to that in MatrixEQTL.

Value

If the phenotype is numerical, the output is a list with

correlation

Correlations between residualized phenotype and data columns.

tstat

Corresponding T-statistics

pvalue

Corresponding P-values

nVarTested

Always 1

dfFull

Number of degrees of freedom of the T-test

If the phenotype is a factor (or character)

Rsquared

R-squared for the residualized ANOVA F-test.

Fstat

Corresponding F-test

pvalue

Corresponding P-values

nVarTested

First number of degrees of freedom for the F-test. Equal to the number of factor levels reduced by 1

dfFull

Second number of degrees of freedom for the F-test.

Note

This function is used in several parts of the pipeline.

Author(s)

Andrey A Shabalin [email protected]

See Also

See vignettes: browseVignettes("ramwas").

Also check orthonormalizeCovariates.

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
### Generate data inputs
# Random data matrix with signal in the first column
data = matrix(runif(30*5), nrow = 30, ncol = 5)
data[,1] = data[,1] + rep(0:2, each = 10)

# Two random covariates
cvrt = matrix(runif(2*30), nrow = 30, ncol = 2)
cvrtqr = orthonormalizeCovariates(cvrt)



### First, illustrate with numerical phenotype
# Numerical, 3 value phenotype
phenotype = rep(1:3, each = 10)

# Test for association
output = testPhenotype(phenotype, data, cvrtqr)

# Show the results
print(output)

# Comparing with standard R code for the first variable
summary(lm( data[,1] ~ phenotype + cvrt ))



### First, illustrate with numerical phenotype
# Categorical, 3 group phenotype
phenotype = rep(c("Normal", "Sick", "Dead"), each = 10)

# Test for association
output = testPhenotype(phenotype, data, cvrtqr)

# Show the results
print(output)

# Comparing with standard R code for the first variable
anova(lm( data[,1] ~ cvrt + phenotype ))

ramwas documentation built on Nov. 29, 2019, 2 a.m.