oracle: Performs a gwas based on linear regression.

Description Usage Arguments Value Author(s) See Also Examples

View source: R/gwas_methods.R

Description

This function performs a GWAS based on the linear regression method with known confounders. This is an oracle method when the true confounders are provided as arguments.

Usage

1
oracle(phenotype, genotype, confounder, K)

Arguments

phenotype

a vector of n phenotypic traits. If the phenotypes are generated from simu_pheno with the same confounder object, then the method is an oracle method.

genotype

an n by p matrix of SNP genotypes where n is the number of individuals (rows) and p is the number of SNPs (columns).

confounder

an object of class "confounder" created with create_factor.

K

number of factors in the adjustment method.

Value

a vector of p-values and an estimate of genomic inflation for all SNPs in the genotype matrix.

pvalues a vector of length p containing all calibrated p-values for phenotype-genotype association tests.

gif genomic inflation factor.

Author(s)

Olivier François

See Also

simu_pheno create_factor

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
library(naturalgwas)

## Load A. thaliana example
data(A.thaliana)
env <- get_climate(A.thaliana$coord)
confounder <- create_factor(A.thaliana$genotype, K = 10)
ref.set <- create_refset(A.thaliana$chrpos, window = 501)
sim <- simu_pheno( A.thaliana$genotype, confounder, env, ref.set,
ncausal = 8, effect.size = 20, gxe = 1)
pv.oracle <- naturalgwas::oracle(sim$phenotype,
                                 A.thaliana$genotype,
                                 confounder, K = 8)$pv

## compare with 'cate'
library(cate)
pv.cate = cate::cate( ~ sim.phenotype,
                      X.data = data.frame(sim$phenotype),
                      Y = A.thaliana$genotype,
                      r = 8, calibrate = TRUE)$beta.p.value

## qqplot
qqplot(-log10(pv.oracle), -log10(pv.cate) , pch = 19, cex = .4, col = "grey" )
abline(0, 1, lwd = 2, col = "orange")
par(mfrow = c(2, 1))
plot -log10(pv.oracle), cex = .4, col = "grey", main = "Manhattan plot")
points( sim$causal, -log10(pv.oracle)[sim$causal], type = "h", lty = 1, col = "blue")
plot(-log10(pv.cate), cex = .4, col = "grey", main = "Manhattan plot")
points(sim$causal, -log10(pv.cate)[sim$causal], type = "h", lty = 1, col = "red")

bcm-uga/NaturalGWAS documentation built on Dec. 18, 2019, 12:36 a.m.