Learn R Programming

gtx (version 0.0.8)

grs.onesnp.apply: Convenience tool to fit a series of single-SNP models.

Description

This function takes as input a fitted model object, typically created by the standard R functions lm, glm or coxph, and fitted to individual-level genotype and phenotype data. The model is augmented by adding a term for each single SNP in turn and the refitted. This provides the single SNP summary association statistics needed to apply the summry statistic methods.

Usage

grs.onesnp.apply(params, object, coeff.extract.fun = coeff.extract)

Arguments

params
a data frame, see gtx.params.
object
a fitted model object of class lm, glm, or coxph
coeff.extract.fun
function that extracts Estimate and Std.Err from fitted model objects, see coeff.extract.

Details

By default this uses coeff.extract to detect the class of object and handles coefficient extraction appropriately. Supply your own function if you have an object that works with update (supply your own update too).

Examples

Run this code
library(survival)
data(t2d.scores)
data(t2dex)

mycoxph <- coxph(Surv(FollowupDays,FollowupT2D) ~ Overweight,
                 data = t2dex$data) # fit null model
assoc1 <- grs.onesnp.apply(t2d.scores, mycoxph) # single SNP association
## risk score fit from single SNPs
unlist(grs.summary(t2d.scores$coef, assoc1$beta, assoc1$se,
                   n = length(residuals(mycoxph))))

## compare direct analysis of subject-specific data
t2dex <- grs.make.scores(t2d.scores, t2dex)
coxph(Surv(FollowupDays,FollowupT2D) ~ Overweight + T2D2010.score,
      data = t2dex$data)

Run the code above in your browser using DataLab