snp.rhs.estimates: Fit GLMs with SNP genotypes as independent variable(s)

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

View source: R/glm-test.R

Description

This function fits a generalized linear model with phenotype as dependent variable and with a series of SNPs (or small sets of SNPs) as predictor variables. Optionally, one or more potential confounders of a phenotype-genotype association may be included in the model. In order to protect against misspecification of the variance function, "robust" estimates of the variance-covariance matrix of estimates may be calculated in place of the usual model-based estimates.

Usage

1
2
3
4
snp.rhs.estimates(formula, family = "binomial", link, weights, subset,
data = parent.frame(), snp.data,
   rules = NULL, sets = NULL, robust = FALSE, uncertain = FALSE, control
= glm.test.control())

Arguments

formula

The model formula, with phenotype as dependent variable and any potential confounders as independent variables. Note that parameter estimates are not returned for these model terms

family

A string defining the generalized linear model family. This currently should (partially) match one of "binomial", "Poisson", "Gaussian" or "gamma" (case-insensitive)

link

A string defining the link function for the GLM. This currently should (partially) match one of "logit", "log", "identity" or "inverse". The default action is to use the "canonical" link for the family selected

data

The dataframe in which the model formula is to be interpreted

snp.data

An object of class "SnpMatrix" or "XSnpMatrix" containing the SNP data

rules

Optionally, an object of class "ImputationRules"

sets

Either a vector of SNP names (or numbers) for the SNPs to be added to the model formula, or a logical vector of length equal to the number of columns in snp.data or a list of short vectors defining sets of SNPs to be included (see Details)

weights

"Prior" weights in the generalized linear model

subset

Array defining the subset of rows of data to use

robust

If TRUE, robust tests will be carried out

uncertain

If TRUE, uncertain genotypes are used and scored by their posterior expectations. Otherwise they are treated as missing

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

Details

Homozygous SNP genotypes are coded 0 or 2 and heterozygous genotypes are coded 1. For SNPs on the X chromosome, males are coded as homozygous females. For X SNPs, it will often be appropriate to include sex of subject in the base model (this is not done automatically). The "robust" option causes Huber-White estimates of the variance-covariance matrix of the parameter estimates to be returned. These protect against mis-specification of the variance function in the GLM, for example if binary or count data are overdispersed,

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.

Usually SNPs to be fitted in models will be referenced by name. However, they can also be referenced by number, indicating the appropriate column in the input snp.data. They can also be referenced by a logical selection vector of length equal to the number of columns in snp.data.

If the rules argument is supplied, SNPs may be imputed using these rules and included in the model.

Value

An object of class GlmEstimates

Note

A factor (or several factors) may be included as arguments to the function strata(...) in the 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 parameter estimates is used.

If uncertain genotypes (e.g. as a result of imputation) are used, the interpretation of the regression coefficients is questionable; the regression coefficient for an imperfectly measurement of a variable is not a biased (attenuated) estimate of the coefficient of the variable measured.

Author(s)

David Clayton dc208@cam.ac.uk

See Also

GlmEstimates-class, snp.lhs.estimates, snp.rhs.tests, SnpMatrix-class, XSnpMatrix-class

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
data(testdata)
test <- snp.rhs.estimates(cc~strata(region), family="binomial",
   data=subject.data, snp.data= Autosomes, sets=1:10)
print(test)
test2 <- snp.rhs.estimates(cc~region+sex, family="binomial",
   data=subject.data, snp.data= Autosomes, sets=1:10)
print(test2)
test.robust <- snp.rhs.estimates(cc~strata(region), family="binomial",
   data=subject.data, snp.data= Autosomes, sets=1:10, robust=TRUE)
print(test.robust)

Example output

Loading required package: survival
Loading required package: Matrix
Warning message:
In snp.rhs.estimates(cc ~ strata(region), family = "binomial", data = subject.data,  :
  No estimable parameters for set 6

 Model  Y-variable  Parameter    Estimate        S.E.     z-value
-----------------------------------------------------------------
173760          cc     173760     -12.234      270.82      -0.045
-----------------------------------------------------------------
173761          cc     173761     0.17831     0.14764       1.208
-----------------------------------------------------------------
173762          cc     173762     0.20594     0.14881       1.384
-----------------------------------------------------------------
173767          cc     173767     -0.1336     0.15176      -0.880
-----------------------------------------------------------------
173769          cc     173769     0.91677     0.55152       1.662
-----------------------------------------------------------------
    173770 - No estimates available
-----------------------------------------------------------------
173772          cc     173772     -12.334      271.21      -0.045
-----------------------------------------------------------------
173774          cc     173774     0.16249     0.19922       0.816
-----------------------------------------------------------------
173775          cc     173775    -0.18392      0.1873      -0.982
-----------------------------------------------------------------
173776          cc     173776    0.078991     0.25196       0.314
-----------------------------------------------------------------
Warning messages:
1: In snp.rhs.estimates(cc ~ region + sex, family = "binomial", data = subject.data,  :
  Variable(s) in base model were aliased and were dropped
2: In snp.rhs.estimates(cc ~ region + sex, family = "binomial", data = subject.data,  :
  No estimable parameters for set 6

 Model  Y-variable  Parameter    Estimate        S.E.     z-value
-----------------------------------------------------------------
173760          cc     173760      -12.18      270.82      -0.045
-----------------------------------------------------------------
173761          cc     173761     0.18851     0.14835       1.271
-----------------------------------------------------------------
173762          cc     173762     0.21405      0.1494       1.433
-----------------------------------------------------------------
173767          cc     173767    -0.13387     0.15183      -0.882
-----------------------------------------------------------------
173769          cc     173769     0.91673     0.55157       1.662
-----------------------------------------------------------------
    173770 - No estimates available
-----------------------------------------------------------------
173772          cc     173772     -12.253      270.82      -0.045
-----------------------------------------------------------------
173774          cc     173774     0.17059      0.1997       0.854
-----------------------------------------------------------------
173775          cc     173775    -0.18293     0.18742      -0.976
-----------------------------------------------------------------
173776          cc     173776    0.075692     0.25207       0.300
-----------------------------------------------------------------
Warning message:
In snp.rhs.estimates(cc ~ strata(region), family = "binomial", data = subject.data,  :
  No estimable parameters for set 6

 Model  Y-variable  Parameter    Estimate        S.E.     z-value
-----------------------------------------------------------------
173760          cc     173760     -12.234     0.44372     -27.570
-----------------------------------------------------------------
173761          cc     173761     0.17831     0.14549       1.226
-----------------------------------------------------------------
173762          cc     173762     0.20594     0.14661       1.405
-----------------------------------------------------------------
173767          cc     173767     -0.1336     0.15105      -0.884
-----------------------------------------------------------------
173769          cc     173769     0.91677     0.55552       1.650
-----------------------------------------------------------------
    173770 - No estimates available
-----------------------------------------------------------------
173772          cc     173772     -12.334     0.46989     -26.248
-----------------------------------------------------------------
173774          cc     173774     0.16249     0.19974       0.813
-----------------------------------------------------------------
173775          cc     173775    -0.18392     0.18456      -0.997
-----------------------------------------------------------------
173776          cc     173776    0.078991     0.25262       0.313
-----------------------------------------------------------------

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