Skip to content

Instantly share code, notes, and snippets.

@explodecomputer
Created April 28, 2017 10:55
Show Gist options
  • Save explodecomputer/60d36b2269771aaa28dfa11be6850ca4 to your computer and use it in GitHub Desktop.
Save explodecomputer/60d36b2269771aaa28dfa11be6850ca4 to your computer and use it in GitHub Desktop.
multivariable mr example
# Lipids (GLGC) against CHD
id_exposure <- c(299, 300, 302)
id_outcome <- 7
# Get exposures
exposure_dat <- mv_extract_exposures(id_exposure)
# Chris - if you have external data then is it possible to create the same format as this?
# - it's in long format
# - each SNP appears as many times as there are exposures
# - the effect allele for each SNP is the same in each exposure
# If so, then you can use the extract_outcome_data and mv_harmonise_data functions below for each outcome
# Get outcomes
outcome_dat <- extract_outcome_data(exposure_dat$SNP, id_outcome)
# Harmonise
mvdat <- mv_harmonise_data(exposure_dat, outcome_dat)
# Perform analysis
res <- mv_basic(mvdat)
res_nothresh <- mv_basic(mvdat, pval_threshold=1)
res$result
res_nothresh$result
# Chris - perhaps you can look at this function and make a new one with the modified model?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment