## simulate covariate matrix (X) and continuous response vector (Y)
## for two populations/triats Y1 and Y2 depend equally on f1 and f2
## within each population, although their distributions differ between
## populations. They are compatible with a null hypothesis that they
## share a common causal variant
set.seed(1)
X1 <- matrix(rbinom(1000,1,0.4),ncol=2)
Y1 <- rnorm(500,apply(X1,1,sum),2)
X2 <- matrix(rbinom(1000,1,0.6),ncol=2)
Y2 <- rnorm(500,2*apply(X2,1,sum),5)
boxplot(list(Y1,Y2),names=c("Y1","Y2"))
## fit and store linear model objects
colnames(X1) <- colnames(X2) <- c("f1","f2")
summary(lm1 <- lm(Y1~f1+f2,data=as.data.frame(X1)))
summary(lm2 <- lm(Y2~f1+f2,data=as.data.frame(X2)))
## test whether the traits are compatible with colocalisation
### ppp should be large (>0.05, for example), indicating that they are.
par(mfrow=c(2,2))
coloc.test(lm1,lm2,plot.coeff=TRUE,
plots.extra=list(x=c("eta","theta"),
y=c("lhood","lhood")))
Run the code above in your browser using DataLab