#### Diabetes Example: analysis while controlling FDR
## read in the vector of p-values created in dm2_pvals.R
load("dm2_pvals.rda")
## the table in our lecture
names(pvals)[which.min(pvals)]
## how many tables with < 5 cell expectations?
sum(is.na(pvals))
## how many are left?
sum(!is.na(pvals))
## histogram of the tests
hist(pvals, main='', xlab='p-values',breaks=30,col="lightblue")
title("P-values: GWAS Diabetes")
## read in the handy fdr_cut function I provided
source("fdr.R")
## get the FDR cutoff
cutoff <- fdr_cut(pvals, 0.001)
## significants: !' means 'not', so this is 'not NA' and pval <= cutoff
signif <- (pvals <= cutoff) & (!is.na(pvals))
sum(signif)
# top 10 locations to investigate
names(pvals)[order(pvals)[1:10]]