Meta analysis within Dataset
Closed this issue · 2 comments
explodecomputer commented
Meta analysis within Dataset
explodecomputer commented
Suppose you make a Dataset of two SummarySets of coronary heart disease - each one is from a different study. e.g.
- ieu-a-7
- ukb-d-I9_IHD
Once everything is harmonised, a useful function would be to meta analyse all the studies inside the Dataset to create a new SummarySet
e.g.
chd_dat <- createDataset(c("ieu-a-7", "ukb-d-I9_IHD"))
chd_meta <- meta_analyse(chd_dat, method="fixed")
meta_analyse
- for every variant in the Dataset create a new effect estimate that meta-analyses across all the variants available.
chd_meta will be a SummarySet that would then feed into the tutorial (e.g. replace 'ieu-a-7' in the tutorial with this new meta-analysed version)
e.g. use meta http://cran.nexr.com/web/packages/meta/index.html in the Suggests field
explodecomputer commented
This is quite efficient code for doing FE meta analysis across many SNPs
#' Fixed effects meta analysis vectorised across multiple SNPs
#'
#' @param beta_mat Matrix of betas - rows are SNPs, columns are studies
#' @param se_mat Matrix of SEs - rows are SNPs, columns are studies
#'
#' @return list of meta analysis betas and SEs
fixed_effects_meta_analysis <- function(beta_mat, se_mat) {
w <- 1/se_mat^2
beta <- rowSums(beta_mat * w) / rowSums(w)
se <- sqrt(1/rowSums(w))
return(list(beta=beta, se=se))
}