###load example data for two cohorts
data(skatExample)
####run on each cohort:
cohort1 <- skatCohort(Z=Z1, y~1, SNPInfo = SNPInfo, data =pheno1)
cohort2 <- skatCohort(Z=Z2, y~1, SNPInfo = SNPInfo, data =pheno2)
#### combine results:
out <- burdenMeta(cohort1, cohort2, SNPInfo = SNPInfo, mafRange=c(0,.01))
head(out)
##### Compare with analysis on full data set:
bigZ <- matrix(NA,2*n,nrow(SNPInfo))
colnames(bigZ) <- SNPInfo$Name
for(gene in unique(SNPInfo$gene)){
snp.names <- SNPInfo$Name[SNPInfo$gene == gene]
bigZ[1:n,SNPInfo$gene == gene][,
snp.names %in% colnames(Z1)] <- Z1[,
na.omit(match(snp.names,colnames(Z1)))]
bigZ[(n+1):(2*n),SNPInfo$gene == gene][,
snp.names %in% colnames(Z2)] <- Z2[,
na.omit(match(snp.names,colnames(Z2)))]
}
pheno <- rbind(pheno1[,c("y","sex","bmi")],pheno2[,c("y","sex","bmi")])
burden.p <- c(by(SNPInfo$Name, SNPInfo$gene,function(snp.names){
inds <- match(snp.names,colnames(bigZ))
burden <- rowSums(bigZ[,na.omit(inds)],na.rm=TRUE)
mod <- lm(y~burden + gl(2,nrow(pheno1)),data=pheno)
summary(mod)$coef[2,4]
}))
head(cbind(out$p,burden.p))
#will be slightly different:
plot(y=out$p,x=burden.p, ylab = "burden meta p-values", xlab = "complete data p-values")
Run the code above in your browser using DataLab