Learn R Programming

hierGWAS (version 1.2.0)

compute.r2: R2 computation

Description

Calculates the R2 of a cluster of SNPs.

Usage

compute.r2(x, y, res.multisplit, covar = NULL, SNP_index = NULL)

Arguments

x
The input matrix, of dimension nobs x nvar. Each row represents a subject, each column a SNP.
y
The response vector. It can be continuous or discrete.
res.multisplit
The output of multisplit.
covar
NULL or the matrix of covariates one wishes to control for, of size nobs x ncovar.
SNP_index
NULL or the index vector of the cluster of SNPs whose R2 will be computed. See the 'Details' section.

Value

The R2 value of the SNP cluster

Details

The R2 of a cluster of SNPs is computed on the second half-samples. The cluster members, are intersected with the SNPs selected by the lasso, and the R2 of this model is calculated. Thus, we obtain B R2 values. Finally, the mean of these values is taken. If the value of SNP_index is NULL, the R2 of the full model with all the SNPs will be computed.

References

Buzdugan, L. et al. (2015), Assessing statistical significance in predictive genome-wide association studies. (unpublished)

Examples

Run this code
library(MASS)
x <- mvrnorm(60,mu = rep(0,60), Sigma = diag(60))
beta <- rep(0,60)
beta[c(5,9,3)] <- 1
y <- x %*% beta + rnorm(60)
SNP_index <- c(5,9,3)
res.multisplit <- multisplit(x, y)
r2 <- compute.r2(x, y, res.multisplit, SNP_index = SNP_index)

Run the code above in your browser using DataLab