-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
24ee023
commit 693b500
Showing
3 changed files
with
186 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
# MR sign concordance - how often are the SNP-exposure and SNP-outcome effects in the same direction? | ||
|
||
# Use binomial test assuming that on average should be 50% under the null hypothesis | ||
|
||
# What is the minumum number of SNPs required to achieve p-value of 0.05? | ||
|
||
param <- expand.grid(n = 1:100, x=0:100) | ||
param <- subset(param, x <= n) | ||
for(i in 1:nrow(param)) | ||
{ | ||
param$pval[i] <- binom.test(x=param$x[i], n=param$n[i], p=0.5)$p.value | ||
} | ||
min(param$pval) | ||
|
||
library(ggplot2) | ||
ggplot(param, aes(x=x, y=n)) + | ||
geom_point(aes(colour=pval < 0.05)) | ||
|
||
library(dplyr) | ||
group_by(param, n) %>% summarise(minp = min(pval)) | ||
|
||
# Looks like 6 is the smallest number of SNPs that can achieve p < 0.05 | ||
|
||
a <- extract_instruments(2) | ||
b <- extract_outcome_data(a$SNP,7) | ||
dat <- harmonise_data(a, b) | ||
mr(dat, method_list=c("mr_ivw", "mr_sign")) | ||
|
||
|
||
# Could consider doing a parametric bootstrap type analysis | ||
|