Created
October 29, 2013 12:32
-
-
Save chr1swallace/7213787 to your computer and use it in GitHub Desktop.
conditional testing of SNPs - reports number and which SNPs are "significant" in sequential conditional testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(snpStats) | |
best <- cond.best(X,Y, family=family) | |
while(length(newbest <- cond.best(X, Y, best, family=family))) | |
best <- c(best,newbest) | |
cond.best <- function(X,Y,best=NULL,p.thr=1e-6, ...) { | |
if(is.null(best)) { | |
cond <- snp.rhs.tests(Y ~ 1, snp.data=X, data=data.frame(Y=Y, | |
row.names=rownames(X)), ...) | |
p.thr <- 1 | |
} else { | |
cond <- snp.rhs.tests(as.formula(paste("Y ~", paste(best, collapse="+"))), | |
snp.data=X, | |
data=cbind(data.frame(Y=Y,row.names=rownames(X)),as(X[,best],"numeric")), | |
control=glm.test.control(R2Max=1), | |
...) | |
} | |
p <- p.value(cond) | |
pmin <- min(p, na.rm=TRUE) | |
if(pmin<p.thr) { | |
newbest <- colnames(X)[ which.min(p) ] | |
message(newbest," ",format.pval(pmin)) | |
return(newbest) | |
} | |
return(NULL) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment