snp.lhs.tests: Score tests with SNP genotypes as dependent variable

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

View source: R/glm-test.R

Description

Under the assumption of Hardy-Weinberg equilibrium, a SNP genotype is a binomial variate with two trials for an autosomal SNP or with one or two trials (depending on sex) for a SNP on the X chromosome. With each SNP in an input "SnpMatrix" as dependent variable, this function first fits a "base" logistic regression model and then carries out a score test for the addition of further term(s). The Hardy-Weinberg assumption can be relaxed by use of a "robust" option.

Usage

1
2
3
snp.lhs.tests(snp.data, base.formula, add.formula, subset, snp.subset,
                data = sys.parent(), robust = FALSE, uncertain = FALSE, 
                control=glm.test.control(), score=FALSE)

Arguments

snp.data

The SNP data, as an object of class "SnpMatrix" or "XSnpMatrix"

base.formula

A formula object describing the base model, with dependent variable omitted

add.formula

A formula object describing the additional terms to be tested, also with dependent variable omitted

subset

An array describing the subset of observations to be considered

snp.subset

An array describing the subset of SNPs to be considered. Default action is to test all SNPs.

data

The data frame in which base.formula, add.formula and subset are to be evaluated

robust

If TRUE, a test which does not assume Hardy-Weinberg equilibrium will be used

uncertain

If TRUE, uncertain genotypes are used and scored by their posterior expectations. Otherwise they are treated as missing. If set, this option forces robust variance estimates

control

An object giving parameters for the IRLS algorithm fitting of the base model and for the acceptable aliasing amongst new terms to be tested. See glm.test.control

score

Is extended score information to be returned?

Details

The tests used are asymptotic chi-squared tests based on the vector of first and second derivatives of the log-likelihood with respect to the parameters of the additional model. The "robust" form is a generalized score test in the sense discussed by Boos(1992). If a data argument is supplied, the snp.data and data objects are aligned by rowname. Otherwise all variables in the model formulae are assumed to be stored in the same order as the columns of the snp.data object.

Value

An object of class snp.tests.glm or GlmTests.score depending on whether score is set to FALSE or TRUE in the call.

Note

A factor (or several factors) may be included as arguments to the function strata(...) in the base.formula. This fits all interactions of the factors so included, but leads to faster computation than fitting these in the normal way. Additionally, a cluster(...) call may be included in the base model formula. This identifies clusters of potentially correlated observations (e.g. for members of the same family); in this case, an appropriate robust estimate of the variance of the score test is used. No more than one strata() call may be used, and neither strata(...) or cluster(...) calls may appear in the add.formula. A known bug is that the function fails when no data argument is supplied and the base model formula contains no variables (~1). A work-round is to create a data frame to hold the variables in the models and pass this as data=.

Author(s)

David Clayton dc208@cam.ac.uk

References

Boos, Dennis D. (1992) On generalized score tests. The American Statistician, 46:327-333.

See Also

GlmTests-class, GlmTestsScore-class, glm.test.control,snp.rhs.tests single.snp.tests, SnpMatrix-class, XSnpMatrix-class

Examples

1
2
3
4
data(testdata)
snp.lhs.tests(Autosomes[,1:10], ~cc, ~region, data=subject.data)
snp.lhs.tests(Autosomes[,1:10], ~strata(region), ~cc,
   data=subject.data)

Example output

Loading required package: survival
Loading required package: Matrix
       Chi.squared Df   p.value
173760    5.042958  9 0.8305475
173761   12.272003  9 0.1984058
173762   12.476151  9 0.1877771
173767   14.462676  9 0.1067926
173769    8.589652  9 0.4759812
173770    0.000000  0 1.0000000
173772    7.714914  9 0.5631116
173774    6.156140  9 0.7241952
173775    8.812111  9 0.4547958
173776    7.602749  9 0.5746207
Warning message:
In snp.lhs.tests(Autosomes[, 1:10], ~cc, ~region, data = subject.data) :
  Monomorphic SNP: 6
       Chi.squared Df   p.value
173760         NaN  1       NaN
173761   1.4658701  1 0.2259984
173762   1.9149415  1 0.1664154
173767   0.7489825  1 0.3867986
173769         NaN  1       NaN
173770          NA NA        NA
173772         NaN  1       NaN
173774         NaN  1       NaN
173775         NaN  1       NaN
173776         NaN  1       NaN
Warning message:
In snp.lhs.tests(Autosomes[, 1:10], ~strata(region), ~cc, data = subject.data) :
  Monomorphic SNP: 6

snpStats documentation built on Nov. 8, 2020, 10:59 p.m.