brary(boot) library(MASS) library(base) library(stats) ################################################################## ## TOW is an association test to test association ## ## between a phenotype and a optimal weighted ## ## combination of variants (can be rare and common) ## ## in a genomic region. ## ## y represents trait values(a vector). x represents ## ## genotype (number of minor allele) matrix. Each row ## ## represents an individual and each column represents ## ## a SNP. xc represents the covariate matrix. Each row ## ## represents an individual and each column represents ## ## a covriate. ## ################################################################## TOW=function(y,x,xc,numper) { q=colMeans(x)/2 a=which(q>0) x=x[,a] y=lm(y~xc)$resid x=lm(x~xc)$resid T1per=rep(0,numper) m=ncol(x) aa=apply(x,2,var) T1=sum(cov(y,x)^2/aa) for(i in 1:numper) { yper=sample(y) T1per[i]=sum(cov(yper,x)^2/aa) } pvalue=sum(T10) x=x[,a] m=ncol(x) n=nrow(x) q=colMeans(x)/2 a0=which(qT[1])/numper+sum(T[2:(numper+1)]==T[1])/numper/2 }