Learn R Programming

ARTP (version 2.0.5)

single.marker.test: Single SNP test

Description

Perform an association test for 1 SNP

Usage

single.marker.test(y, covariates, weights, offset, control, snpcol,
                   min.count=5, y.continuous=FALSE)

Arguments

y

The response vector

covariates

A design matrix where the SNP is the last column. The SNP must be coded as 0-1-2.

weights

Vector of weights.

offset

Vector for the offset.

control

List for glm.control

snpcol

Number of columns of the design matrix covariates

min.count

The minimum number of subjects to have in at least 2 of the genotype categories (0-1-2), if y is continuous. If y is binary, then the minimum expected frequency count for cases or controls to use logistic regression; otherwise, Fisher's exact test will be used. The default is 5

y.continuous

TRUE or FALSE for whether or not y is continuous. If FALSE, then y must be coded as 0-1. The default is FALSE.

Value

The returned object is a vector of length 4 containing the p-value, p-value flag (see details), SNP main effect estimate, and standard error of the SNP main effect estimate. If Fisher's exact test was used, then the main effect and standard error will be set to NA.

Details

The input vectors and matrices must not contain missing values. To compute the p-value, either glm.fit, fisher.test or lm is called. The p-value flag is a value for how the p-value was computed:

Value Genetic Model Test
0 trend Wald test from logistic/linear regression
-1 dominant Fisher's exact test
-2 recessive Fisher's exact test
1 dominant Wald test from logistic regression

See Also

runPermutations

Examples

Run this code
# NOT RUN {
  # Generate data
  set.seed(123)
  n <- 1000
  y <- rbinom(n, 1, 0.5)
  snp <- rbinom(n, 2, 0.4)
  weights <- rep.int(1, times=n)
  offset  <- rep.int(0, times=n)
  control  <- glm.control()
 
  # Create a design matrix
  x <- matrix(data=NA, nrow=n, ncol=3)
  x[, 1] <- 1  # Intercept column
  x[, 2] <- runif(n) # Continuous covariate
  x[, 3] <- snp

  single.marker.test(y, x, weights, offset, control, 3)

# }

Run the code above in your browser using DataLab