R: 1-df and 2-df tests for genetic associations with SNPs (or...
single.snp.tests
R Documentation
1-df and 2-df tests for genetic associations with SNPs (or
imputed SNPs)
Description
This function carries out tests for association between phenotype and
a series of single nucleotide polymorphisms (SNPs), within strata
defined by a possibly confounding factor. SNPs are
considered one at a time and both 1-df and 2-df tests are
calculated. For a binary phenotype, the
1-df test is the Cochran-Armitage test (or, when
stratified, the Mantel-extension test). The function will also calculate
the same tests for SNPs imputed by regression analysis.
Optionally, a factor defining strata for the analysis
data
A dataframe containing the phenotype and
stratum data. The row names of this are linked with the row
names of the snps argument to establish correspondence of
phenotype and genotype data. If this argument is not supplied,
phenotype and stratum are evaluated in the calling
environment and should be in the same order as rows of snps
snp.data
An object of class "SnpMatrix" containing the SNP
genotypes to be tested
rules
An object of class
"ImputationRules". If
supplied, the rules coded in this object are used, together with
snp.data, to calculate tests for imputed SNPs
subset
A vector or expression describing the subset of subjects
to be used in the analysis. This is evaluated in the same
environment as the phenotype and stratum arguments
snp.subset
A vector describing the subset of SNPs to be
considered. Default action is to test all SNPs in snp.data
or, in imputation mode, as specified by rules
uncertain
If TRUE, uncertain genotypes are handled by replacing
score contributions by their posterior expectations. Otherwise they
are treated as missing. Setting this option authomatically invokes
use of robust variance estimates
score
If TRUE, the output object will contain, for each
SNP, the score vector and its variance-covariance matrix
Details
Formally, the test statistics are score tests for generalized linear
models with canonical link. That is, they are inner products between
genotype indicators and the deviations of phenotypes from their
stratum means. Variances (and covariances) are those of the
permutation distribution obtained by randomly permuting phenotype
within stratum.
When the function is used to calculate tests for imputed SNPs, the
test is still a score test. The score statistics are calculated from
the expected value, given observed SNPs, of the score statistic if the
SNP to be tested were itself observed.
The subset argument can either be a logical vector of length
equal to the length of the vector of phenotypes, an integer vector
specifying positions in the data frame, or a character vector
containing names of the selected rows in the data
frame. Similarly, the snp.subset argument can be a logical,
integer, or character vector.
Value
An object of class
"SingleSnpTests".
If score is set to TRUE,
the output object will be of the extended class
"SingleSnpTestsScore"
containing additional slots holding the score statistics and their
variances (and covariances). This allows meta-analysis using the
pool function.
Note
The 1 df imputation tests are described by Chapman et al. (2008)
and the 2 df imputation tests are a simple extension of these.
The behaviour of this function for objects of class
XSnpMatrix is as described by Clayton (2008). Males are
treated as homozygous females and corrected variance estimates are
used.
Chapman J.M., Cooper J.D., Todd J.A. and Clayton D.G. (2003)
Human Heredity, 56:18-31.
Clayton (2008) Testing for association on the X chromosome
Biostatistics, 9:593-600.)
See Also
snp.lhs.tests, snp.rhs.tests,
impute.snps, ImputationRules-class,
pool,
SingleSnpTests-class,
SingleSnpTestsScore-class
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(snpStats)
Loading required package: survival
Loading required package: Matrix
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/snpStats/single.snp.tests.Rd_%03d_medium.png", width=480, height=480)
> ### Name: single.snp.tests
> ### Title: 1-df and 2-df tests for genetic associations with SNPs (or
> ### imputed SNPs)
> ### Aliases: single.snp.tests
> ### Keywords: htest
>
> ### ** Examples
>
> data(testdata)
> results <- single.snp.tests(cc, stratum=region, data=subject.data,
+ snp.data=Autosomes, snp.subset=1:10)
> print(summary(results))
N Chi.squared.1.df Chi.squared.2.df P.1df
Min. :378.0 Min. :0.0963 Min. :0.8189 Min. :0.08984
1st Qu.:396.2 1st Qu.:0.7577 1st Qu.:1.0972 1st Qu.:0.23253
Median :398.5 Median :1.0000 Median :1.5847 Median :0.31731
Mean :395.6 Mean :1.1903 Mean :2.1849 Mean :0.33322
3rd Qu.:400.0 3rd Qu.:1.4253 3rd Qu.:3.2740 3rd Qu.:0.38406
Max. :400.0 Max. :2.8773 Max. :4.3497 Max. :0.75631
NA's :1 NA's :4 NA's :1
P.2df
Min. :0.1136
1st Qu.:0.2190
Median :0.4536
Mean :0.4082
3rd Qu.:0.5809
Max. :0.6640
NA's :4
>
> # writing to an (anonymous and temporary) csv file
> csvfile <- tempfile()
> write.csv(file=csvfile, as(results, 'data.frame'))
> unlink(csvfile)
> # QQ plot
> qq.chisq(chi.squared(results, 1), 1)
N omitted lambda
9.000000 0.000000 4.867221
> qq.chisq(chi.squared(results, 2), 2)
N omitted lambda
6.000000 0.000000 1.417002
>
>
>
>
>
> dev.off()
null device
1
>