Created
May 11, 2016 21:13
-
-
Save explodecomputer/801f450cdeeabc0d38c4a8700a496c6c to your computer and use it in GitHub Desktop.
check egger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# library(TwoSampleMR) | |
library(MRInstruments) | |
data(gwas_catalog) | |
gwas_catalog_subset <- subset(gwas_catalog, Phenotype %in% c('Body mass index')& SNP %in% c('rs10938397', 'rs1516725', 'rs2568958', 'rs633715', 'rs7138803', 'rs8089364')) | |
exposure_dat <- format_gwas_catalog(gwas_catalog_subset) | |
exposure_dat <- format_data(gwas_catalog_subset, "exposure") | |
ao <- available_outcomes() | |
outcome_dat <- extract_outcome_data(exposure_dat$SNP, c(1), proxies = 1, rsq = 0.8, align_alleles = 1, palindromes = 1, maf_threshold = 0.3) | |
dat <- harmonise_data(exposure_dat, outcome_dat, action = 2) | |
mr_results <- mr(dat) | |
mr_forest_plot(mr_singlesnp(dat)) | |
exposure_dat | |
outcome_dat | |
ed <- subset(exposure_dat, select=c(SNP, beta.exposure, se.exposure, effect_allele.exposure, other_allele.exposure)) | |
od <- subset(outcome_dat, select=c(SNP, beta.outcome, se.outcome, effect_allele.outcome, other_allele.outcome)) | |
index <- ed$effect_allele.exposure != od$effect_allele.outcome | |
od$beta.outcome[index] <- od$beta.outcome[index] * -1 | |
summary(lm(od$beta.outcome ~ ed$beta.exposure, weight=1/od$se.outcome^2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment