###################################################################### ## CLC is an association test to test genetic associations ## ## between multiple phenotypes and a genetic variant. ## ## ## ## In the function CLC, ## ## x: represents the genotype (number of minor alleles) vector. ## ## y: represents the trait value matrix. Each row represents ## ## an individual and each column represents a phenotype. ## ## numper: represents the number of permutations to ## ## obtain the p-value of the test statistic CLC. ## ###################################################################### CLC=function(x,y,numper) { K=ncol(y) Tstat=score(x,y) Sigma=cor(y) dist=1-Sigma hc=hclust(as.dist(dist)) pv0=rep(9999,K) U=list() for (L in c(1:K)) { index=cutree(hc,L) B=sapply(1:L, function(t) as.numeric(index==t)) W=ginv(t(B)%*%ginv(Sigma)%*%B)%*%t(B)%*%ginv(Sigma) U[[L]]=t(W)%*%ginv(W%*%Sigma%*%t(W))%*%W CLC=t(Tstat)%*%U[[L]]%*%Tstat pv0[L]=1-pchisq(CLC,L) } CLC0=min(pv0) CLC1=rep(999999,numper) for (i in c(1:numper)) { xper=sample(x) Tstat=score(xper,y) CLC1[i]=min(sapply(1:K,function(z) 1-pchisq(t(Tstat)%*%U[[z]]%*%Tstat,z))) } pvalue=mean(CLC1