matrixEpistasis: matrixEpistasis

Description Usage Arguments Value Author(s) See Also Examples

Description

matrixEpistasis uses large matrix operation to perform the exhaustive epistasis scan for quantitative traits with covariate adjustment

Usage

1
matrixEpistasis(snpA, snpB, trait, covariate = NULL)

Arguments

snpA

a matrix of numeric values in size of sample*snp representing the 1st group of SNPs, where the column names are the snp_ids

snpB

a matrix of numeric values in size of sample*snp representing the 2nd group of SNPs, where the column names are the snp_ids

trait

a vector of numeric values representing the quantitative trait

covariate

a matrix of numeric values in size of sample*covariate, by default, NULL

Value

A list containing the follow components:

Author(s)

Shijia Zhu, shijia.zhu@mssm.edu

See Also

p2c; matrixPval; smoothQQplot

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
# randomly generate a SNP matrix
snp <- sapply(1:100,function(i) rnorm(1000) )
# assign names to SNPs
colnames(snp) <- paste0('snp',1:100)
snpA = snp
snpB = snp

# radnomly generate a quantitative trait by simulating the relationship between SNPs and traits
trait <- snp %*% rnorm(100)

# use the top 5 PCs as the covariates 
covariate <- prcomp(snp)$x[,1:5]

# run matrixEpistasis with covariates adjustment
res <- matrixEpistasis( snpA=snpA, snpB=snpB, trait=trait, covariate = covariate )
r <- res$r
df <- res$df

# run matrixEpistasis function with covariates adjustment
res <- matrixEpistasis( snpA=snpA, snpB=snpB, trait=trait, covariate = covariate )

# res is a list comprising two components: r and df. res$r is the matrix of partial correlation coefficients between snp interaction (snpA*snpB) and trait with additive effects (snpA and snpB) and covariates adjusted, and res$df is the degree of freedom for the partial correlation.
names(res)
r = res$r 
df = res$df

# based on the degree of freedom, run matrixPval function to calculate p values for all partial correlation coefficients. The result is a matrix of p-values for epistasis of all snp interactions.
p <- matrixPval( r , df )

# alternatively, users can calculate p-values only for those entries with p vlaues less than a given threshold, say 1e-2, shown as follows: 
# use p2c to covert p value threshold 1e-5 to the corresponding partial correlation coefficient
corrThreshold <- p2c( pval=1e-2 , df )

# extract the index for those significant ones
index <- which( abs(r)>corrThreshold , arr.ind=TRUE )

# get the SNP names
snp1 <- colnames(snpA)[ index[,1] ]
snp2 <- colnames(snpB)[ index[,2] ]

# use matrixPval function to calculate p values for only those of interest
pvalue <- matrixPval( r[index] , df  )

# build the data frame
sig_res <- data.frame( snp1 , snp2 , pvalue )
head(sig_res)

fanglab/MatrixEpistasis documentation built on May 25, 2019, 5:22 p.m.