-Converting the betas to OR’s tend to help the estimates become more interpretable to readers
-Providing the I2 heterogeneity estimate as well as Q is also easier to interpret because it corresponds to the proportion of het
-Steiger filtering helps to assess whether the IV is being biased by reverse causation - in a different manner to bidirectional assessment because it compares the R2 of the same IV in both the exposure and outcome
-MR-PRESSO would be good to see if there are any outlying SNPs that should be removed that are causing het in some of your estimates that might make some of them less biased
## MR PRESSO
# seems easy enough but need to figure out what it means and how to get both betas together in one file
#data(SummaryStats)
#mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = sleep_dur_dep_dat, NbDistribution = 10000, SignifThreshold = 0.05)
### the causal corrected estimate is very similar but now significant.
### the IVW estimate for sleep duration - depression b= -0.002194542, p=0.184051387
### MR PRESSO estimates b=-0.002102447, p=0.126841627
### but the corrected IVW estimate b= -0.003474544, p=0.003352516
QUESTIONS FOR ISY:
-example: sleep duration - depression had a significant heterogeneity test (for both IVW and MR Egger), but no significant MR egger intercept. The IVW estimate however was not significant. But, after outlier correction, the IVW effect did become significant.
dep<- "ieu-b-102"
scz<- "ieu-b-42"
#bip<- "ieu-b-41"
adhd<- "ieu-a-1183"
sleepdur<- "ebi-a-GCST003839"
napping<- "ebi-a-GCST011494"
chrono<- "ukb-b-4956"
longsleep<- "ebi-a-GCST006685"
shortsleep<- "ebi-a-GCST006686"
methods<- c('mr_two_sample_ml', 'mr_egger_regression', 'mr_weighted_mode', 'mr_weighted_median', 'mr_ivw')
ivw_p<- .05/8
set seed
set.seed(222)
sleep_psych_MR<- data.frame()
dur<- grep("Dashti", gwas_catalog$Author)
unique(gwas_catalog[dur,]$Phenotype) ###
## [1] "Sleep duration" "Sleep duration (long sleep)"
## [3] "Sleep duration (short sleep)" "Circulating phylloquinone levels"
sleep_dur_gwas <-
subset(gwas_catalog,
grepl("Dashti", Author) & Phenotype == "Sleep duration")
sleep_dur_exp_dat <- format_data(sleep_dur_gwas)
sleep_dur_exp_dat$samplesize.exposure<- 446118
nrow(sleep_dur_exp_dat)
## [1] 72
sleep_dur_exp_dat <- sleep_dur_exp_dat %>% as.data.table
sleep_dur_exp_dat <- sleep_dur_exp_dat[, F_STAT := qf(
pval.exposure,
df1=1,
df2=samplesize.exposure,
lower.tail=F
)] # this piece calculates the F statistic of each SNP in the IV and adds a column called F_STAT
sleep_dur_exp_dat$F_STAT %>% mean # to calculate the overall F stat of your exposure
## [1] 37.27047
sleep_dur_exp_dat$F_STAT %>% min # you can use this to check whether any individual SNPs fall under F of 10 which would make them invalid instruments
## [1] 20.4882
dep_out_dat <- extract_outcome_data(snps = sleep_dur_exp_dat$SNP, outcomes = dep)
## API: public: http://gwas-api.mrcieu.ac.uk/
## Extracting data for 72 SNP(s) from 1 GWAS(s)
## Finding proxies for 9 SNPs in outcome ieu-b-102
## Extracting data for 9 SNP(s) from 1 GWAS(s)
sleep_dur_dep_dat <- harmonise_data(sleep_dur_exp_dat, dep_out_dat)
## Harmonising Sleep duration (unit increase) (lVP89E) and Major depression || id:ieu-b-102 (ieu-b-102)
## Removing the following SNPs for incompatible alleles:
## rs17732997
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10421649, rs10761674, rs11643715, rs12246842, rs12470989, rs12791153, rs1553132, rs17427571, rs17732997, rs2231265, rs269054, rs3095508, rs374153, rs4538155, rs55658675, rs7915425, rs8050478, rs915416
## Harmonising Sleep duration (unit decrease) (YZehmn) and Major depression || id:ieu-b-102 (ieu-b-102)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs330088
res <- mr(sleep_dur_dep_dat, method_list = methods)
## Analysing 'lVP89E' on 'ieu-b-102'
## No SNPs available for MR analysis of 'YZehmn' on 'ieu-b-102'
res
## id.exposure id.outcome outcome
## 1 lVP89E ieu-b-102 Major depression || id:ieu-b-102
## 2 lVP89E ieu-b-102 Major depression || id:ieu-b-102
## 3 lVP89E ieu-b-102 Major depression || id:ieu-b-102
## 4 lVP89E ieu-b-102 Major depression || id:ieu-b-102
## 5 lVP89E ieu-b-102 Major depression || id:ieu-b-102
## exposure method nsnp b
## 1 Sleep duration (unit increase) Maximum likelihood 49 -0.002269758
## 2 Sleep duration (unit increase) MR Egger 49 -0.004312081
## 3 Sleep duration (unit increase) Weighted mode 49 -0.003490188
## 4 Sleep duration (unit increase) Weighted median 49 -0.002917034
## 5 Sleep duration (unit increase) Inverse variance weighted 49 -0.002191741
## se pval
## 1 0.0008331037 0.006440674
## 2 0.0056796773 0.451516669
## 3 0.0017729333 0.054788869
## 4 0.0014197944 0.039922779
## 5 0.0016523292 0.184688980
mr_heterogeneity(sleep_dur_dep_dat)
## Not enough SNPs available for Heterogeneity analysis of 'YZehmn' on 'ieu-b-102'
## id.exposure id.outcome outcome
## 1 lVP89E ieu-b-102 Major depression || id:ieu-b-102
## 2 lVP89E ieu-b-102 Major depression || id:ieu-b-102
## exposure method Q Q_df
## 1 Sleep duration (unit increase) MR Egger 208.6211 47
## 2 Sleep duration (unit increase) Inverse variance weighted 209.2980 48
## Q_pval
## 1 3.060064e-22
## 2 5.003368e-22
mr_pleiotropy_test(sleep_dur_dep_dat)
## Not enough SNPs available for pleiotropy analysis of 'YZehmn' on 'ieu-b-102'
## id.exposure id.outcome outcome
## 1 lVP89E ieu-b-102 Major depression || id:ieu-b-102
## exposure egger_intercept se pval
## 1 Sleep duration (unit increase) 0.001965612 0.005033291 0.697915
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = sleep_dur_dep_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, sleep_dur_dep_dat)
p1
## $`lVP89E.ieu-b-102`
##
## $`YZehmn.ieu-b-102`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 lVP89E ieu-b-102
## 2 YZehmn ieu-b-102
res_single <- mr_singlesnp(sleep_dur_dep_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure
## 1 Sleep duration (unit increase) Major depression || id:ieu-b-102 lVP89E
## 2 Sleep duration (unit increase) Major depression || id:ieu-b-102 lVP89E
## 3 Sleep duration (unit increase) Major depression || id:ieu-b-102 lVP89E
## 4 Sleep duration (unit increase) Major depression || id:ieu-b-102 lVP89E
## 5 Sleep duration (unit increase) Major depression || id:ieu-b-102 lVP89E
## 6 Sleep duration (unit increase) Major depression || id:ieu-b-102 lVP89E
## 7 Sleep duration (unit increase) Major depression || id:ieu-b-102 lVP89E
## 8 Sleep duration (unit increase) Major depression || id:ieu-b-102 lVP89E
## id.outcome samplesize SNP b se p
## 1 ieu-b-102 NA rs1057703 -0.02103659 0.006199187 6.902002e-04
## 2 ieu-b-102 NA rs10973207 0.03114286 0.005714286 5.036982e-08
## 3 ieu-b-102 NA rs113113059 -0.01871981 0.006280193 2.875254e-03
## 4 ieu-b-102 NA rs174560 0.01906566 0.005808081 1.028513e-03
## 5 ieu-b-102 NA rs205024 -0.01771654 0.005774278 2.153655e-03
## 6 ieu-b-102 NA rs34731055 -0.02672414 0.005363985 6.288398e-07
## 7 ieu-b-102 NA rs73219758 0.01986755 0.005187638 1.282541e-04
## 8 ieu-b-102 NA rs9345234 0.01862745 0.006162465 2.505079e-03
scz_out_dat <- extract_outcome_data(snps = sleep_dur_exp_dat$SNP, outcomes = scz)
## Extracting data for 72 SNP(s) from 1 GWAS(s)
## Finding proxies for 8 SNPs in outcome ieu-b-42
## Extracting data for 8 SNP(s) from 1 GWAS(s)
sleep_dur_scz_dat <- harmonise_data(sleep_dur_exp_dat, scz_out_dat)
## Harmonising Sleep duration (unit increase) (lVP89E) and schizophrenia || id:ieu-b-42 (ieu-b-42)
## Removing the following SNPs for incompatible alleles:
## rs17732997
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10421649, rs10761674, rs11643715, rs12246842, rs12470989, rs12791153, rs1553132, rs17427571, rs17732997, rs2231265, rs269054, rs3095508, rs374153, rs4538155, rs55658675, rs7915425, rs8050478, rs915416
## Harmonising Sleep duration (unit decrease) (YZehmn) and schizophrenia || id:ieu-b-42 (ieu-b-42)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs330088
nrow(sleep_dur_scz_dat)
## [1] 70
res <- mr(sleep_dur_scz_dat, method_list = methods)
## Analysing 'lVP89E' on 'ieu-b-42'
## No SNPs available for MR analysis of 'YZehmn' on 'ieu-b-42'
res
## id.exposure id.outcome outcome
## 1 lVP89E ieu-b-42 schizophrenia || id:ieu-b-42
## 2 lVP89E ieu-b-42 schizophrenia || id:ieu-b-42
## 3 lVP89E ieu-b-42 schizophrenia || id:ieu-b-42
## 4 lVP89E ieu-b-42 schizophrenia || id:ieu-b-42
## 5 lVP89E ieu-b-42 schizophrenia || id:ieu-b-42
## exposure method nsnp b
## 1 Sleep duration (unit increase) Maximum likelihood 51 0.005728847
## 2 Sleep duration (unit increase) MR Egger 51 -0.001644921
## 3 Sleep duration (unit increase) Weighted mode 51 0.008679163
## 4 Sleep duration (unit increase) Weighted median 51 0.007917005
## 5 Sleep duration (unit increase) Inverse variance weighted 51 0.005176986
## se pval
## 1 0.002122943 0.00696443
## 2 0.017361429 0.92490321
## 3 0.004959807 0.08627079
## 4 0.003905762 0.04266174
## 5 0.004980447 0.29858985
mr_heterogeneity(sleep_dur_scz_dat)
## Not enough SNPs available for Heterogeneity analysis of 'YZehmn' on 'ieu-b-42'
## id.exposure id.outcome outcome
## 1 lVP89E ieu-b-42 schizophrenia || id:ieu-b-42
## 2 lVP89E ieu-b-42 schizophrenia || id:ieu-b-42
## exposure method Q Q_df
## 1 Sleep duration (unit increase) MR Egger 321.0824 49
## 2 Sleep duration (unit increase) Inverse variance weighted 322.1865 50
## Q_pval
## 1 1.193973e-41
## 2 1.926457e-41
mr_pleiotropy_test(sleep_dur_scz_dat)
## Not enough SNPs available for pleiotropy analysis of 'YZehmn' on 'ieu-b-42'
## id.exposure id.outcome outcome
## 1 lVP89E ieu-b-42 schizophrenia || id:ieu-b-42
## exposure egger_intercept se pval
## 1 Sleep duration (unit increase) 0.006352521 0.01547562 0.6832392
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = sleep_dur_scz_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, sleep_dur_scz_dat)
p1
## $`lVP89E.ieu-b-42`
##
## $`YZehmn.ieu-b-42`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 lVP89E ieu-b-42
## 2 YZehmn ieu-b-42
res_single <- mr_singlesnp(sleep_dur_scz_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure
## 1 Sleep duration (unit increase) schizophrenia || id:ieu-b-42 lVP89E
## 2 Sleep duration (unit increase) schizophrenia || id:ieu-b-42 lVP89E
## 3 Sleep duration (unit increase) schizophrenia || id:ieu-b-42 lVP89E
## 4 Sleep duration (unit increase) schizophrenia || id:ieu-b-42 lVP89E
## 5 Sleep duration (unit increase) schizophrenia || id:ieu-b-42 lVP89E
## 6 Sleep duration (unit increase) schizophrenia || id:ieu-b-42 lVP89E
## 7 Sleep duration (unit increase) schizophrenia || id:ieu-b-42 lVP89E
## 8 Sleep duration (unit increase) schizophrenia || id:ieu-b-42 lVP89E
## 9 Sleep duration (unit increase) schizophrenia || id:ieu-b-42 lVP89E
## 10 Sleep duration (unit increase) schizophrenia || id:ieu-b-42 lVP89E
## 11 Sleep duration (unit increase) schizophrenia || id:ieu-b-42 lVP89E
## 12 Sleep duration (unit increase) schizophrenia || id:ieu-b-42 lVP89E
## 13 Sleep duration (unit increase) schizophrenia || id:ieu-b-42 lVP89E
## 14 Sleep duration (unit increase) schizophrenia || id:ieu-b-42 lVP89E
## 15 Sleep duration (unit increase) schizophrenia || id:ieu-b-42 lVP89E
## id.outcome samplesize SNP b se p
## 1 ieu-b-42 77096 rs10173260 0.05322816 0.01796117 3.041487e-03
## 2 ieu-b-42 77096 rs1057703 0.04827236 0.01554878 1.905525e-03
## 3 ieu-b-42 77096 rs113113059 0.06727053 0.01630435 3.692461e-05
## 4 ieu-b-42 77096 rs11567976 -0.04682273 0.01651515 4.580595e-03
## 5 ieu-b-42 77096 rs11614986 0.06093524 0.01507431 5.292405e-05
## 6 ieu-b-42 77096 rs12611523 -0.06566382 0.01552707 2.347419e-05
## 7 ieu-b-42 77096 rs13109404 -0.07738928 0.01357809 1.201094e-08
## 8 ieu-b-42 77096 rs205024 -0.05853018 0.01456693 5.868971e-05
## 9 ieu-b-42 77096 rs34556183 -0.10090909 0.01323232 2.422358e-14
## 10 ieu-b-42 77096 rs34731055 0.03859866 0.01264368 2.267147e-03
## 11 ieu-b-42 77096 rs4128364 0.06731410 0.01461538 4.110772e-06
## 12 ieu-b-42 77096 rs4767550 0.05572141 0.01350365 3.684919e-05
## 13 ieu-b-42 77096 rs61796569 -0.04239010 0.01485507 4.323002e-03
## 14 ieu-b-42 77096 rs7644809 0.05593590 0.01778846 1.663684e-03
## 15 ieu-b-42 77096 rs7806045 -0.03937584 0.01420582 5.574539e-03
anx_out_dat <- read_outcome_data(
snps = sleep_dur_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/anxiety_withNeff.txt.gz",
sep = "\t",
snp_col = "SNP",
beta_col = "effect",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
eaf_col = "MAF",
pval_col = "P",
samplesize_col = "Neff"
)
## No phenotype name specified, defaulting to 'outcome'.
anx_out_dat$outcome<- rep('Anxiety', 1, nrow(anx_out_dat))
sleep_dur_anx_dat <- harmonise_data(sleep_dur_exp_dat, anx_out_dat)
## Harmonising Sleep duration (unit increase) (lVP89E) and Anxiety (eRr3n7)
## Removing the following SNPs for incompatible alleles:
## rs17732997
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10421649, rs10761674, rs11643715, rs12246842, rs12470989, rs12791153, rs1553132, rs17427571, rs17732997, rs2231265, rs269054, rs3095508, rs374153, rs4538155, rs55658675, rs7915425, rs8050478, rs915416
## Harmonising Sleep duration (unit decrease) (YZehmn) and Anxiety (eRr3n7)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs330088
res <- mr(sleep_dur_anx_dat, method_list = methods)
## Analysing 'lVP89E' on 'eRr3n7'
## No SNPs available for MR analysis of 'YZehmn' on 'eRr3n7'
res
## id.exposure id.outcome outcome exposure
## 1 lVP89E eRr3n7 Anxiety Sleep duration (unit increase)
## 2 lVP89E eRr3n7 Anxiety Sleep duration (unit increase)
## 3 lVP89E eRr3n7 Anxiety Sleep duration (unit increase)
## 4 lVP89E eRr3n7 Anxiety Sleep duration (unit increase)
## 5 lVP89E eRr3n7 Anxiety Sleep duration (unit increase)
## method nsnp b se pval
## 1 Maximum likelihood 53 0.001559121 0.003147465 0.6203477
## 2 MR Egger 53 0.016552212 0.010800530 0.1315703
## 3 Weighted mode 53 0.006699404 0.006981957 0.3417318
## 4 Weighted median 53 0.005445090 0.004681674 0.2448032
## 5 Inverse variance weighted 53 0.001521643 0.003378274 0.6524074
sleep_psych_MR<- rbind(sleep_psych_MR, res)
mr_heterogeneity(sleep_dur_anx_dat)
## Not enough SNPs available for Heterogeneity analysis of 'YZehmn' on 'eRr3n7'
## id.exposure id.outcome outcome exposure
## 1 lVP89E eRr3n7 Anxiety Sleep duration (unit increase)
## 2 lVP89E eRr3n7 Anxiety Sleep duration (unit increase)
## method Q Q_df Q_pval
## 1 MR Egger 59.22940 51 0.2004694
## 2 Inverse variance weighted 61.71672 52 0.1676082
mr_pleiotropy_test(sleep_dur_anx_dat)
## Not enough SNPs available for pleiotropy analysis of 'YZehmn' on 'eRr3n7'
## id.exposure id.outcome outcome exposure egger_intercept
## 1 lVP89E eRr3n7 Anxiety Sleep duration (unit increase) -0.01514859
## se pval
## 1 0.01035118 0.1494767
p1 <- mr_scatter_plot(res, sleep_dur_anx_dat)
p1
## $lVP89E.eRr3n7
##
## $YZehmn.eRr3n7
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 lVP89E eRr3n7
## 2 YZehmn eRr3n7
res_single <- mr_singlesnp(sleep_dur_anx_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome samplesize
## 1 Sleep duration (unit increase) Anxiety lVP89E eRr3n7 117893.2
## SNP b se p
## 1 rs174560 -0.07581578 0.02714964 0.005230001
#bp<- fread("/Users/claire/Desktop/Desktop/sleepMR/BiP_withNeff.txt.gz", header=T, data.table=F)
bip_out_dat <- read_outcome_data(
snps = sleep_dur_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/BiP_withNeff.txt.gz",
sep = "\t",
snp_col = "SNP",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
# eaf_col = "MAF",
pval_col = "PVAL"
)
## No phenotype name specified, defaulting to 'outcome'.
bip_out_dat$outcome<- rep('Bipolar Disorder', 1, nrow(bip_out_dat))
sleep_dur_bip_dat <- harmonise_data(sleep_dur_exp_dat, bip_out_dat)
## Harmonising Sleep duration (unit increase) (lVP89E) and Bipolar Disorder (Fwy5oD)
## Removing the following SNPs for incompatible alleles:
## rs17732997
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10421649, rs10761674, rs11643715, rs12246842, rs12470989, rs12791153, rs1553132, rs17427571, rs17732997, rs2231265, rs269054, rs3095508, rs374153, rs4538155, rs55658675, rs7915425, rs8050478, rs915416
## Harmonising Sleep duration (unit decrease) (YZehmn) and Bipolar Disorder (Fwy5oD)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs330088
res <- mr(sleep_dur_bip_dat, method_list = methods)
## Analysing 'lVP89E' on 'Fwy5oD'
## No SNPs available for MR analysis of 'YZehmn' on 'Fwy5oD'
res
## id.exposure id.outcome outcome exposure
## 1 lVP89E Fwy5oD Bipolar Disorder Sleep duration (unit increase)
## 2 lVP89E Fwy5oD Bipolar Disorder Sleep duration (unit increase)
## 3 lVP89E Fwy5oD Bipolar Disorder Sleep duration (unit increase)
## 4 lVP89E Fwy5oD Bipolar Disorder Sleep duration (unit increase)
## 5 lVP89E Fwy5oD Bipolar Disorder Sleep duration (unit increase)
## method nsnp b se pval
## 1 Maximum likelihood 53 8.136526e-03 0.001737224 2.818293e-06
## 2 MR Egger 53 -1.040351e-04 0.011301936 9.926914e-01
## 3 Weighted mode 53 -3.649714e-04 0.003719076 9.222024e-01
## 4 Weighted median 53 -5.919751e-05 0.002718101 9.826243e-01
## 5 Inverse variance weighted 53 7.741394e-03 0.003224378 1.635504e-02
mr_heterogeneity(sleep_dur_bip_dat)
## Not enough SNPs available for Heterogeneity analysis of 'YZehmn' on 'Fwy5oD'
## id.exposure id.outcome outcome exposure
## 1 lVP89E Fwy5oD Bipolar Disorder Sleep duration (unit increase)
## 2 lVP89E Fwy5oD Bipolar Disorder Sleep duration (unit increase)
## method Q Q_df Q_pval
## 1 MR Egger 193.2099 51 2.056112e-18
## 2 Inverse variance weighted 195.1988 52 1.928335e-18
mr_pleiotropy_test(sleep_dur_bip_dat)
## Not enough SNPs available for pleiotropy analysis of 'YZehmn' on 'Fwy5oD'
## id.exposure id.outcome outcome exposure
## 1 lVP89E Fwy5oD Bipolar Disorder Sleep duration (unit increase)
## egger_intercept se pval
## 1 0.007278678 0.01004561 0.4720311
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = sleep_dur_bip_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, sleep_dur_bip_dat)
p1
## $lVP89E.Fwy5oD
##
## $YZehmn.Fwy5oD
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 lVP89E Fwy5oD
## 2 YZehmn Fwy5oD
res_single <- mr_singlesnp(sleep_dur_bip_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome
## 1 Sleep duration (unit increase) Bipolar Disorder lVP89E Fwy5oD
## 2 Sleep duration (unit increase) Bipolar Disorder lVP89E Fwy5oD
## 3 Sleep duration (unit increase) Bipolar Disorder lVP89E Fwy5oD
## 4 Sleep duration (unit increase) Bipolar Disorder lVP89E Fwy5oD
## 5 Sleep duration (unit increase) Bipolar Disorder lVP89E Fwy5oD
## 6 Sleep duration (unit increase) Bipolar Disorder lVP89E Fwy5oD
## 7 Sleep duration (unit increase) Bipolar Disorder lVP89E Fwy5oD
## 8 Sleep duration (unit increase) Bipolar Disorder lVP89E Fwy5oD
## 9 Sleep duration (unit increase) Bipolar Disorder lVP89E Fwy5oD
## 10 Sleep duration (unit increase) Bipolar Disorder lVP89E Fwy5oD
## samplesize SNP b se p
## 1 NA rs10973207 0.057046319 0.011904762 1.652168e-06
## 2 NA rs113113059 0.045415486 0.013888889 1.075798e-03
## 3 NA rs174560 0.087116721 0.012626263 5.213291e-12
## 4 NA rs205024 -0.051571697 0.012598425 4.249037e-05
## 5 NA rs34556183 0.032628896 0.011111111 3.318311e-03
## 6 NA rs34731055 0.048657739 0.011206897 1.413411e-05
## 7 NA rs62120041 0.040725169 0.014202899 4.138800e-03
## 8 NA rs7644809 0.055935442 0.015224359 2.387123e-04
## 9 NA rs9345234 0.042573325 0.013165266 1.221716e-03
## 10 NA All - Maximum likelihood 0.008136526 0.001737224 2.818293e-06
adhd_out_dat <- extract_outcome_data(snps = sleep_dur_exp_dat$SNP, outcomes = adhd)
## Extracting data for 72 SNP(s) from 1 GWAS(s)
## Finding proxies for 1 SNPs in outcome ieu-a-1183
## Extracting data for 1 SNP(s) from 1 GWAS(s)
sleep_dur_adhd_dat <- harmonise_data(sleep_dur_exp_dat, adhd_out_dat)
## Harmonising Sleep duration (unit increase) (lVP89E) and ADHD || id:ieu-a-1183 (ieu-a-1183)
## Removing the following SNPs for incompatible alleles:
## rs17732997
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10421649, rs10761674, rs11643715, rs12246842, rs12470989, rs12791153, rs1553132, rs17427571, rs17732997, rs2231265, rs269054, rs3095508, rs374153, rs4538155, rs55658675, rs7915425, rs8050478, rs915416
## Harmonising Sleep duration (unit decrease) (YZehmn) and ADHD || id:ieu-a-1183 (ieu-a-1183)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs330088
res <- mr(sleep_dur_adhd_dat, method_list = methods)
## Analysing 'lVP89E' on 'ieu-a-1183'
## No SNPs available for MR analysis of 'YZehmn' on 'ieu-a-1183'
res
## id.exposure id.outcome outcome exposure
## 1 lVP89E ieu-a-1183 ADHD || id:ieu-a-1183 Sleep duration (unit increase)
## 2 lVP89E ieu-a-1183 ADHD || id:ieu-a-1183 Sleep duration (unit increase)
## 3 lVP89E ieu-a-1183 ADHD || id:ieu-a-1183 Sleep duration (unit increase)
## 4 lVP89E ieu-a-1183 ADHD || id:ieu-a-1183 Sleep duration (unit increase)
## 5 lVP89E ieu-a-1183 ADHD || id:ieu-a-1183 Sleep duration (unit increase)
## method nsnp b se pval
## 1 Maximum likelihood 52 0.0001115095 0.002470050 0.9639920
## 2 MR Egger 52 0.0055869567 0.013160424 0.6730026
## 3 Weighted mode 52 -0.0027409779 0.006571876 0.6783726
## 4 Weighted median 52 -0.0003311490 0.003904801 0.9324159
## 5 Inverse variance weighted 52 0.0001081899 0.003722815 0.9768157
mr_heterogeneity(sleep_dur_adhd_dat)
## Not enough SNPs available for Heterogeneity analysis of 'YZehmn' on 'ieu-a-1183'
## id.exposure id.outcome outcome exposure
## 1 lVP89E ieu-a-1183 ADHD || id:ieu-a-1183 Sleep duration (unit increase)
## 2 lVP89E ieu-a-1183 ADHD || id:ieu-a-1183 Sleep duration (unit increase)
## method Q Q_df Q_pval
## 1 MR Egger 123.0327 50 4.313532e-08
## 2 Inverse variance weighted 123.4969 51 5.974699e-08
mr_pleiotropy_test(sleep_dur_adhd_dat)
## Not enough SNPs available for pleiotropy analysis of 'YZehmn' on 'ieu-a-1183'
## id.exposure id.outcome outcome exposure
## 1 lVP89E ieu-a-1183 ADHD || id:ieu-a-1183 Sleep duration (unit increase)
## egger_intercept se pval
## 1 -0.005096249 0.01173333 0.6659105
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = sleep_dur_adhd_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, sleep_dur_adhd_dat)
p1
## $`lVP89E.ieu-a-1183`
##
## $`YZehmn.ieu-a-1183`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 lVP89E ieu-a-1183
## 2 YZehmn ieu-a-1183
res_single <- mr_singlesnp(sleep_dur_adhd_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome
## 1 Sleep duration (unit increase) ADHD || id:ieu-a-1183 lVP89E ieu-a-1183
## 2 Sleep duration (unit increase) ADHD || id:ieu-a-1183 lVP89E ieu-a-1183
## 3 Sleep duration (unit increase) ADHD || id:ieu-a-1183 lVP89E ieu-a-1183
## 4 Sleep duration (unit increase) ADHD || id:ieu-a-1183 lVP89E ieu-a-1183
## 5 Sleep duration (unit increase) ADHD || id:ieu-a-1183 lVP89E ieu-a-1183
## samplesize SNP b se p
## 1 55374 rs10483350 -0.05734219 0.02027972 0.0046903753
## 2 55374 rs13088093 0.05187340 0.01578366 0.0010143196
## 3 55374 rs2072727 -0.06221868 0.01925287 0.0012307481
## 4 55374 rs34731055 -0.05536264 0.01618774 0.0006261296
## 5 55374 rs9903973 0.06639960 0.01773333 0.0001808698
# dpw<- fread("/Users/claire/Desktop/Desktop/sleepMR/DrinksPerWeek.txt.gz", header=T, data.table=F)
drinkspw_out_dat <- read_outcome_data(
snps = sleep_dur_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/DrinksPerWeek.txt.gz",
sep = "\t",
snp_col = "RSID",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "REF",
other_allele_col = "ALT",
eaf_col = "AF",
pval_col = "PVALUE"
)
## No phenotype name specified, defaulting to 'outcome'.
drinkspw_out_dat$outcome<- rep('Drinks per Week', 1, nrow(drinkspw_out_dat))
sleep_dur_dpw_dat <- harmonise_data(sleep_dur_exp_dat, drinkspw_out_dat)
## Harmonising Sleep duration (unit increase) (lVP89E) and Drinks per Week (11rUZm)
## Removing the following SNPs for incompatible alleles:
## rs17732997
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10421649, rs10761674, rs11643715, rs12246842, rs12470989, rs12791153, rs1553132, rs17427571, rs17732997, rs2231265, rs269054, rs3095508, rs374153, rs4538155, rs55658675, rs7915425, rs8050478, rs915416
## Harmonising Sleep duration (unit decrease) (YZehmn) and Drinks per Week (11rUZm)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs330088
res <- mr(sleep_dur_dpw_dat, method_list = methods)
## Analysing 'lVP89E' on '11rUZm'
## No SNPs available for MR analysis of 'YZehmn' on '11rUZm'
res
## id.exposure id.outcome outcome exposure
## 1 lVP89E 11rUZm Drinks per Week Sleep duration (unit increase)
## 2 lVP89E 11rUZm Drinks per Week Sleep duration (unit increase)
## 3 lVP89E 11rUZm Drinks per Week Sleep duration (unit increase)
## 4 lVP89E 11rUZm Drinks per Week Sleep duration (unit increase)
## 5 lVP89E 11rUZm Drinks per Week Sleep duration (unit increase)
## method nsnp b se pval
## 1 Maximum likelihood 53 5.555686e-07 0.0003621794 0.9987761
## 2 MR Egger 53 -1.714521e-03 0.0024331061 0.4842254
## 3 Weighted mode 53 2.865688e-04 0.0009154480 0.7555049
## 4 Weighted median 53 3.009946e-04 0.0006364466 0.6362632
## 5 Inverse variance weighted 53 5.555686e-07 0.0006962824 0.9993634
mr_heterogeneity(sleep_dur_dpw_dat)
## Not enough SNPs available for Heterogeneity analysis of 'YZehmn' on '11rUZm'
## id.exposure id.outcome outcome exposure
## 1 lVP89E 11rUZm Drinks per Week Sleep duration (unit increase)
## 2 lVP89E 11rUZm Drinks per Week Sleep duration (unit increase)
## method Q Q_df Q_pval
## 1 MR Egger 213.2749 51 9.864315e-22
## 2 Inverse variance weighted 215.5399 52 8.530824e-22
mr_pleiotropy_test(sleep_dur_dpw_dat)
## Not enough SNPs available for pleiotropy analysis of 'YZehmn' on '11rUZm'
## id.exposure id.outcome outcome exposure
## 1 lVP89E 11rUZm Drinks per Week Sleep duration (unit increase)
## egger_intercept se pval
## 1 0.001591035 0.00216188 0.4651328
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = sleep_dur_dpw_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, sleep_dur_dpw_dat)
p1
## $lVP89E.11rUZm
##
## $YZehmn.11rUZm
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 lVP89E 11rUZm
## 2 YZehmn 11rUZm
res_single <- mr_singlesnp(sleep_dur_dpw_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome
## 1 Sleep duration (unit increase) Drinks per Week lVP89E 11rUZm
## 2 Sleep duration (unit increase) Drinks per Week lVP89E 11rUZm
## 3 Sleep duration (unit increase) Drinks per Week lVP89E 11rUZm
## 4 Sleep duration (unit increase) Drinks per Week lVP89E 11rUZm
## 5 Sleep duration (unit increase) Drinks per Week lVP89E 11rUZm
## 6 Sleep duration (unit increase) Drinks per Week lVP89E 11rUZm
## 7 Sleep duration (unit increase) Drinks per Week lVP89E 11rUZm
## 8 Sleep duration (unit increase) Drinks per Week lVP89E 11rUZm
## 9 Sleep duration (unit increase) Drinks per Week lVP89E 11rUZm
## samplesize SNP b se p
## 1 NA rs13109404 -0.014252952 0.002327497 9.141298e-10
## 2 NA rs174560 -0.007493719 0.002615326 4.166015e-03
## 3 NA rs2072727 0.008553078 0.002794169 2.205655e-03
## 4 NA rs2192528 0.012703134 0.002899080 1.177134e-05
## 5 NA rs34354917 -0.013579983 0.003209761 2.328211e-05
## 6 NA rs34556183 -0.006195620 0.002215549 5.167120e-03
## 7 NA rs4402351 0.010527616 0.002718219 1.075112e-04
## 8 NA rs4592416 0.007064798 0.002423206 3.551465e-03
## 9 NA rs61796569 0.009521132 0.002650902 3.285821e-04
# cigs<- fread("/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/cigs_withNeff.txt.gz", header=T, data.table = F)
cigs_out_dat <- read_outcome_data(
snps = sleep_dur_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/cigs_withNeff.txt.gz",
sep = "\t",
snp_col = "RSID",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
eaf_col = "MAF",
pval_col = "PVALUE"
)
## No phenotype name specified, defaulting to 'outcome'.
cigs_out_dat$outcome<- rep('Cigarettes per Day', 1, nrow(cigs_out_dat))
sleep_dur_cigs_dat <- harmonise_data(sleep_dur_exp_dat, cigs_out_dat)
## Harmonising Sleep duration (unit increase) (lVP89E) and Cigarettes per Day (BaIDRA)
## Removing the following SNPs for incompatible alleles:
## rs17732997
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10421649, rs10761674, rs11643715, rs12246842, rs12470989, rs12791153, rs1553132, rs17427571, rs17732997, rs2231265, rs269054, rs3095508, rs374153, rs4538155, rs55658675, rs7915425, rs8050478, rs915416
## Harmonising Sleep duration (unit decrease) (YZehmn) and Cigarettes per Day (BaIDRA)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs330088
res <- mr(sleep_dur_cigs_dat, method_list = methods)
## Analysing 'lVP89E' on 'BaIDRA'
## No SNPs available for MR analysis of 'YZehmn' on 'BaIDRA'
res
## id.exposure id.outcome outcome exposure
## 1 lVP89E BaIDRA Cigarettes per Day Sleep duration (unit increase)
## 2 lVP89E BaIDRA Cigarettes per Day Sleep duration (unit increase)
## 3 lVP89E BaIDRA Cigarettes per Day Sleep duration (unit increase)
## 4 lVP89E BaIDRA Cigarettes per Day Sleep duration (unit increase)
## 5 lVP89E BaIDRA Cigarettes per Day Sleep duration (unit increase)
## method nsnp b se pval
## 1 Maximum likelihood 53 -0.0004518498 0.001009541 0.6544569
## 2 MR Egger 53 -0.0002250402 0.005264694 0.9660716
## 3 Weighted mode 53 -0.0011421870 0.002470375 0.6457565
## 4 Weighted median 53 -0.0004029734 0.001748237 0.8177012
## 5 Inverse variance weighted 53 -0.0004324516 0.001499477 0.7730393
mr_heterogeneity(sleep_dur_cigs_dat)
## Not enough SNPs available for Heterogeneity analysis of 'YZehmn' on 'BaIDRA'
## id.exposure id.outcome outcome exposure
## 1 lVP89E BaIDRA Cigarettes per Day Sleep duration (unit increase)
## 2 lVP89E BaIDRA Cigarettes per Day Sleep duration (unit increase)
## method Q Q_df Q_pval
## 1 MR Egger 121.9514 51 9.578106e-08
## 2 Inverse variance weighted 121.9554 52 1.506067e-07
mr_pleiotropy_test(sleep_dur_cigs_dat)
## Not enough SNPs available for pleiotropy analysis of 'YZehmn' on 'BaIDRA'
## id.exposure id.outcome outcome exposure
## 1 lVP89E BaIDRA Cigarettes per Day Sleep duration (unit increase)
## egger_intercept se pval
## 1 -0.0001922821 0.004674476 0.9673493
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = sleep_dur_cigs_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, sleep_dur_cigs_dat)
p1
## $lVP89E.BaIDRA
##
## $YZehmn.BaIDRA
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 lVP89E BaIDRA
## 2 YZehmn BaIDRA
res_single <- mr_singlesnp(sleep_dur_cigs_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome
## 1 Sleep duration (unit increase) Cigarettes per Day lVP89E BaIDRA
## 2 Sleep duration (unit increase) Cigarettes per Day lVP89E BaIDRA
## 3 Sleep duration (unit increase) Cigarettes per Day lVP89E BaIDRA
## 4 Sleep duration (unit increase) Cigarettes per Day lVP89E BaIDRA
## samplesize SNP b se p
## 1 NA rs11567976 -0.02538684 0.008452894 0.0026704139
## 2 NA rs11614986 0.02380328 0.007690489 0.0019670841
## 3 NA rs174560 0.02168665 0.007438458 0.0035514648
## 4 NA rs34731055 0.02448470 0.007416203 0.0009616426
dur_full<- fread("/Users/claire/Desktop/dissertation/cotwin_mendelian//sleepMR/sumstats/actisleepdur.txt.gz", header=T, data.table = F)
dur<- fread("/Users/claire/Desktop/sleepGWAS/component/acti_sleepdur/GenomicRiskLoci.txt", header=T, data.table=F)
dur<- dur %>% select(rsID) %>%
rename(SNP=rsID)
dur_full<- dur_full %>% right_join(dur)
## Joining with `by = join_by(SNP)`
sleep_dur_exp_dat <- format_data(dur_full, type="exposure",
snp_col = "SNP", beta_col = "beta", se_col = "SE", effect_allele_col = "A1", other_allele_col = "A2", eaf_col = "MAF", pval_col = "p", samplesize_col = "N")
## No phenotype name specified, defaulting to 'exposure'.
sleep_dur_exp_dat$exposure<- rep("Accelerometer sleep duration", 1, nrow(sleep_dur_exp_dat))
nrow(sleep_dur_exp_dat)
## [1] 11
sleep_dur_exp_dat <- sleep_dur_exp_dat %>% as.data.table
sleep_dur_exp_dat <- sleep_dur_exp_dat[, F_STAT := qf(
pval.exposure,
df1=1,
df2=samplesize.exposure,
lower.tail=F
)] # this piece calculates the F statistic of each SNP in the IV and adds a column called F_STAT
sleep_dur_exp_dat$F_STAT %>% mean # to calculate the overall F stat of your exposure
## [1] 49.06198
sleep_dur_exp_dat$F_STAT %>% min # you can use this to check whether any individual SNPs fall under F of 10 which would make them invalid instruments
## [1] 31.06718
dep_out_dat <- extract_outcome_data(snps = sleep_dur_exp_dat$SNP, outcomes = dep)
## Extracting data for 11 SNP(s) from 1 GWAS(s)
## Finding proxies for 1 SNPs in outcome ieu-b-102
## Extracting data for 1 SNP(s) from 1 GWAS(s)
sleep_dur_dep_dat <- harmonise_data(sleep_dur_exp_dat, dep_out_dat)
## Harmonising Accelerometer sleep duration (m33Bcv) and Major depression || id:ieu-b-102 (ieu-b-102)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10138240, rs2975734
res <- mr(sleep_dur_dep_dat, method_list = methods)
## Analysing 'm33Bcv' on 'ieu-b-102'
res
## id.exposure id.outcome outcome
## 1 m33Bcv ieu-b-102 Major depression || id:ieu-b-102
## 2 m33Bcv ieu-b-102 Major depression || id:ieu-b-102
## 3 m33Bcv ieu-b-102 Major depression || id:ieu-b-102
## 4 m33Bcv ieu-b-102 Major depression || id:ieu-b-102
## 5 m33Bcv ieu-b-102 Major depression || id:ieu-b-102
## exposure method nsnp b
## 1 Accelerometer sleep duration Maximum likelihood 9 0.003435200
## 2 Accelerometer sleep duration MR Egger 9 -0.085367841
## 3 Accelerometer sleep duration Weighted mode 9 0.006946422
## 4 Accelerometer sleep duration Weighted median 9 -0.005991883
## 5 Accelerometer sleep duration Inverse variance weighted 9 0.003298690
## se pval
## 1 0.04309986 0.9364732
## 2 0.16538942 0.6216405
## 3 0.07703251 0.9303648
## 4 0.05897580 0.9190750
## 5 0.06145466 0.9571927
mr_heterogeneity(sleep_dur_dep_dat)
## id.exposure id.outcome outcome
## 1 m33Bcv ieu-b-102 Major depression || id:ieu-b-102
## 2 m33Bcv ieu-b-102 Major depression || id:ieu-b-102
## exposure method Q Q_df
## 1 Accelerometer sleep duration MR Egger 16.10412 7
## 2 Accelerometer sleep duration Inverse variance weighted 16.88250 8
## Q_pval
## 1 0.02418190
## 2 0.03135613
mr_pleiotropy_test(sleep_dur_dep_dat)
## id.exposure id.outcome outcome
## 1 m33Bcv ieu-b-102 Major depression || id:ieu-b-102
## exposure egger_intercept se pval
## 1 Accelerometer sleep duration 0.004086871 0.00702613 0.5790323
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = sleep_dur_dep_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, sleep_dur_dep_dat)
p1
## $`m33Bcv.ieu-b-102`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 m33Bcv ieu-b-102
res_single <- mr_singlesnp(sleep_dur_dep_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## [1] exposure outcome id.exposure id.outcome samplesize SNP
## [7] b se p
## <0 rows> (or 0-length row.names)
anx_out_dat <- read_outcome_data(
snps = sleep_dur_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/anxiety_withNeff.txt.gz",
sep = "\t",
snp_col = "SNP",
beta_col = "effect",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
eaf_col = "MAF",
pval_col = "P",
samplesize_col = "Neff"
)
## No phenotype name specified, defaulting to 'outcome'.
anx_out_dat$outcome<- rep('Anxiety', 1, nrow(anx_out_dat))
sleep_dur_anx_dat <- harmonise_data(sleep_dur_exp_dat, anx_out_dat)
## Harmonising Accelerometer sleep duration (m33Bcv) and Anxiety (Zxqv1B)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10138240, rs2975734
res <- mr(sleep_dur_anx_dat, method_list = methods)
## Analysing 'm33Bcv' on 'Zxqv1B'
res
## id.exposure id.outcome outcome exposure
## 1 m33Bcv Zxqv1B Anxiety Accelerometer sleep duration
## 2 m33Bcv Zxqv1B Anxiety Accelerometer sleep duration
## 3 m33Bcv Zxqv1B Anxiety Accelerometer sleep duration
## 4 m33Bcv Zxqv1B Anxiety Accelerometer sleep duration
## 5 m33Bcv Zxqv1B Anxiety Accelerometer sleep duration
## method nsnp b se pval
## 1 Maximum likelihood 9 -0.057706150 0.1327914 0.6638800
## 2 MR Egger 9 0.261592548 0.3374212 0.4635606
## 3 Weighted mode 9 0.013955322 0.1736275 0.9379133
## 4 Weighted median 9 0.001294079 0.1702737 0.9939361
## 5 Inverse variance weighted 9 -0.056897969 0.1570173 0.7170775
mr_heterogeneity(sleep_dur_anx_dat)
## id.exposure id.outcome outcome exposure
## 1 m33Bcv Zxqv1B Anxiety Accelerometer sleep duration
## 2 m33Bcv Zxqv1B Anxiety Accelerometer sleep duration
## method Q Q_df Q_pval
## 1 MR Egger 9.788219 7 0.2008959
## 2 Inverse variance weighted 11.371269 8 0.1815367
mr_pleiotropy_test(sleep_dur_anx_dat)
## id.exposure id.outcome outcome exposure egger_intercept
## 1 m33Bcv Zxqv1B Anxiety Accelerometer sleep duration -0.01956117
## se pval
## 1 0.01838443 0.3226462
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, sleep_dur_anx_dat)
p1
## $m33Bcv.Zxqv1B
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 m33Bcv Zxqv1B
res_single <- mr_singlesnp(sleep_dur_anx_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## [1] exposure outcome id.exposure id.outcome samplesize SNP
## [7] b se p
## <0 rows> (or 0-length row.names)
scz_out_dat <- extract_outcome_data(snps = sleep_dur_exp_dat$SNP, outcomes = scz)
## Extracting data for 11 SNP(s) from 1 GWAS(s)
## Finding proxies for 1 SNPs in outcome ieu-b-42
## Extracting data for 1 SNP(s) from 1 GWAS(s)
sleep_dur_scz_dat <- harmonise_data(sleep_dur_exp_dat, scz_out_dat)
## Harmonising Accelerometer sleep duration (m33Bcv) and schizophrenia || id:ieu-b-42 (ieu-b-42)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10138240, rs2975734
res <- mr(sleep_dur_scz_dat, method_list = methods)
## Analysing 'm33Bcv' on 'ieu-b-42'
res
## id.exposure id.outcome outcome
## 1 m33Bcv ieu-b-42 schizophrenia || id:ieu-b-42
## 2 m33Bcv ieu-b-42 schizophrenia || id:ieu-b-42
## 3 m33Bcv ieu-b-42 schizophrenia || id:ieu-b-42
## 4 m33Bcv ieu-b-42 schizophrenia || id:ieu-b-42
## 5 m33Bcv ieu-b-42 schizophrenia || id:ieu-b-42
## exposure method nsnp b
## 1 Accelerometer sleep duration Maximum likelihood 9 0.5536043
## 2 Accelerometer sleep duration MR Egger 9 0.8632304
## 3 Accelerometer sleep duration Weighted mode 9 0.4455836
## 4 Accelerometer sleep duration Weighted median 9 0.4099781
## 5 Accelerometer sleep duration Inverse variance weighted 9 0.5325843
## se pval
## 1 0.1178942 2.656028e-06
## 2 0.8761231 3.573075e-01
## 3 0.1669934 2.843841e-02
## 4 0.1536659 7.630820e-03
## 5 0.3204400 9.650466e-02
mr_heterogeneity(sleep_dur_scz_dat)
## id.exposure id.outcome outcome
## 1 m33Bcv ieu-b-42 schizophrenia || id:ieu-b-42
## 2 m33Bcv ieu-b-42 schizophrenia || id:ieu-b-42
## exposure method Q Q_df
## 1 Accelerometer sleep duration MR Egger 69.10253 7
## 2 Accelerometer sleep duration Inverse variance weighted 70.75534 8
## Q_pval
## 1 2.242779e-12
## 2 3.475588e-12
mr_pleiotropy_test(sleep_dur_scz_dat)
## id.exposure id.outcome outcome
## 1 m33Bcv ieu-b-42 schizophrenia || id:ieu-b-42
## exposure egger_intercept se pval
## 1 Accelerometer sleep duration -0.01521301 0.03717941 0.6946386
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = sleep_dur_scz_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, sleep_dur_scz_dat)
p1
## $`m33Bcv.ieu-b-42`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 m33Bcv ieu-b-42
res_single <- mr_singlesnp(sleep_dur_scz_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure
## 1 Accelerometer sleep duration schizophrenia || id:ieu-b-42 m33Bcv
## 2 Accelerometer sleep duration schizophrenia || id:ieu-b-42 m33Bcv
## id.outcome samplesize SNP b se
## 1 ieu-b-42 77096 rs2660302 2.7282486 0.3304717
## 2 ieu-b-42 77096 All - Maximum likelihood 0.5536043 0.1178942
## p
## 1 1.511152e-16
## 2 2.656028e-06
#bp<- fread("/Users/claire/Desktop/Desktop/sleepMR/BiP_withNeff.txt.gz", header=T, data.table=F)
bip_out_dat <- read_outcome_data(
snps = sleep_dur_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/BiP_withNeff.txt.gz",
sep = "\t",
snp_col = "SNP",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
# eaf_col = "MAF",
pval_col = "PVAL"
)
## No phenotype name specified, defaulting to 'outcome'.
bip_out_dat$outcome<- rep('Bipolar Disorder', 1, nrow(bip_out_dat))
sleep_dur_bip_dat <- harmonise_data(sleep_dur_exp_dat, bip_out_dat)
## Harmonising Accelerometer sleep duration (m33Bcv) and Bipolar Disorder (RJxEaE)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10138240, rs2660302, rs2880370, rs2975734
res <- mr(sleep_dur_bip_dat, method_list = methods)
## Analysing 'm33Bcv' on 'RJxEaE'
res
## id.exposure id.outcome outcome exposure
## 1 m33Bcv RJxEaE Bipolar Disorder Accelerometer sleep duration
## 2 m33Bcv RJxEaE Bipolar Disorder Accelerometer sleep duration
## 3 m33Bcv RJxEaE Bipolar Disorder Accelerometer sleep duration
## 4 m33Bcv RJxEaE Bipolar Disorder Accelerometer sleep duration
## 5 m33Bcv RJxEaE Bipolar Disorder Accelerometer sleep duration
## method nsnp b se pval
## 1 Maximum likelihood 7 0.007605284 0.1033193 0.9413211
## 2 MR Egger 7 0.025439661 0.2529830 0.9238085
## 3 Weighted mode 7 0.031164764 0.1571262 0.8493270
## 4 Weighted median 7 -0.009282804 0.1336033 0.9446073
## 5 Inverse variance weighted 7 0.007714449 0.1027275 0.9401381
sleep_psych_MR<- rbind(sleep_psych_MR, res)
mr_heterogeneity(sleep_dur_bip_dat)
## id.exposure id.outcome outcome exposure
## 1 m33Bcv RJxEaE Bipolar Disorder Accelerometer sleep duration
## 2 m33Bcv RJxEaE Bipolar Disorder Accelerometer sleep duration
## method Q Q_df Q_pval
## 1 MR Egger 4.249435 5 0.5140904
## 2 Inverse variance weighted 4.255314 6 0.6421689
mr_pleiotropy_test(sleep_dur_bip_dat)
## id.exposure id.outcome outcome exposure
## 1 m33Bcv RJxEaE Bipolar Disorder Accelerometer sleep duration
## egger_intercept se pval
## 1 -0.0008672723 0.01131169 0.9418591
p1 <- mr_scatter_plot(res, sleep_dur_bip_dat)
p1
## $m33Bcv.RJxEaE
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 m33Bcv RJxEaE
res_single <- mr_singlesnp(sleep_dur_bip_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## [1] exposure outcome id.exposure id.outcome samplesize SNP
## [7] b se p
## <0 rows> (or 0-length row.names)
adhd_out_dat <- extract_outcome_data(snps = sleep_dur_exp_dat$SNP, outcomes = adhd)
## Extracting data for 11 SNP(s) from 1 GWAS(s)
## Finding proxies for 1 SNPs in outcome ieu-a-1183
## Extracting data for 1 SNP(s) from 1 GWAS(s)
sleep_dur_adhd_dat <- harmonise_data(sleep_dur_exp_dat, adhd_out_dat)
## Harmonising Accelerometer sleep duration (m33Bcv) and ADHD || id:ieu-a-1183 (ieu-a-1183)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10138240, rs2660302, rs2880370, rs2975734
res <- mr(sleep_dur_adhd_dat, method_list = methods)
## Analysing 'm33Bcv' on 'ieu-a-1183'
res
## id.exposure id.outcome outcome exposure
## 1 m33Bcv ieu-a-1183 ADHD || id:ieu-a-1183 Accelerometer sleep duration
## 2 m33Bcv ieu-a-1183 ADHD || id:ieu-a-1183 Accelerometer sleep duration
## 3 m33Bcv ieu-a-1183 ADHD || id:ieu-a-1183 Accelerometer sleep duration
## 4 m33Bcv ieu-a-1183 ADHD || id:ieu-a-1183 Accelerometer sleep duration
## 5 m33Bcv ieu-a-1183 ADHD || id:ieu-a-1183 Accelerometer sleep duration
## method nsnp b se pval
## 1 Maximum likelihood 7 -0.02158384 0.1543744 0.8888062
## 2 MR Egger 7 -0.06387453 0.8773255 0.9447833
## 3 Weighted mode 7 -0.18205882 0.2254141 0.4501092
## 4 Weighted median 7 -0.14335440 0.2001081 0.4737538
## 5 Inverse variance weighted 7 -0.02087624 0.3238075 0.9485951
mr_heterogeneity(sleep_dur_adhd_dat)
## id.exposure id.outcome outcome exposure
## 1 m33Bcv ieu-a-1183 ADHD || id:ieu-a-1183 Accelerometer sleep duration
## 2 m33Bcv ieu-a-1183 ADHD || id:ieu-a-1183 Accelerometer sleep duration
## method Q Q_df Q_pval
## 1 MR Egger 28.14900 5 3.403709e-05
## 2 Inverse variance weighted 28.16516 6 8.746591e-05
mr_pleiotropy_test(sleep_dur_adhd_dat)
## id.exposure id.outcome outcome exposure
## 1 m33Bcv ieu-a-1183 ADHD || id:ieu-a-1183 Accelerometer sleep duration
## egger_intercept se pval
## 1 0.002095052 0.03909938 0.9593426
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = sleep_dur_adhd_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, sleep_dur_adhd_dat)
p1
## $`m33Bcv.ieu-a-1183`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 m33Bcv ieu-a-1183
res_single <- mr_singlesnp(sleep_dur_adhd_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome
## 1 Accelerometer sleep duration ADHD || id:ieu-a-1183 m33Bcv ieu-a-1183
## samplesize SNP b se p
## 1 55374 rs17400325 2.618127 0.5991694 1.244772e-05
# dpw<- fread("/Users/claire/Desktop/Desktop/sleepMR/DrinksPerWeek.txt.gz", header=T, data.table=F)
drinkspw_out_dat <- read_outcome_data(
snps = sleep_dur_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/DrinksPerWeek.txt.gz",
sep = "\t",
snp_col = "RSID",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "REF",
other_allele_col = "ALT",
eaf_col = "AF",
pval_col = "PVALUE"
)
## No phenotype name specified, defaulting to 'outcome'.
drinkspw_out_dat$outcome<- rep('Drinks per Week', 1, nrow(drinkspw_out_dat))
sleep_dur_dpw_dat <- harmonise_data(sleep_dur_exp_dat, drinkspw_out_dat)
## Harmonising Accelerometer sleep duration (m33Bcv) and Drinks per Week (7vwzC2)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10138240, rs2975734
res <- mr(sleep_dur_dpw_dat, method_list = methods)
## Analysing 'm33Bcv' on '7vwzC2'
res
## id.exposure id.outcome outcome exposure
## 1 m33Bcv 7vwzC2 Drinks per Week Accelerometer sleep duration
## 2 m33Bcv 7vwzC2 Drinks per Week Accelerometer sleep duration
## 3 m33Bcv 7vwzC2 Drinks per Week Accelerometer sleep duration
## 4 m33Bcv 7vwzC2 Drinks per Week Accelerometer sleep duration
## 5 m33Bcv 7vwzC2 Drinks per Week Accelerometer sleep duration
## method nsnp b se pval
## 1 Maximum likelihood 9 0.00879108 0.01908488 0.6450635
## 2 MR Egger 9 0.04774417 0.05797035 0.4373255
## 3 Weighted mode 9 0.03799855 0.02885939 0.2244129
## 4 Weighted median 9 0.02827198 0.02507932 0.2596147
## 5 Inverse variance weighted 9 0.00847769 0.02217028 0.7021722
sleep_psych_MR<- rbind(sleep_psych_MR, res)
mr_heterogeneity(sleep_dur_dpw_dat)
## id.exposure id.outcome outcome exposure
## 1 m33Bcv 7vwzC2 Drinks per Week Accelerometer sleep duration
## 2 m33Bcv 7vwzC2 Drinks per Week Accelerometer sleep duration
## method Q Q_df Q_pval
## 1 MR Egger 10.24525 7 0.1750960
## 2 Inverse variance weighted 11.04006 8 0.1994395
mr_pleiotropy_test(sleep_dur_dpw_dat)
## id.exposure id.outcome outcome exposure
## 1 m33Bcv 7vwzC2 Drinks per Week Accelerometer sleep duration
## egger_intercept se pval
## 1 -0.001823757 0.002474845 0.4851324
p1 <- mr_scatter_plot(res, sleep_dur_dpw_dat)
p1
## $m33Bcv.7vwzC2
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 m33Bcv 7vwzC2
res_single <- mr_singlesnp(sleep_dur_dpw_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## [1] exposure outcome id.exposure id.outcome samplesize SNP
## [7] b se p
## <0 rows> (or 0-length row.names)
# cigs<- fread("/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/cigs_withNeff.txt.gz", header=T, data.table = F)
cigs_out_dat <- read_outcome_data(
snps = sleep_dur_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/cigs_withNeff.txt.gz",
sep = "\t",
snp_col = "RSID",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
eaf_col = "MAF",
pval_col = "PVALUE"
)
## No phenotype name specified, defaulting to 'outcome'.
cigs_out_dat$outcome<- rep('Cigarettes per Day', 1, nrow(cigs_out_dat))
sleep_dur_cigs_dat <- harmonise_data(sleep_dur_exp_dat, cigs_out_dat)
## Harmonising Accelerometer sleep duration (m33Bcv) and Cigarettes per Day (9svD5Y)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10138240, rs2975734
res <- mr(sleep_dur_cigs_dat, method_list = methods)
## Analysing 'm33Bcv' on '9svD5Y'
res
## id.exposure id.outcome outcome exposure
## 1 m33Bcv 9svD5Y Cigarettes per Day Accelerometer sleep duration
## 2 m33Bcv 9svD5Y Cigarettes per Day Accelerometer sleep duration
## 3 m33Bcv 9svD5Y Cigarettes per Day Accelerometer sleep duration
## 4 m33Bcv 9svD5Y Cigarettes per Day Accelerometer sleep duration
## 5 m33Bcv 9svD5Y Cigarettes per Day Accelerometer sleep duration
## method nsnp b se pval
## 1 Maximum likelihood 9 -0.11753264 0.05581313 0.03521963
## 2 MR Egger 9 0.01264264 0.17613054 0.94478483
## 3 Weighted mode 9 -0.09705463 0.09962578 0.35849360
## 4 Weighted median 9 -0.10117164 0.07739866 0.19116186
## 5 Inverse variance weighted 9 -0.11713158 0.06830170 0.08636089
sleep_psych_MR<- rbind(sleep_psych_MR, res)
mr_heterogeneity(sleep_dur_cigs_dat)
## id.exposure id.outcome outcome exposure
## 1 m33Bcv 9svD5Y Cigarettes per Day Accelerometer sleep duration
## 2 m33Bcv 9svD5Y Cigarettes per Day Accelerometer sleep duration
## method Q Q_df Q_pval
## 1 MR Egger 11.39557 7 0.1222711
## 2 Inverse variance weighted 12.44442 8 0.1324492
mr_pleiotropy_test(sleep_dur_cigs_dat)
## id.exposure id.outcome outcome exposure
## 1 m33Bcv 9svD5Y Cigarettes per Day Accelerometer sleep duration
## egger_intercept se pval
## 1 -0.006050171 0.007537546 0.4485549
p1 <- mr_scatter_plot(res, sleep_dur_cigs_dat)
p1
## $m33Bcv.9svD5Y
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 m33Bcv 9svD5Y
res_single <- mr_singlesnp(sleep_dur_cigs_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome
## 1 Accelerometer sleep duration Cigarettes per Day m33Bcv 9svD5Y
## samplesize SNP b se p
## 1 NA rs2880370 -0.6342443 0.2078652 0.002279065
should have 126 loci
for ex: napping genomic loci # = 126, and the SNPs being pulled out of here are 107
napping_exp_dat <- extract_instruments(outcomes = napping)
nrow(napping_exp_dat)
## [1] 107
napping_exp_dat <- napping_exp_dat %>% as.data.table
napping_exp_dat <- napping_exp_dat[, F_STAT := qf(
pval.exposure,
df1=1,
df2=samplesize.exposure,
lower.tail=F
)] # this piece calculates the F statistic of each SNP in the IV and adds a column called F_STAT
napping_exp_dat$F_STAT %>% mean # to calculate the overall F stat of your exposure
## [1] 46.24445
napping_exp_dat$F_STAT %>% min # you can use this to check whether any individual SNPs fall under F of 10 which would make them invalid instruments
## [1] 30.0092
dep_out_dat <- extract_outcome_data(snps = napping_exp_dat$SNP, outcomes = dep)
## Extracting data for 107 SNP(s) from 1 GWAS(s)
## Finding proxies for 20 SNPs in outcome ieu-b-102
## Extracting data for 20 SNP(s) from 1 GWAS(s)
napping_exp_dep_dat <- harmonise_data(napping_exp_dat, dep_out_dat)
## Harmonising Daytime nap || id:ebi-a-GCST011494 (ebi-a-GCST011494) and Major depression || id:ieu-b-102 (ieu-b-102)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10772659, rs285815
res <- mr(napping_exp_dep_dat, method_list = methods)
## Analysing 'ebi-a-GCST011494' on 'ieu-b-102'
res
## id.exposure id.outcome outcome
## 1 ebi-a-GCST011494 ieu-b-102 Major depression || id:ieu-b-102
## 2 ebi-a-GCST011494 ieu-b-102 Major depression || id:ieu-b-102
## 3 ebi-a-GCST011494 ieu-b-102 Major depression || id:ieu-b-102
## 4 ebi-a-GCST011494 ieu-b-102 Major depression || id:ieu-b-102
## 5 ebi-a-GCST011494 ieu-b-102 Major depression || id:ieu-b-102
## exposure method nsnp b
## 1 Daytime nap || id:ebi-a-GCST011494 Maximum likelihood 97 0.28358764
## 2 Daytime nap || id:ebi-a-GCST011494 MR Egger 97 0.19874579
## 3 Daytime nap || id:ebi-a-GCST011494 Weighted mode 97 -0.06017036
## 4 Daytime nap || id:ebi-a-GCST011494 Weighted median 97 0.05741615
## 5 Daytime nap || id:ebi-a-GCST011494 Inverse variance weighted 97 0.27216870
## se pval
## 1 0.05483493 2.320230e-07
## 2 0.35337693 5.751555e-01
## 3 0.12089119 6.198173e-01
## 4 0.09045783 5.256056e-01
## 5 0.10182466 7.519518e-03
mr_heterogeneity(napping_exp_dep_dat)
## id.exposure id.outcome outcome
## 1 ebi-a-GCST011494 ieu-b-102 Major depression || id:ieu-b-102
## 2 ebi-a-GCST011494 ieu-b-102 Major depression || id:ieu-b-102
## exposure method Q Q_df
## 1 Daytime nap || id:ebi-a-GCST011494 MR Egger 362.0641 95
## 2 Daytime nap || id:ebi-a-GCST011494 Inverse variance weighted 362.2437 96
## Q_pval
## 1 8.256185e-33
## 2 1.517402e-32
mr_pleiotropy_test(napping_exp_dep_dat)
## id.exposure id.outcome outcome
## 1 ebi-a-GCST011494 ieu-b-102 Major depression || id:ieu-b-102
## exposure egger_intercept se pval
## 1 Daytime nap || id:ebi-a-GCST011494 0.0007279679 0.003353509 0.8286142
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = napping_exp_dep_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, napping_exp_dep_dat)
p1
## $`ebi-a-GCST011494.ieu-b-102`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 ebi-a-GCST011494 ieu-b-102
res_single <- mr_singlesnp(napping_exp_dep_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome
## 1 Daytime nap || id:ebi-a-GCST011494 Major depression || id:ieu-b-102
## 2 Daytime nap || id:ebi-a-GCST011494 Major depression || id:ieu-b-102
## 3 Daytime nap || id:ebi-a-GCST011494 Major depression || id:ieu-b-102
## 4 Daytime nap || id:ebi-a-GCST011494 Major depression || id:ieu-b-102
## 5 Daytime nap || id:ebi-a-GCST011494 Major depression || id:ieu-b-102
## 6 Daytime nap || id:ebi-a-GCST011494 Major depression || id:ieu-b-102
## 7 Daytime nap || id:ebi-a-GCST011494 Major depression || id:ieu-b-102
## 8 Daytime nap || id:ebi-a-GCST011494 Major depression || id:ieu-b-102
## 9 Daytime nap || id:ebi-a-GCST011494 Major depression || id:ieu-b-102
## 10 Daytime nap || id:ebi-a-GCST011494 Major depression || id:ieu-b-102
## 11 Daytime nap || id:ebi-a-GCST011494 Major depression || id:ieu-b-102
## 12 Daytime nap || id:ebi-a-GCST011494 Major depression || id:ieu-b-102
## 13 Daytime nap || id:ebi-a-GCST011494 Major depression || id:ieu-b-102
## 14 Daytime nap || id:ebi-a-GCST011494 Major depression || id:ieu-b-102
## 15 Daytime nap || id:ebi-a-GCST011494 Major depression || id:ieu-b-102
## 16 Daytime nap || id:ebi-a-GCST011494 Major depression || id:ieu-b-102
## id.exposure id.outcome samplesize SNP b
## 1 ebi-a-GCST011494 ieu-b-102 NA rs10875606 2.0468831
## 2 ebi-a-GCST011494 ieu-b-102 NA rs11071755 1.6586988
## 3 ebi-a-GCST011494 ieu-b-102 NA rs11682175 2.7880373
## 4 ebi-a-GCST011494 ieu-b-102 NA rs174541 1.4065779
## 5 ebi-a-GCST011494 ieu-b-102 NA rs1931175 -1.7260812
## 6 ebi-a-GCST011494 ieu-b-102 NA rs224111 2.1292292
## 7 ebi-a-GCST011494 ieu-b-102 NA rs2370926 -1.6723786
## 8 ebi-a-GCST011494 ieu-b-102 NA rs2431108 2.7498132
## 9 ebi-a-GCST011494 ieu-b-102 NA rs2943023 1.9143551
## 10 ebi-a-GCST011494 ieu-b-102 NA rs301817 -3.0637171
## 11 ebi-a-GCST011494 ieu-b-102 NA rs3799380 3.3475097
## 12 ebi-a-GCST011494 ieu-b-102 NA rs6452787 -2.6134286
## 13 ebi-a-GCST011494 ieu-b-102 NA rs76824303 2.0003899
## 14 ebi-a-GCST011494 ieu-b-102 NA rs910187 2.0635350
## 15 ebi-a-GCST011494 ieu-b-102 NA rs9389556 1.9250948
## 16 ebi-a-GCST011494 ieu-b-102 NA All - Maximum likelihood 0.2835876
## se p
## 1 0.63710931 1.314634e-03
## 2 0.60444110 6.066115e-03
## 3 0.61796703 6.433197e-06
## 4 0.45536695 2.009066e-03
## 5 0.59253534 3.579248e-03
## 6 0.55109461 1.117115e-04
## 7 0.55336056 2.509263e-03
## 8 0.35431767 8.434903e-15
## 9 0.61935019 1.995447e-03
## 10 0.59912691 3.160154e-07
## 11 0.60659572 3.418695e-08
## 12 0.55632392 2.631404e-06
## 13 0.61876467 1.225504e-03
## 14 0.60129497 5.995494e-04
## 15 0.58228176 9.459674e-04
## 16 0.05483493 2.320230e-07
anx_out_dat <- read_outcome_data(
snps = napping_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/anxiety_withNeff.txt.gz",
sep = "\t",
snp_col = "SNP",
beta_col = "effect",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
eaf_col = "MAF",
pval_col = "P",
samplesize_col = "Neff"
)
## No phenotype name specified, defaulting to 'outcome'.
anx_out_dat$outcome<- rep('Anxiety', 1, nrow(anx_out_dat))
napping_anx_dat <- harmonise_data(napping_exp_dat, anx_out_dat)
## Harmonising Daytime nap || id:ebi-a-GCST011494 (ebi-a-GCST011494) and Anxiety (yQjjGN)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10772659, rs285815
res <- mr(napping_anx_dat, method_list = methods)
## Analysing 'ebi-a-GCST011494' on 'yQjjGN'
res
## id.exposure id.outcome outcome exposure
## 1 ebi-a-GCST011494 yQjjGN Anxiety Daytime nap || id:ebi-a-GCST011494
## 2 ebi-a-GCST011494 yQjjGN Anxiety Daytime nap || id:ebi-a-GCST011494
## 3 ebi-a-GCST011494 yQjjGN Anxiety Daytime nap || id:ebi-a-GCST011494
## 4 ebi-a-GCST011494 yQjjGN Anxiety Daytime nap || id:ebi-a-GCST011494
## 5 ebi-a-GCST011494 yQjjGN Anxiety Daytime nap || id:ebi-a-GCST011494
## method nsnp b se pval
## 1 Maximum likelihood 90 -0.4043596 0.2287124 0.07706375
## 2 MR Egger 90 1.4804397 0.8968898 0.10237742
## 3 Weighted mode 90 0.4553197 0.5512982 0.41106675
## 4 Weighted median 90 0.1923638 0.3769085 0.60979035
## 5 Inverse variance weighted 90 -0.4026133 0.2917023 0.16751889
mr_heterogeneity(napping_anx_dat)
## id.exposure id.outcome outcome exposure
## 1 ebi-a-GCST011494 yQjjGN Anxiety Daytime nap || id:ebi-a-GCST011494
## 2 ebi-a-GCST011494 yQjjGN Anxiety Daytime nap || id:ebi-a-GCST011494
## method Q Q_df Q_pval
## 1 MR Egger 143.6378 88 1.674983e-04
## 2 Inverse variance weighted 151.6441 89 3.934863e-05
mr_pleiotropy_test(napping_anx_dat)
## id.exposure id.outcome outcome exposure
## 1 ebi-a-GCST011494 yQjjGN Anxiety Daytime nap || id:ebi-a-GCST011494
## egger_intercept se pval
## 1 -0.02025789 0.009146819 0.02936042
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = napping_anx_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, napping_anx_dat)
p1
## $`ebi-a-GCST011494.yQjjGN`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 ebi-a-GCST011494 yQjjGN
res_single <- mr_singlesnp(napping_anx_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome
## 1 Daytime nap || id:ebi-a-GCST011494 Anxiety ebi-a-GCST011494 yQjjGN
## 2 Daytime nap || id:ebi-a-GCST011494 Anxiety ebi-a-GCST011494 yQjjGN
## 3 Daytime nap || id:ebi-a-GCST011494 Anxiety ebi-a-GCST011494 yQjjGN
## samplesize SNP b se p
## 1 117893.2 rs11682175 -12.537933 3.105503 5.406346e-05
## 2 117893.2 rs2431108 -7.461422 1.653189 6.381124e-06
## 3 117893.2 rs3799380 -7.557599 2.529430 2.809325e-03
scz_out_dat <- extract_outcome_data(snps = napping_exp_dat$SNP, outcomes = scz)
## Extracting data for 107 SNP(s) from 1 GWAS(s)
## Finding proxies for 17 SNPs in outcome ieu-b-42
## Extracting data for 17 SNP(s) from 1 GWAS(s)
napping_scz_dat <- harmonise_data(napping_exp_dat, scz_out_dat)
## Harmonising Daytime nap || id:ebi-a-GCST011494 (ebi-a-GCST011494) and schizophrenia || id:ieu-b-42 (ieu-b-42)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10772659, rs285815
res <- mr(napping_scz_dat, method_list = methods)
## Analysing 'ebi-a-GCST011494' on 'ieu-b-42'
res
## id.exposure id.outcome outcome
## 1 ebi-a-GCST011494 ieu-b-42 schizophrenia || id:ieu-b-42
## 2 ebi-a-GCST011494 ieu-b-42 schizophrenia || id:ieu-b-42
## 3 ebi-a-GCST011494 ieu-b-42 schizophrenia || id:ieu-b-42
## 4 ebi-a-GCST011494 ieu-b-42 schizophrenia || id:ieu-b-42
## 5 ebi-a-GCST011494 ieu-b-42 schizophrenia || id:ieu-b-42
## exposure method nsnp b
## 1 Daytime nap || id:ebi-a-GCST011494 Maximum likelihood 98 0.6606529
## 2 Daytime nap || id:ebi-a-GCST011494 MR Egger 98 1.1702932
## 3 Daytime nap || id:ebi-a-GCST011494 Weighted mode 98 1.6401302
## 4 Daytime nap || id:ebi-a-GCST011494 Weighted median 98 0.7711188
## 5 Daytime nap || id:ebi-a-GCST011494 Inverse variance weighted 98 0.6254100
## se pval
## 1 0.1408331 2.718261e-06
## 2 1.0184890 2.533908e-01
## 3 0.6122978 8.683446e-03
## 4 0.2357623 1.072640e-03
## 5 0.2869227 2.927853e-02
mr_heterogeneity(napping_scz_dat)
## id.exposure id.outcome outcome
## 1 ebi-a-GCST011494 ieu-b-42 schizophrenia || id:ieu-b-42
## 2 ebi-a-GCST011494 ieu-b-42 schizophrenia || id:ieu-b-42
## exposure method Q Q_df
## 1 Daytime nap || id:ebi-a-GCST011494 MR Egger 445.8887 96
## 2 Daytime nap || id:ebi-a-GCST011494 Inverse variance weighted 447.3335 97
## Q_pval
## 1 1.703111e-46
## 2 2.087814e-46
mr_pleiotropy_test(napping_scz_dat)
## id.exposure id.outcome outcome
## 1 ebi-a-GCST011494 ieu-b-42 schizophrenia || id:ieu-b-42
## exposure egger_intercept se pval
## 1 Daytime nap || id:ebi-a-GCST011494 -0.005344601 0.009582493 0.5783159
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = napping_scz_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, napping_scz_dat)
p1
## $`ebi-a-GCST011494.ieu-b-42`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 ebi-a-GCST011494 ieu-b-42
res_single <- mr_singlesnp(napping_scz_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome
## 1 Daytime nap || id:ebi-a-GCST011494 schizophrenia || id:ieu-b-42
## 2 Daytime nap || id:ebi-a-GCST011494 schizophrenia || id:ieu-b-42
## 3 Daytime nap || id:ebi-a-GCST011494 schizophrenia || id:ieu-b-42
## 4 Daytime nap || id:ebi-a-GCST011494 schizophrenia || id:ieu-b-42
## 5 Daytime nap || id:ebi-a-GCST011494 schizophrenia || id:ieu-b-42
## 6 Daytime nap || id:ebi-a-GCST011494 schizophrenia || id:ieu-b-42
## 7 Daytime nap || id:ebi-a-GCST011494 schizophrenia || id:ieu-b-42
## 8 Daytime nap || id:ebi-a-GCST011494 schizophrenia || id:ieu-b-42
## 9 Daytime nap || id:ebi-a-GCST011494 schizophrenia || id:ieu-b-42
## 10 Daytime nap || id:ebi-a-GCST011494 schizophrenia || id:ieu-b-42
## 11 Daytime nap || id:ebi-a-GCST011494 schizophrenia || id:ieu-b-42
## 12 Daytime nap || id:ebi-a-GCST011494 schizophrenia || id:ieu-b-42
## 13 Daytime nap || id:ebi-a-GCST011494 schizophrenia || id:ieu-b-42
## 14 Daytime nap || id:ebi-a-GCST011494 schizophrenia || id:ieu-b-42
## 15 Daytime nap || id:ebi-a-GCST011494 schizophrenia || id:ieu-b-42
## 16 Daytime nap || id:ebi-a-GCST011494 schizophrenia || id:ieu-b-42
## 17 Daytime nap || id:ebi-a-GCST011494 schizophrenia || id:ieu-b-42
## 18 Daytime nap || id:ebi-a-GCST011494 schizophrenia || id:ieu-b-42
## id.exposure id.outcome samplesize SNP b
## 1 ebi-a-GCST011494 ieu-b-42 77096 rs11615756 2.5125224
## 2 ebi-a-GCST011494 ieu-b-42 77096 rs11682175 10.5623500
## 3 ebi-a-GCST011494 ieu-b-42 77096 rs12346996 5.8279928
## 4 ebi-a-GCST011494 ieu-b-42 77096 rs13330072 5.5360885
## 5 ebi-a-GCST011494 ieu-b-42 77096 rs1546977 -7.7567481
## 6 ebi-a-GCST011494 ieu-b-42 77096 rs17158413 -5.1457600
## 7 ebi-a-GCST011494 ieu-b-42 77096 rs2033103 -4.8635301
## 8 ebi-a-GCST011494 ieu-b-42 77096 rs2059639 -5.2969786
## 9 ebi-a-GCST011494 ieu-b-42 77096 rs301817 7.5573051
## 10 ebi-a-GCST011494 ieu-b-42 77096 rs3799380 14.1536754
## 11 ebi-a-GCST011494 ieu-b-42 77096 rs385199 2.2523203
## 12 ebi-a-GCST011494 ieu-b-42 77096 rs785145 6.1961110
## 13 ebi-a-GCST011494 ieu-b-42 77096 rs908442 -3.7844543
## 14 ebi-a-GCST011494 ieu-b-42 77096 rs910187 4.9750326
## 15 ebi-a-GCST011494 ieu-b-42 77096 rs962247 4.4581876
## 16 ebi-a-GCST011494 ieu-b-42 77096 All - Maximum likelihood 0.6606529
## 17 ebi-a-GCST011494 ieu-b-42 77096 All - Weighted mode 1.6401302
## 18 ebi-a-GCST011494 ieu-b-42 77096 All - Weighted median 0.7711188
## se p
## 1 0.6076432 3.551636e-05
## 2 1.5664746 1.554140e-11
## 3 1.5575815 1.827843e-04
## 4 1.5674734 4.126558e-04
## 5 1.3289550 5.323613e-09
## 6 1.4053841 2.507805e-04
## 7 1.5019401 1.203012e-03
## 8 1.6311749 1.164894e-03
## 9 1.5114338 5.730353e-07
## 10 1.5951221 7.113830e-19
## 11 0.6933453 1.160222e-03
## 12 1.5596160 7.101955e-05
## 13 1.0799661 4.579224e-04
## 14 1.5442348 1.274408e-03
## 15 1.3687363 1.125346e-03
## 16 0.1408331 2.718261e-06
## 17 0.5620272 4.375186e-03
## 18 0.2409465 1.372497e-03
bip_out_dat <- read_outcome_data(
snps = napping_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/BiP_withNeff.txt.gz",
sep = "\t",
snp_col = "SNP",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
# eaf_col = "MAF",
pval_col = "PVAL"
)
## No phenotype name specified, defaulting to 'outcome'.
bip_out_dat$outcome<- rep('Bipolar Disorder', 1, nrow(bip_out_dat))
napping_bip_dat <- harmonise_data(napping_exp_dat, bip_out_dat)
## Harmonising Daytime nap || id:ebi-a-GCST011494 (ebi-a-GCST011494) and Bipolar Disorder (dBfnrI)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10152428, rs10257273, rs10772659, rs10811438, rs10835420, rs112520848, rs140506252, rs1931175, rs2202323, rs2284015, rs285815, rs908442, rs9389556
res <- mr(napping_bip_dat, method_list = methods)
## Analysing 'ebi-a-GCST011494' on 'dBfnrI'
res
## id.exposure id.outcome outcome
## 1 ebi-a-GCST011494 dBfnrI Bipolar Disorder
## 2 ebi-a-GCST011494 dBfnrI Bipolar Disorder
## 3 ebi-a-GCST011494 dBfnrI Bipolar Disorder
## 4 ebi-a-GCST011494 dBfnrI Bipolar Disorder
## 5 ebi-a-GCST011494 dBfnrI Bipolar Disorder
## exposure method nsnp b
## 1 Daytime nap || id:ebi-a-GCST011494 Maximum likelihood 79 0.7892545
## 2 Daytime nap || id:ebi-a-GCST011494 MR Egger 79 0.0882409
## 3 Daytime nap || id:ebi-a-GCST011494 Weighted mode 79 0.3529897
## 4 Daytime nap || id:ebi-a-GCST011494 Weighted median 79 0.3404890
## 5 Daytime nap || id:ebi-a-GCST011494 Inverse variance weighted 79 0.7265334
## se pval
## 1 0.1337291 3.593567e-09
## 2 0.9140432 9.233433e-01
## 3 0.3944860 3.736421e-01
## 4 0.2354208 1.480932e-01
## 5 0.2555226 4.464565e-03
mr_heterogeneity(napping_bip_dat)
## id.exposure id.outcome outcome
## 1 ebi-a-GCST011494 dBfnrI Bipolar Disorder
## 2 ebi-a-GCST011494 dBfnrI Bipolar Disorder
## exposure method Q Q_df
## 1 Daytime nap || id:ebi-a-GCST011494 MR Egger 312.8314 77
## 2 Daytime nap || id:ebi-a-GCST011494 Inverse variance weighted 314.9816 78
## Q_pval
## 1 3.513628e-30
## 2 3.151934e-30
mr_pleiotropy_test(napping_bip_dat)
## id.exposure id.outcome outcome
## 1 ebi-a-GCST011494 dBfnrI Bipolar Disorder
## exposure egger_intercept se pval
## 1 Daytime nap || id:ebi-a-GCST011494 0.006318729 0.008685506 0.4691244
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = napping_bip_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, napping_bip_dat)
p1
## $`ebi-a-GCST011494.dBfnrI`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 ebi-a-GCST011494 dBfnrI
res_single <- mr_singlesnp(napping_bip_dat,all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure
## 1 Daytime nap || id:ebi-a-GCST011494 Bipolar Disorder ebi-a-GCST011494
## 2 Daytime nap || id:ebi-a-GCST011494 Bipolar Disorder ebi-a-GCST011494
## 3 Daytime nap || id:ebi-a-GCST011494 Bipolar Disorder ebi-a-GCST011494
## 4 Daytime nap || id:ebi-a-GCST011494 Bipolar Disorder ebi-a-GCST011494
## 5 Daytime nap || id:ebi-a-GCST011494 Bipolar Disorder ebi-a-GCST011494
## 6 Daytime nap || id:ebi-a-GCST011494 Bipolar Disorder ebi-a-GCST011494
## 7 Daytime nap || id:ebi-a-GCST011494 Bipolar Disorder ebi-a-GCST011494
## 8 Daytime nap || id:ebi-a-GCST011494 Bipolar Disorder ebi-a-GCST011494
## 9 Daytime nap || id:ebi-a-GCST011494 Bipolar Disorder ebi-a-GCST011494
## 10 Daytime nap || id:ebi-a-GCST011494 Bipolar Disorder ebi-a-GCST011494
## 11 Daytime nap || id:ebi-a-GCST011494 Bipolar Disorder ebi-a-GCST011494
## 12 Daytime nap || id:ebi-a-GCST011494 Bipolar Disorder ebi-a-GCST011494
## 13 Daytime nap || id:ebi-a-GCST011494 Bipolar Disorder ebi-a-GCST011494
## 14 Daytime nap || id:ebi-a-GCST011494 Bipolar Disorder ebi-a-GCST011494
## 15 Daytime nap || id:ebi-a-GCST011494 Bipolar Disorder ebi-a-GCST011494
## 16 Daytime nap || id:ebi-a-GCST011494 Bipolar Disorder ebi-a-GCST011494
## id.outcome samplesize SNP b se
## 1 dBfnrI NA rs11682175 4.4411142 1.3365333
## 2 dBfnrI NA rs13330072 6.2061469 1.3146551
## 3 dBfnrI NA rs1546977 -4.2040264 1.1356525
## 4 dBfnrI NA rs17158413 -3.9026940 1.1891712
## 5 dBfnrI NA rs174541 6.6788088 0.9815688
## 6 dBfnrI NA rs224111 4.7098578 1.2023882
## 7 dBfnrI NA rs2431108 3.7816256 0.7702558
## 8 dBfnrI NA rs2699869 5.1616439 1.3862589
## 9 dBfnrI NA rs2786547 4.2629330 1.1237729
## 10 dBfnrI NA rs3799380 8.2231904 1.3704570
## 11 dBfnrI NA rs60920123 3.5085735 1.2307241
## 12 dBfnrI NA rs62189006 4.5389398 1.3394740
## 13 dBfnrI NA rs76824303 4.7725164 1.3731490
## 14 dBfnrI NA rs910187 3.6767545 1.3119163
## 15 dBfnrI NA All - Maximum likelihood 0.7892545 0.1337291
## 16 dBfnrI NA All - Inverse variance weighted 0.7265334 0.2555226
## p
## 1 8.909939e-04
## 2 2.349865e-06
## 3 2.140248e-04
## 4 1.031246e-03
## 5 1.015990e-11
## 6 8.962591e-05
## 7 9.127581e-07
## 8 1.965311e-04
## 9 1.485917e-04
## 10 1.969203e-09
## 11 4.360658e-03
## 12 7.025073e-04
## 13 5.097124e-04
## 14 5.069515e-03
## 15 3.593567e-09
## 16 4.464565e-03
adhd_out_dat <- extract_outcome_data(snps = napping_exp_dat$SNP, outcomes = adhd)
## Extracting data for 107 SNP(s) from 1 GWAS(s)
## Finding proxies for 7 SNPs in outcome ieu-a-1183
## Extracting data for 7 SNP(s) from 1 GWAS(s)
napping_adhd_dat <- harmonise_data(napping_exp_dat, adhd_out_dat)
## Harmonising Daytime nap || id:ebi-a-GCST011494 (ebi-a-GCST011494) and ADHD || id:ieu-a-1183 (ieu-a-1183)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10152428, rs10257273, rs10772659, rs10811438, rs10835420, rs112520848, rs140506252, rs1931175, rs2202323, rs2284015, rs285815, rs7697461, rs908442, rs9389556
res <- mr(napping_adhd_dat, method_list = methods)
## Analysing 'ebi-a-GCST011494' on 'ieu-a-1183'
res
## id.exposure id.outcome outcome
## 1 ebi-a-GCST011494 ieu-a-1183 ADHD || id:ieu-a-1183
## 2 ebi-a-GCST011494 ieu-a-1183 ADHD || id:ieu-a-1183
## 3 ebi-a-GCST011494 ieu-a-1183 ADHD || id:ieu-a-1183
## 4 ebi-a-GCST011494 ieu-a-1183 ADHD || id:ieu-a-1183
## 5 ebi-a-GCST011494 ieu-a-1183 ADHD || id:ieu-a-1183
## exposure method nsnp b
## 1 Daytime nap || id:ebi-a-GCST011494 Maximum likelihood 87 0.47489227
## 2 Daytime nap || id:ebi-a-GCST011494 MR Egger 87 -0.04856105
## 3 Daytime nap || id:ebi-a-GCST011494 Weighted mode 87 1.22611543
## 4 Daytime nap || id:ebi-a-GCST011494 Weighted median 87 0.40332724
## 5 Daytime nap || id:ebi-a-GCST011494 Inverse variance weighted 87 0.46542655
## se pval
## 1 0.1743429 0.006451639
## 2 0.8842223 0.956331476
## 3 0.8373354 0.146756279
## 4 0.2825471 0.153444716
## 5 0.2606321 0.074137993
mr_heterogeneity(napping_adhd_dat)
## id.exposure id.outcome outcome
## 1 ebi-a-GCST011494 ieu-a-1183 ADHD || id:ieu-a-1183
## 2 ebi-a-GCST011494 ieu-a-1183 ADHD || id:ieu-a-1183
## exposure method Q Q_df
## 1 Daytime nap || id:ebi-a-GCST011494 MR Egger 201.1296 85
## 2 Daytime nap || id:ebi-a-GCST011494 Inverse variance weighted 202.0059 86
## Q_pval
## 1 2.080905e-11
## 2 2.499515e-11
mr_pleiotropy_test(napping_adhd_dat)
## id.exposure id.outcome outcome
## 1 ebi-a-GCST011494 ieu-a-1183 ADHD || id:ieu-a-1183
## exposure egger_intercept se pval
## 1 Daytime nap || id:ebi-a-GCST011494 0.005147602 0.00845911 0.5444604
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = napping_adhd_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, napping_adhd_dat)
p1
## $`ebi-a-GCST011494.ieu-a-1183`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 ebi-a-GCST011494 ieu-a-1183
res_single <- mr_singlesnp(napping_adhd_dat,all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure
## 1 Daytime nap || id:ebi-a-GCST011494 ADHD || id:ieu-a-1183 ebi-a-GCST011494
## 2 Daytime nap || id:ebi-a-GCST011494 ADHD || id:ieu-a-1183 ebi-a-GCST011494
## 3 Daytime nap || id:ebi-a-GCST011494 ADHD || id:ieu-a-1183 ebi-a-GCST011494
## 4 Daytime nap || id:ebi-a-GCST011494 ADHD || id:ieu-a-1183 ebi-a-GCST011494
## 5 Daytime nap || id:ebi-a-GCST011494 ADHD || id:ieu-a-1183 ebi-a-GCST011494
## id.outcome samplesize SNP b se p
## 1 ieu-a-1183 55374 rs10149986 -5.357182 1.535874 4.865831e-04
## 2 ieu-a-1183 55374 rs10875606 6.873189 1.965550 4.708260e-04
## 3 ieu-a-1183 55374 rs2431108 5.569096 1.093763 3.548989e-07
## 4 ieu-a-1183 55374 rs295278 5.381567 1.700931 1.556727e-03
## 5 ieu-a-1183 55374 rs6452787 8.137816 1.720723 2.252944e-06
# dpw<- fread("/Users/claire/Desktop/Desktop/sleepMR/DrinksPerWeek.txt.gz", header=T, data.table=F)
drinkspw_out_dat <- read_outcome_data(
snps = napping_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/DrinksPerWeek.txt.gz",
sep = "\t",
snp_col = "RSID",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "REF",
other_allele_col = "ALT",
eaf_col = "AF",
pval_col = "PVALUE"
)
## No phenotype name specified, defaulting to 'outcome'.
drinkspw_out_dat$outcome<- rep('Drinks per Week', 1, nrow(drinkspw_out_dat))
napping_dpw_dat <- harmonise_data(napping_exp_dat, drinkspw_out_dat)
## Harmonising Daytime nap || id:ebi-a-GCST011494 (ebi-a-GCST011494) and Drinks per Week (Ncmq7v)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10772659, rs285815
res <- mr(napping_dpw_dat, method_list = methods)
## Analysing 'ebi-a-GCST011494' on 'Ncmq7v'
res
## id.exposure id.outcome outcome
## 1 ebi-a-GCST011494 Ncmq7v Drinks per Week
## 2 ebi-a-GCST011494 Ncmq7v Drinks per Week
## 3 ebi-a-GCST011494 Ncmq7v Drinks per Week
## 4 ebi-a-GCST011494 Ncmq7v Drinks per Week
## 5 ebi-a-GCST011494 Ncmq7v Drinks per Week
## exposure method nsnp b
## 1 Daytime nap || id:ebi-a-GCST011494 Maximum likelihood 89 0.06463228
## 2 Daytime nap || id:ebi-a-GCST011494 MR Egger 89 0.04578923
## 3 Daytime nap || id:ebi-a-GCST011494 Weighted mode 89 0.09418118
## 4 Daytime nap || id:ebi-a-GCST011494 Weighted median 89 0.05436387
## 5 Daytime nap || id:ebi-a-GCST011494 Inverse variance weighted 89 0.06360710
## se pval
## 1 0.02586304 0.0124537
## 2 0.17335814 0.7923038
## 3 0.06521266 0.1522292
## 4 0.04225153 0.1982086
## 5 0.04755716 0.1810636
mr_heterogeneity(napping_dpw_dat)
## id.exposure id.outcome outcome
## 1 ebi-a-GCST011494 Ncmq7v Drinks per Week
## 2 ebi-a-GCST011494 Ncmq7v Drinks per Week
## exposure method Q Q_df
## 1 Daytime nap || id:ebi-a-GCST011494 MR Egger 324.3128 87
## 2 Daytime nap || id:ebi-a-GCST011494 Inverse variance weighted 324.3554 88
## Q_pval
## 1 4.636213e-29
## 2 8.873715e-29
mr_pleiotropy_test(napping_dpw_dat)
## id.exposure id.outcome outcome
## 1 ebi-a-GCST011494 Ncmq7v Drinks per Week
## exposure egger_intercept se pval
## 1 Daytime nap || id:ebi-a-GCST011494 0.0001744827 0.001631739 0.9150903
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = napping_dpw_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, napping_dpw_dat)
p1
## $`ebi-a-GCST011494.Ncmq7v`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 ebi-a-GCST011494 Ncmq7v
res_single <- mr_singlesnp(napping_dpw_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure
## 1 Daytime nap || id:ebi-a-GCST011494 Drinks per Week ebi-a-GCST011494
## 2 Daytime nap || id:ebi-a-GCST011494 Drinks per Week ebi-a-GCST011494
## 3 Daytime nap || id:ebi-a-GCST011494 Drinks per Week ebi-a-GCST011494
## 4 Daytime nap || id:ebi-a-GCST011494 Drinks per Week ebi-a-GCST011494
## 5 Daytime nap || id:ebi-a-GCST011494 Drinks per Week ebi-a-GCST011494
## 6 Daytime nap || id:ebi-a-GCST011494 Drinks per Week ebi-a-GCST011494
## 7 Daytime nap || id:ebi-a-GCST011494 Drinks per Week ebi-a-GCST011494
## 8 Daytime nap || id:ebi-a-GCST011494 Drinks per Week ebi-a-GCST011494
## 9 Daytime nap || id:ebi-a-GCST011494 Drinks per Week ebi-a-GCST011494
## 10 Daytime nap || id:ebi-a-GCST011494 Drinks per Week ebi-a-GCST011494
## 11 Daytime nap || id:ebi-a-GCST011494 Drinks per Week ebi-a-GCST011494
## id.outcome samplesize SNP b se p
## 1 Ncmq7v NA rs1001817 1.0987160 0.2488102 1.005997e-05
## 2 Ncmq7v NA rs10257273 1.0251536 0.2516141 4.615102e-05
## 3 Ncmq7v NA rs11682175 -1.1851018 0.2777921 1.988788e-05
## 4 Ncmq7v NA rs13330072 1.2101976 0.2726611 9.060137e-06
## 5 Ncmq7v NA rs17158413 0.8316124 0.2452291 6.959619e-04
## 6 Ncmq7v NA rs17502738 -0.9729396 0.2797005 5.042182e-04
## 7 Ncmq7v NA rs35011311 -1.1618681 0.2412197 1.459973e-06
## 8 Ncmq7v NA rs378421 1.8775928 0.2808327 2.296573e-11
## 9 Ncmq7v NA rs60222088 0.9102278 0.2366025 1.195355e-04
## 10 Ncmq7v NA rs6452787 1.0457821 0.2622664 6.677872e-05
## 11 Ncmq7v NA rs80163246 -0.8901666 0.2538158 4.529583e-04
#cigs<- fread("/Users/claire/Desktop/Desktop/sleepMR/cigs_withNeff.txt.gz", header=T, data.table = F)
cigs_out_dat <- read_outcome_data(
snps = napping_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/cigs_withNeff.txt.gz",
sep = "\t",
snp_col = "RSID",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
eaf_col = "MAF",
pval_col = "PVALUE"
)
## No phenotype name specified, defaulting to 'outcome'.
cigs_out_dat$outcome<- rep('Cigarettes per Day', 1, nrow(cigs_out_dat))
napping_cigs_dat <- harmonise_data(napping_exp_dat, cigs_out_dat)
## Harmonising Daytime nap || id:ebi-a-GCST011494 (ebi-a-GCST011494) and Cigarettes per Day (rAV1Qm)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10772659, rs285815
res <- mr(napping_cigs_dat, method_list = methods)
## Analysing 'ebi-a-GCST011494' on 'rAV1Qm'
res
## id.exposure id.outcome outcome
## 1 ebi-a-GCST011494 rAV1Qm Cigarettes per Day
## 2 ebi-a-GCST011494 rAV1Qm Cigarettes per Day
## 3 ebi-a-GCST011494 rAV1Qm Cigarettes per Day
## 4 ebi-a-GCST011494 rAV1Qm Cigarettes per Day
## 5 ebi-a-GCST011494 rAV1Qm Cigarettes per Day
## exposure method nsnp b
## 1 Daytime nap || id:ebi-a-GCST011494 Maximum likelihood 89 -0.06999463
## 2 Daytime nap || id:ebi-a-GCST011494 MR Egger 89 0.01766753
## 3 Daytime nap || id:ebi-a-GCST011494 Weighted mode 89 0.06021410
## 4 Daytime nap || id:ebi-a-GCST011494 Weighted median 89 -0.07810247
## 5 Daytime nap || id:ebi-a-GCST011494 Inverse variance weighted 89 -0.06979313
## se pval
## 1 0.07257644 0.3348322
## 2 0.38449902 0.9634558
## 3 0.26766930 0.8225342
## 4 0.11472595 0.4960144
## 5 0.10590009 0.5098656
mr_heterogeneity(napping_cigs_dat)
## id.exposure id.outcome outcome
## 1 ebi-a-GCST011494 rAV1Qm Cigarettes per Day
## 2 ebi-a-GCST011494 rAV1Qm Cigarettes per Day
## exposure method Q Q_df
## 1 Daytime nap || id:ebi-a-GCST011494 MR Egger 196.7230 87
## 2 Daytime nap || id:ebi-a-GCST011494 Inverse variance weighted 196.8497 88
## Q_pval
## 1 1.795674e-10
## 2 2.634466e-10
mr_pleiotropy_test(napping_cigs_dat)
## id.exposure id.outcome outcome
## 1 ebi-a-GCST011494 rAV1Qm Cigarettes per Day
## exposure egger_intercept se pval
## 1 Daytime nap || id:ebi-a-GCST011494 -0.0008576968 0.003623199 0.8134277
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = napping_cigs_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, napping_cigs_dat)
p1
## $`ebi-a-GCST011494.rAV1Qm`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 ebi-a-GCST011494 rAV1Qm
res_single <- mr_singlesnp(napping_cigs_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure
## 1 Daytime nap || id:ebi-a-GCST011494 Cigarettes per Day ebi-a-GCST011494
## 2 Daytime nap || id:ebi-a-GCST011494 Cigarettes per Day ebi-a-GCST011494
## 3 Daytime nap || id:ebi-a-GCST011494 Cigarettes per Day ebi-a-GCST011494
## 4 Daytime nap || id:ebi-a-GCST011494 Cigarettes per Day ebi-a-GCST011494
## 5 Daytime nap || id:ebi-a-GCST011494 Cigarettes per Day ebi-a-GCST011494
## id.outcome samplesize SNP b se p
## 1 rAV1Qm NA rs10257273 3.213542 0.7240206 9.060137e-06
## 2 rAV1Qm NA rs174541 1.617484 0.5769375 5.054039e-03
## 3 rAV1Qm NA rs2786547 -1.954629 0.6768326 3.878160e-03
## 4 rAV1Qm NA rs76824303 -2.329573 0.7861928 3.045512e-03
## 5 rAV1Qm NA rs7814873 3.291426 0.7890591 3.028260e-05
alert<- fread("//Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/sleepinessR.txt.gz", header=T, data.table=F)
alert_snps<- fread("/Users/claire/Desktop/sleepGWAS/component/sleepiness/GenomicRiskLoci.txt", header=T, data.table=F)
alert_snps<- alert_snps %>% select(rsID) %>%
rename(SNP=rsID)
alert<- alert %>% right_join(alert_snps)
## Joining with `by = join_by(SNP)`
#head(alert)
alertness_exp_dat <- format_data(alert, type="exposure",
snp_col = "SNP", beta_col = "BETA", se_col = "SE", effect_allele_col = "A1", other_allele_col = "A2", eaf_col = "MAF", pval_col = "P", samplesize_col = "N")
## No phenotype name specified, defaulting to 'exposure'.
alertness_exp_dat$exposure<- rep("Daytime alertness (sleepiness GWAS)", 1, nrow(alertness_exp_dat))
nrow(alertness_exp_dat)
## [1] 37
alertness_exp_dat <- alertness_exp_dat %>% as.data.table
alertness_exp_dat <- alertness_exp_dat[, F_STAT := qf(
pval.exposure,
df1=1,
df2=samplesize.exposure,
lower.tail=F
)] # this piece calculates the F statistic of each SNP in the IV and adds a column called F_STAT
alertness_exp_dat$F_STAT %>% mean # to calculate the overall F stat of your exposure
## [1] 42.43743
alertness_exp_dat$F_STAT %>% min # you can use this to check whether any individual SNPs fall under F of 10 which would make them invalid instruments
## [1] 30.24893
dep_out_dat <- extract_outcome_data(snps = alertness_exp_dat$SNP, outcomes = dep)
## Extracting data for 37 SNP(s) from 1 GWAS(s)
## Finding proxies for 6 SNPs in outcome ieu-b-102
## Extracting data for 6 SNP(s) from 1 GWAS(s)
alertness_exp_dep_dat <- harmonise_data(alertness_exp_dat, dep_out_dat)
## Harmonising Daytime alertness (sleepiness GWAS) (cnvHN8) and Major depression || id:ieu-b-102 (ieu-b-102)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs2048522
res <- mr(alertness_exp_dep_dat, method_list = methods)
## Analysing 'cnvHN8' on 'ieu-b-102'
res
## id.exposure id.outcome outcome
## 1 cnvHN8 ieu-b-102 Major depression || id:ieu-b-102
## 2 cnvHN8 ieu-b-102 Major depression || id:ieu-b-102
## 3 cnvHN8 ieu-b-102 Major depression || id:ieu-b-102
## 4 cnvHN8 ieu-b-102 Major depression || id:ieu-b-102
## 5 cnvHN8 ieu-b-102 Major depression || id:ieu-b-102
## exposure method nsnp b
## 1 Daytime alertness (sleepiness GWAS) Maximum likelihood 34 -0.2143832
## 2 Daytime alertness (sleepiness GWAS) MR Egger 34 0.3457860
## 3 Daytime alertness (sleepiness GWAS) Weighted mode 34 0.3495262
## 4 Daytime alertness (sleepiness GWAS) Weighted median 34 0.1066289
## 5 Daytime alertness (sleepiness GWAS) Inverse variance weighted 34 -0.2064422
## se pval
## 1 0.1138293 0.0596496
## 2 0.8522702 0.6876460
## 3 0.3478466 0.3222909
## 4 0.1926883 0.5800068
## 5 0.1951631 0.2901497
mr_heterogeneity(alertness_exp_dep_dat)
## id.exposure id.outcome outcome
## 1 cnvHN8 ieu-b-102 Major depression || id:ieu-b-102
## 2 cnvHN8 ieu-b-102 Major depression || id:ieu-b-102
## exposure method Q Q_df
## 1 Daytime alertness (sleepiness GWAS) MR Egger 103.2674 32
## 2 Daytime alertness (sleepiness GWAS) Inverse variance weighted 104.6986 33
## Q_pval
## 1 1.985266e-09
## 2 2.191918e-09
mr_pleiotropy_test(alertness_exp_dep_dat)
## id.exposure id.outcome outcome
## 1 cnvHN8 ieu-b-102 Major depression || id:ieu-b-102
## exposure egger_intercept se pval
## 1 Daytime alertness (sleepiness GWAS) -0.004248207 0.00637914 0.5102138
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = alertness_exp_dep_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, alertness_exp_dep_dat)
p1
## $`cnvHN8.ieu-b-102`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 cnvHN8 ieu-b-102
res_single <- mr_singlesnp(alertness_exp_dep_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome
## 1 Daytime alertness (sleepiness GWAS) Major depression || id:ieu-b-102
## 2 Daytime alertness (sleepiness GWAS) Major depression || id:ieu-b-102
## 3 Daytime alertness (sleepiness GWAS) Major depression || id:ieu-b-102
## 4 Daytime alertness (sleepiness GWAS) Major depression || id:ieu-b-102
## 5 Daytime alertness (sleepiness GWAS) Major depression || id:ieu-b-102
## 6 Daytime alertness (sleepiness GWAS) Major depression || id:ieu-b-102
## id.exposure id.outcome samplesize SNP b se p
## 1 cnvHN8 ieu-b-102 NA rs11078398 -1.918982 0.6266065 0.002194965
## 2 cnvHN8 ieu-b-102 NA rs11123962 -1.466872 0.5345380 0.006066115
## 3 cnvHN8 ieu-b-102 NA rs12153518 -1.909630 0.6415162 0.002913270
## 4 cnvHN8 ieu-b-102 NA rs13097760 -2.204574 0.7515595 0.003353436
## 5 cnvHN8 ieu-b-102 NA rs13135092 -2.439426 0.7744209 0.001632705
## 6 cnvHN8 ieu-b-102 NA rs6897863 -2.121676 0.6814141 0.001847971
anx_out_dat <- read_outcome_data(
snps = alertness_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/anxiety_withNeff.txt.gz",
sep = "\t",
snp_col = "SNP",
beta_col = "effect",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
eaf_col = "MAF",
pval_col = "P",
samplesize_col = "Neff"
)
## No phenotype name specified, defaulting to 'outcome'.
anx_out_dat$outcome<- rep('Anxiety', 1, nrow(anx_out_dat))
alertness_anx_dat <- harmonise_data(alertness_exp_dat, anx_out_dat)
## Harmonising Daytime alertness (sleepiness GWAS) (cnvHN8) and Anxiety (cAsCcd)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs2048522
res <- mr(alertness_anx_dat, method_list = methods)
## Analysing 'cnvHN8' on 'cAsCcd'
res
## id.exposure id.outcome outcome exposure
## 1 cnvHN8 cAsCcd Anxiety Daytime alertness (sleepiness GWAS)
## 2 cnvHN8 cAsCcd Anxiety Daytime alertness (sleepiness GWAS)
## 3 cnvHN8 cAsCcd Anxiety Daytime alertness (sleepiness GWAS)
## 4 cnvHN8 cAsCcd Anxiety Daytime alertness (sleepiness GWAS)
## 5 cnvHN8 cAsCcd Anxiety Daytime alertness (sleepiness GWAS)
## method nsnp b se pval
## 1 Maximum likelihood 35 -0.0005525922 0.4668286 0.9990555
## 2 MR Egger 35 -1.7888994624 2.3381242 0.4496492
## 3 Weighted mode 35 -0.3998608998 1.1670497 0.7339895
## 4 Weighted median 35 0.0311386984 0.7312066 0.9660321
## 5 Inverse variance weighted 35 -0.0005525922 0.6313635 0.9993017
mr_heterogeneity(alertness_anx_dat)
## id.exposure id.outcome outcome exposure
## 1 cnvHN8 cAsCcd Anxiety Daytime alertness (sleepiness GWAS)
## 2 cnvHN8 cAsCcd Anxiety Daytime alertness (sleepiness GWAS)
## method Q Q_df Q_pval
## 1 MR Egger 64.05058 33 0.0009524546
## 2 Inverse variance weighted 65.27642 34 0.0009922313
mr_pleiotropy_test(alertness_anx_dat)
## id.exposure id.outcome outcome exposure
## 1 cnvHN8 cAsCcd Anxiety Daytime alertness (sleepiness GWAS)
## egger_intercept se pval
## 1 0.01488859 0.01873449 0.4324575
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = alertness_anx_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, alertness_anx_dat)
p1
## $cnvHN8.cAsCcd
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 cnvHN8 cAsCcd
res_single <- mr_singlesnp(alertness_anx_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome samplesize
## 1 Daytime alertness (sleepiness GWAS) Anxiety cnvHN8 cAsCcd 117893.2
## SNP b se p
## 1 rs960986 -9.459802 2.990866 0.001562072
scz_out_dat <- extract_outcome_data(snps = alertness_exp_dat$SNP, outcomes = scz)
## Extracting data for 37 SNP(s) from 1 GWAS(s)
## Finding proxies for 4 SNPs in outcome ieu-b-42
## Extracting data for 4 SNP(s) from 1 GWAS(s)
alertness_scz_dat <- harmonise_data(alertness_exp_dat, scz_out_dat)
## Harmonising Daytime alertness (sleepiness GWAS) (cnvHN8) and schizophrenia || id:ieu-b-42 (ieu-b-42)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs2048522
res <- mr(alertness_scz_dat, method_list = methods)
## Analysing 'cnvHN8' on 'ieu-b-42'
res
## id.exposure id.outcome outcome
## 1 cnvHN8 ieu-b-42 schizophrenia || id:ieu-b-42
## 2 cnvHN8 ieu-b-42 schizophrenia || id:ieu-b-42
## 3 cnvHN8 ieu-b-42 schizophrenia || id:ieu-b-42
## 4 cnvHN8 ieu-b-42 schizophrenia || id:ieu-b-42
## 5 cnvHN8 ieu-b-42 schizophrenia || id:ieu-b-42
## exposure method nsnp b
## 1 Daytime alertness (sleepiness GWAS) Maximum likelihood 36 -1.0495392
## 2 Daytime alertness (sleepiness GWAS) MR Egger 36 -2.5349475
## 3 Daytime alertness (sleepiness GWAS) Weighted mode 36 -0.8231325
## 4 Daytime alertness (sleepiness GWAS) Weighted median 36 -0.9669964
## 5 Daytime alertness (sleepiness GWAS) Inverse variance weighted 36 -0.9486046
## se pval
## 1 0.2998312 0.0004645018
## 2 3.3670875 0.4567151178
## 3 0.7873540 0.3029858384
## 4 0.4752323 0.0418723396
## 5 0.7346357 0.1966140366
mr_heterogeneity(alertness_scz_dat)
## id.exposure id.outcome outcome
## 1 cnvHN8 ieu-b-42 schizophrenia || id:ieu-b-42
## 2 cnvHN8 ieu-b-42 schizophrenia || id:ieu-b-42
## exposure method Q Q_df
## 1 Daytime alertness (sleepiness GWAS) MR Egger 253.7380 34
## 2 Daytime alertness (sleepiness GWAS) Inverse variance weighted 255.4792 35
## Q_pval
## 1 1.961347e-35
## 2 2.538679e-35
mr_pleiotropy_test(alertness_scz_dat)
## id.exposure id.outcome outcome
## 1 cnvHN8 ieu-b-42 schizophrenia || id:ieu-b-42
## exposure egger_intercept se pval
## 1 Daytime alertness (sleepiness GWAS) 0.01212658 0.02510506 0.6321682
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = alertness_scz_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, alertness_scz_dat)
p1
## $`cnvHN8.ieu-b-42`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 cnvHN8 ieu-b-42
res_single <- mr_singlesnp(alertness_scz_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure
## 1 Daytime alertness (sleepiness GWAS) schizophrenia || id:ieu-b-42 cnvHN8
## 2 Daytime alertness (sleepiness GWAS) schizophrenia || id:ieu-b-42 cnvHN8
## 3 Daytime alertness (sleepiness GWAS) schizophrenia || id:ieu-b-42 cnvHN8
## 4 Daytime alertness (sleepiness GWAS) schizophrenia || id:ieu-b-42 cnvHN8
## 5 Daytime alertness (sleepiness GWAS) schizophrenia || id:ieu-b-42 cnvHN8
## 6 Daytime alertness (sleepiness GWAS) schizophrenia || id:ieu-b-42 cnvHN8
## 7 Daytime alertness (sleepiness GWAS) schizophrenia || id:ieu-b-42 cnvHN8
## 8 Daytime alertness (sleepiness GWAS) schizophrenia || id:ieu-b-42 cnvHN8
## 9 Daytime alertness (sleepiness GWAS) schizophrenia || id:ieu-b-42 cnvHN8
## 10 Daytime alertness (sleepiness GWAS) schizophrenia || id:ieu-b-42 cnvHN8
## 11 Daytime alertness (sleepiness GWAS) schizophrenia || id:ieu-b-42 cnvHN8
## 12 Daytime alertness (sleepiness GWAS) schizophrenia || id:ieu-b-42 cnvHN8
## id.outcome samplesize SNP b se
## 1 ieu-b-42 77096 rs11078398 7.219290 1.5665162
## 2 ieu-b-42 77096 rs13010456 5.141434 1.4338455
## 3 ieu-b-42 77096 rs13135092 -14.007531 2.0134943
## 4 ieu-b-42 77096 rs17356118 6.047999 1.6850432
## 5 ieu-b-42 77096 rs1846644 -3.989661 0.9775774
## 6 ieu-b-42 77096 rs62066119 -5.870246 1.7922764
## 7 ieu-b-42 77096 rs62519825 5.453932 1.8039116
## 8 ieu-b-42 77096 rs6923811 -12.400941 1.7567791
## 9 ieu-b-42 77096 rs7607363 -7.385798 1.8425071
## 10 ieu-b-42 77096 rs7837226 -7.261743 1.8808745
## 11 ieu-b-42 77096 rs9712275 9.159847 1.8524656
## 12 ieu-b-42 77096 All - Maximum likelihood -1.049539 0.2998312
## p
## 1 4.055844e-06
## 2 3.360905e-04
## 3 3.480221e-12
## 4 3.316627e-04
## 5 4.480934e-05
## 6 1.055491e-03
## 7 2.499584e-03
## 8 1.678167e-12
## 9 6.109049e-05
## 10 1.130010e-04
## 11 7.626947e-07
## 12 4.645018e-04
bip_out_dat <- read_outcome_data(
snps = alertness_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/BiP_withNeff.txt.gz",
sep = "\t",
snp_col = "SNP",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
# eaf_col = "MAF",
pval_col = "PVAL"
)
## No phenotype name specified, defaulting to 'outcome'.
bip_out_dat$outcome<- rep('Bipolar Disorder', 1, nrow(bip_out_dat))
alertness_bip_dat <- harmonise_data(alertness_exp_dat, bip_out_dat)
## Harmonising Daytime alertness (sleepiness GWAS) (cnvHN8) and Bipolar Disorder (SpwgWY)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs17131124, rs2048522, rs4765939
res <- mr(alertness_bip_dat, method_list = methods)
## Analysing 'cnvHN8' on 'SpwgWY'
res
## id.exposure id.outcome outcome exposure
## 1 cnvHN8 SpwgWY Bipolar Disorder Daytime alertness (sleepiness GWAS)
## 2 cnvHN8 SpwgWY Bipolar Disorder Daytime alertness (sleepiness GWAS)
## 3 cnvHN8 SpwgWY Bipolar Disorder Daytime alertness (sleepiness GWAS)
## 4 cnvHN8 SpwgWY Bipolar Disorder Daytime alertness (sleepiness GWAS)
## 5 cnvHN8 SpwgWY Bipolar Disorder Daytime alertness (sleepiness GWAS)
## method nsnp b se pval
## 1 Maximum likelihood 33 -0.22616993 0.2544399 0.3740603
## 2 MR Egger 33 -1.56972981 2.1488619 0.4705737
## 3 Weighted mode 33 0.49992903 0.7454363 0.5072536
## 4 Weighted median 33 -0.04496497 0.4261834 0.9159742
## 5 Inverse variance weighted 33 -0.20707404 0.4864080 0.6703112
mr_heterogeneity(alertness_bip_dat)
## id.exposure id.outcome outcome exposure
## 1 cnvHN8 SpwgWY Bipolar Disorder Daytime alertness (sleepiness GWAS)
## 2 cnvHN8 SpwgWY Bipolar Disorder Daytime alertness (sleepiness GWAS)
## method Q Q_df Q_pval
## 1 MR Egger 126.9101 31 1.455194e-13
## 2 Inverse variance weighted 128.6470 32 1.536338e-13
mr_pleiotropy_test(alertness_bip_dat)
## id.exposure id.outcome outcome exposure
## 1 cnvHN8 SpwgWY Bipolar Disorder Daytime alertness (sleepiness GWAS)
## egger_intercept se pval
## 1 0.01044166 0.01603082 0.519621
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = alertness_bip_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, alertness_bip_dat)
p1
## $cnvHN8.SpwgWY
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 cnvHN8 SpwgWY
res_single <- mr_singlesnp(alertness_bip_dat,all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome
## 1 Daytime alertness (sleepiness GWAS) Bipolar Disorder cnvHN8 SpwgWY
## 2 Daytime alertness (sleepiness GWAS) Bipolar Disorder cnvHN8 SpwgWY
## 3 Daytime alertness (sleepiness GWAS) Bipolar Disorder cnvHN8 SpwgWY
## 4 Daytime alertness (sleepiness GWAS) Bipolar Disorder cnvHN8 SpwgWY
## 5 Daytime alertness (sleepiness GWAS) Bipolar Disorder cnvHN8 SpwgWY
## 6 Daytime alertness (sleepiness GWAS) Bipolar Disorder cnvHN8 SpwgWY
## 7 Daytime alertness (sleepiness GWAS) Bipolar Disorder cnvHN8 SpwgWY
## samplesize SNP b se p
## 1 NA rs11123962 -4.698381 1.168525 5.800582e-05
## 2 NA rs17356118 4.989944 1.502170 8.943146e-04
## 3 NA rs4665972 -5.328640 1.479357 3.157816e-04
## 4 NA rs6923811 -4.488365 1.520574 3.159706e-03
## 5 NA rs811483 -5.537321 1.580337 4.585209e-04
## 6 NA rs843372 5.732482 1.371930 2.935590e-05
## 7 NA rs886114 5.460816 1.621770 7.593697e-04
adhd_out_dat <- extract_outcome_data(snps = alertness_exp_dat$SNP, outcomes = adhd)
## Extracting data for 37 SNP(s) from 1 GWAS(s)
## Finding proxies for 1 SNPs in outcome ieu-a-1183
## Extracting data for 1 SNP(s) from 1 GWAS(s)
alertness_adhd_dat <- harmonise_data(alertness_exp_dat, adhd_out_dat)
## Harmonising Daytime alertness (sleepiness GWAS) (cnvHN8) and ADHD || id:ieu-a-1183 (ieu-a-1183)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs17131124, rs2048522, rs4765939
res <- mr(alertness_adhd_dat, method_list = methods)
## Analysing 'cnvHN8' on 'ieu-a-1183'
res
## id.exposure id.outcome outcome
## 1 cnvHN8 ieu-a-1183 ADHD || id:ieu-a-1183
## 2 cnvHN8 ieu-a-1183 ADHD || id:ieu-a-1183
## 3 cnvHN8 ieu-a-1183 ADHD || id:ieu-a-1183
## 4 cnvHN8 ieu-a-1183 ADHD || id:ieu-a-1183
## 5 cnvHN8 ieu-a-1183 ADHD || id:ieu-a-1183
## exposure method nsnp b
## 1 Daytime alertness (sleepiness GWAS) Maximum likelihood 33 -0.1103361
## 2 Daytime alertness (sleepiness GWAS) MR Egger 33 -3.5064150
## 3 Daytime alertness (sleepiness GWAS) Weighted mode 33 1.0592488
## 4 Daytime alertness (sleepiness GWAS) Weighted median 33 0.5135449
## 5 Daytime alertness (sleepiness GWAS) Inverse variance weighted 33 -0.1082611
## se pval
## 1 0.3515482 0.7536292
## 2 2.0991664 0.1049114
## 3 1.1239832 0.3530456
## 4 0.5536780 0.3536590
## 5 0.4964835 0.8273856
mr_heterogeneity(alertness_adhd_dat)
## id.exposure id.outcome outcome
## 1 cnvHN8 ieu-a-1183 ADHD || id:ieu-a-1183
## 2 cnvHN8 ieu-a-1183 ADHD || id:ieu-a-1183
## exposure method Q Q_df
## 1 Daytime alertness (sleepiness GWAS) MR Egger 61.53700 31
## 2 Daytime alertness (sleepiness GWAS) Inverse variance weighted 67.03016 32
## Q_pval
## 1 0.0008860753
## 2 0.0002808491
mr_pleiotropy_test(alertness_adhd_dat)
## id.exposure id.outcome outcome
## 1 cnvHN8 ieu-a-1183 ADHD || id:ieu-a-1183
## exposure egger_intercept se pval
## 1 Daytime alertness (sleepiness GWAS) 0.02606482 0.01566863 0.1062904
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = alertness_adhd_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, alertness_adhd_dat)
p1
## $`cnvHN8.ieu-a-1183`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 cnvHN8 ieu-a-1183
res_single <- mr_singlesnp(alertness_adhd_dat,all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure
## 1 Daytime alertness (sleepiness GWAS) ADHD || id:ieu-a-1183 cnvHN8
## 2 Daytime alertness (sleepiness GWAS) ADHD || id:ieu-a-1183 cnvHN8
## id.outcome samplesize SNP b se p
## 1 ieu-a-1183 55374 rs1566362 6.929697 2.215214 0.001758634
## 2 ieu-a-1183 55374 rs6897863 -6.520080 2.059729 0.001548147
# dpw<- fread("/Users/claire/Desktop/Desktop/sleepMR/DrinksPerWeek.txt.gz", header=T, data.table=F)
drinkspw_out_dat <- read_outcome_data(
snps = alertness_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/DrinksPerWeek.txt.gz",
sep = "\t",
snp_col = "RSID",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "REF",
other_allele_col = "ALT",
eaf_col = "AF",
pval_col = "PVALUE"
)
## No phenotype name specified, defaulting to 'outcome'.
drinkspw_out_dat$outcome<- rep('Drinks per Week', 1, nrow(drinkspw_out_dat))
alertness_dpw_dat <- harmonise_data(alertness_exp_dat, drinkspw_out_dat)
## Harmonising Daytime alertness (sleepiness GWAS) (cnvHN8) and Drinks per Week (Tez5vW)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs2048522
res <- mr(alertness_dpw_dat, method_list = methods)
## Analysing 'cnvHN8' on 'Tez5vW'
res
## id.exposure id.outcome outcome exposure
## 1 cnvHN8 Tez5vW Drinks per Week Daytime alertness (sleepiness GWAS)
## 2 cnvHN8 Tez5vW Drinks per Week Daytime alertness (sleepiness GWAS)
## 3 cnvHN8 Tez5vW Drinks per Week Daytime alertness (sleepiness GWAS)
## 4 cnvHN8 Tez5vW Drinks per Week Daytime alertness (sleepiness GWAS)
## 5 cnvHN8 Tez5vW Drinks per Week Daytime alertness (sleepiness GWAS)
## method nsnp b se pval
## 1 Maximum likelihood 35 -0.21287040 0.05382038 7.647048e-05
## 2 MR Egger 35 -0.30391314 0.60545750 6.190312e-01
## 3 Weighted mode 35 -0.09639688 0.14871390 5.212072e-01
## 4 Weighted median 35 -0.06395745 0.07814544 4.131053e-01
## 5 Inverse variance weighted 35 -0.21935834 0.13837263 1.129044e-01
mr_heterogeneity(alertness_dpw_dat)
## id.exposure id.outcome outcome exposure
## 1 cnvHN8 Tez5vW Drinks per Week Daytime alertness (sleepiness GWAS)
## 2 cnvHN8 Tez5vW Drinks per Week Daytime alertness (sleepiness GWAS)
## method Q Q_df Q_pval
## 1 MR Egger 277.5268 33 1.891978e-40
## 2 Inverse variance weighted 277.7002 34 5.140576e-40
mr_pleiotropy_test(alertness_dpw_dat)
## id.exposure id.outcome outcome exposure
## 1 cnvHN8 Tez5vW Drinks per Week Daytime alertness (sleepiness GWAS)
## egger_intercept se pval
## 1 0.0006503558 0.004529938 0.8867145
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = alertness_dpw_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, alertness_dpw_dat)
p1
## $cnvHN8.Tez5vW
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 cnvHN8 Tez5vW
res_single <- mr_singlesnp(alertness_dpw_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome
## 1 Daytime alertness (sleepiness GWAS) Drinks per Week cnvHN8 Tez5vW
## 2 Daytime alertness (sleepiness GWAS) Drinks per Week cnvHN8 Tez5vW
## 3 Daytime alertness (sleepiness GWAS) Drinks per Week cnvHN8 Tez5vW
## 4 Daytime alertness (sleepiness GWAS) Drinks per Week cnvHN8 Tez5vW
## 5 Daytime alertness (sleepiness GWAS) Drinks per Week cnvHN8 Tez5vW
## 6 Daytime alertness (sleepiness GWAS) Drinks per Week cnvHN8 Tez5vW
## samplesize SNP b se p
## 1 NA rs13135092 -3.2366957 0.35941107 2.145800e-19
## 2 NA rs17356118 -0.9358839 0.29895716 1.745119e-03
## 3 NA rs4665972 -3.3675493 0.29882168 1.857735e-29
## 4 NA rs843372 -0.8997467 0.28035070 1.330302e-03
## 5 NA rs960986 1.0924838 0.28114251 1.019633e-04
## 6 NA All - Maximum likelihood -0.2128704 0.05382038 7.647048e-05
#cigs<- fread("/Users/claire/Desktop/Desktop/sleepMR/cigs_withNeff.txt.gz", header=T, data.table = F)
cigs_out_dat <- read_outcome_data(
snps = alertness_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/cigs_withNeff.txt.gz",
sep = "\t",
snp_col = "RSID",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
eaf_col = "MAF",
pval_col = "PVALUE"
)
## No phenotype name specified, defaulting to 'outcome'.
cigs_out_dat$outcome<- rep('Cigarettes per Day', 1, nrow(cigs_out_dat))
alertness_cigs_dat <- harmonise_data(alertness_exp_dat, cigs_out_dat)
## Harmonising Daytime alertness (sleepiness GWAS) (cnvHN8) and Cigarettes per Day (ev60bZ)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs2048522
res <- mr(alertness_cigs_dat, method_list = methods)
## Analysing 'cnvHN8' on 'ev60bZ'
res
## id.exposure id.outcome outcome exposure
## 1 cnvHN8 ev60bZ Cigarettes per Day Daytime alertness (sleepiness GWAS)
## 2 cnvHN8 ev60bZ Cigarettes per Day Daytime alertness (sleepiness GWAS)
## 3 cnvHN8 ev60bZ Cigarettes per Day Daytime alertness (sleepiness GWAS)
## 4 cnvHN8 ev60bZ Cigarettes per Day Daytime alertness (sleepiness GWAS)
## 5 cnvHN8 ev60bZ Cigarettes per Day Daytime alertness (sleepiness GWAS)
## method nsnp b se pval
## 1 Maximum likelihood 35 0.1916078 0.1426387 0.1791720
## 2 MR Egger 35 0.1349812 0.8679723 0.8773641
## 3 Weighted mode 35 0.2086563 0.4794213 0.6661493
## 4 Weighted median 35 0.2071411 0.2165401 0.3387720
## 5 Inverse variance weighted 35 0.1842004 0.1990891 0.3548537
mr_heterogeneity(alertness_cigs_dat)
## id.exposure id.outcome outcome exposure
## 1 cnvHN8 ev60bZ Cigarettes per Day Daytime alertness (sleepiness GWAS)
## 2 cnvHN8 ev60bZ Cigarettes per Day Daytime alertness (sleepiness GWAS)
## method Q Q_df Q_pval
## 1 MR Egger 69.63263 33 0.0002007069
## 2 Inverse variance weighted 69.63981 34 0.0003001300
mr_pleiotropy_test(alertness_cigs_dat)
## id.exposure id.outcome outcome exposure
## 1 cnvHN8 ev60bZ Cigarettes per Day Daytime alertness (sleepiness GWAS)
## egger_intercept se pval
## 1 0.0003781791 0.006485875 0.9538549
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = alertness_cigs_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, alertness_cigs_dat)
p1
## $cnvHN8.ev60bZ
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 cnvHN8 ev60bZ
res_single <- mr_singlesnp(alertness_cigs_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome
## 1 Daytime alertness (sleepiness GWAS) Cigarettes per Day cnvHN8 ev60bZ
## 2 Daytime alertness (sleepiness GWAS) Cigarettes per Day cnvHN8 ev60bZ
## 3 Daytime alertness (sleepiness GWAS) Cigarettes per Day cnvHN8 ev60bZ
## samplesize SNP b se p
## 1 NA rs1566362 -2.665440 0.9026320 0.003147380
## 2 NA rs811483 2.786545 0.9563396 0.003571038
## 3 NA rs960986 -2.535893 0.8031254 0.001591115
## exposure data
alert_full<- fread("/Users/claire/Desktop/sleepGWAS/sleep_rr_upd/alertness_gsem.txt.gz", header=T, data.table = F)
alert<- fread("/Users/claire/Desktop///sleepGWAS/FUMA_out/alertness///GenomicRiskLoci.txt", header=T, data.table=F)
alert<- alert %>% select(rsID) %>%
rename(SNP=rsID)
alert_full<- alert_full %>% right_join(alert)
## Joining with `by = join_by(SNP)`
alertness_exp_dat <- format_data(alert_full, type="exposure",
snp_col = "SNP", beta_col = "est", se_col = "SE", effect_allele_col = "A1", other_allele_col = "A2", eaf_col = "MAF", pval_col = "Pval_Estimate")
## No phenotype name specified, defaulting to 'exposure'.
alertness_exp_dat$exposure<- rep("Alertness Factor", 1, nrow(alertness_exp_dat))
nrow(alertness_exp_dat)
## [1] 85
alertness_exp_dat$samplesize.exposure<- 1043563
alertness_exp_dat <- alertness_exp_dat %>% as.data.table
alertness_exp_dat <- alertness_exp_dat[, F_STAT := qf(
pval.exposure,
df1=1,
df2=samplesize.exposure,
lower.tail=F
)] # this piece calculates the F statistic of each SNP in the IV and adds a column called F_STAT
alertness_exp_dat$F_STAT %>% mean # to calculate the overall F stat of your exposure
## [1] 43.94361
alertness_exp_dat$F_STAT %>% min # you can use this to check whether any individual SNPs fall under F of 10 which would make them invalid instrume
## [1] 29.89063
dep_out_dat <- extract_outcome_data(snps = alertness_exp_dat$SNP, outcomes = dep)
## Extracting data for 85 SNP(s) from 1 GWAS(s)
## Finding proxies for 6 SNPs in outcome ieu-b-102
## Extracting data for 6 SNP(s) from 1 GWAS(s)
alertness_exp_dep_dat <- harmonise_data(alertness_exp_dat, dep_out_dat)
## Harmonising Alertness Factor (EmiO5k) and Major depression || id:ieu-b-102 (ieu-b-102)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs1843815, rs2916622
res <- mr(alertness_exp_dep_dat, method_list = methods)
## Analysing 'EmiO5k' on 'ieu-b-102'
res
## id.exposure id.outcome outcome exposure
## 1 EmiO5k ieu-b-102 Major depression || id:ieu-b-102 Alertness Factor
## 2 EmiO5k ieu-b-102 Major depression || id:ieu-b-102 Alertness Factor
## 3 EmiO5k ieu-b-102 Major depression || id:ieu-b-102 Alertness Factor
## 4 EmiO5k ieu-b-102 Major depression || id:ieu-b-102 Alertness Factor
## 5 EmiO5k ieu-b-102 Major depression || id:ieu-b-102 Alertness Factor
## method nsnp b se pval
## 1 Maximum likelihood 83 -0.935898676 0.1823602 2.864616e-07
## 2 MR Egger 83 -0.005294415 1.1081705 9.961998e-01
## 3 Weighted mode 83 0.141298714 0.4150467 7.343954e-01
## 4 Weighted median 83 -0.168387776 0.3051927 5.811248e-01
## 5 Inverse variance weighted 83 -0.927808079 0.3175116 3.476541e-03
mr_heterogeneity(alertness_exp_dep_dat)
## id.exposure id.outcome outcome exposure
## 1 EmiO5k ieu-b-102 Major depression || id:ieu-b-102 Alertness Factor
## 2 EmiO5k ieu-b-102 Major depression || id:ieu-b-102 Alertness Factor
## method Q Q_df Q_pval
## 1 MR Egger 267.5930 81 8.478342e-22
## 2 Inverse variance weighted 270.0878 82 6.444951e-22
mr_pleiotropy_test(alertness_exp_dep_dat)
## id.exposure id.outcome outcome exposure
## 1 EmiO5k ieu-b-102 Major depression || id:ieu-b-102 Alertness Factor
## egger_intercept se pval
## 1 -0.002925724 0.00336673 0.3874091
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = alertness_exp_dep_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, alertness_exp_dep_dat)
p1
## $`EmiO5k.ieu-b-102`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 EmiO5k ieu-b-102
res_single <- mr_singlesnp(alertness_exp_dep_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome
## 1 Alertness Factor Major depression || id:ieu-b-102 EmiO5k ieu-b-102
## 2 Alertness Factor Major depression || id:ieu-b-102 EmiO5k ieu-b-102
## 3 Alertness Factor Major depression || id:ieu-b-102 EmiO5k ieu-b-102
## 4 Alertness Factor Major depression || id:ieu-b-102 EmiO5k ieu-b-102
## 5 Alertness Factor Major depression || id:ieu-b-102 EmiO5k ieu-b-102
## 6 Alertness Factor Major depression || id:ieu-b-102 EmiO5k ieu-b-102
## 7 Alertness Factor Major depression || id:ieu-b-102 EmiO5k ieu-b-102
## 8 Alertness Factor Major depression || id:ieu-b-102 EmiO5k ieu-b-102
## 9 Alertness Factor Major depression || id:ieu-b-102 EmiO5k ieu-b-102
## 10 Alertness Factor Major depression || id:ieu-b-102 EmiO5k ieu-b-102
## 11 Alertness Factor Major depression || id:ieu-b-102 EmiO5k ieu-b-102
## 12 Alertness Factor Major depression || id:ieu-b-102 EmiO5k ieu-b-102
## 13 Alertness Factor Major depression || id:ieu-b-102 EmiO5k ieu-b-102
## 14 Alertness Factor Major depression || id:ieu-b-102 EmiO5k ieu-b-102
## samplesize SNP b se
## 1 NA rs10514370 -7.7175110 1.7539798
## 2 NA rs11649804 -5.2112359 1.7867094
## 3 NA rs13097760 -5.0592705 1.7247513
## 4 NA rs1372100 -6.1702440 1.6638860
## 5 NA rs174541 -6.1312572 1.9849394
## 6 NA rs224111 -6.1425322 1.5898319
## 7 NA rs2370926 5.7753632 1.9109658
## 8 NA rs2431108 -10.2391629 1.3193319
## 9 NA rs28436846 -5.2898531 1.8919913
## 10 NA rs73209076 -7.2551493 1.9072815
## 11 NA rs75932578 6.1227649 1.9889236
## 12 NA rs9389556 5.4458785 1.6472102
## 13 NA All - Maximum likelihood -0.9358987 0.1823602
## 14 NA All - Inverse variance weighted -0.9278081 0.3175116
## p
## 1 1.082509e-05
## 2 3.537936e-03
## 3 3.353436e-03
## 4 2.086279e-04
## 5 2.009066e-03
## 6 1.117115e-04
## 7 2.509263e-03
## 8 8.434903e-15
## 9 5.175247e-03
## 10 1.424233e-04
## 11 2.080935e-03
## 12 9.459674e-04
## 13 2.864616e-07
## 14 3.476541e-03
anx_out_dat <- read_outcome_data(
snps = alertness_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/anxiety_withNeff.txt.gz",
sep = "\t",
snp_col = "SNP",
beta_col = "effect",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
eaf_col = "MAF",
pval_col = "P",
samplesize_col = "Neff"
)
## No phenotype name specified, defaulting to 'outcome'.
anx_out_dat$outcome<- rep('Anxiety', 1, nrow(anx_out_dat))
alertness_anx_dat <- harmonise_data(alertness_exp_dat, anx_out_dat)
## Harmonising Alertness Factor (EmiO5k) and Anxiety (P7hL23)
## Removing the following SNPs for incompatible alleles:
## rs62271411
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs1843815, rs2916622
res <- mr(alertness_anx_dat, method_list = methods)
## Analysing 'EmiO5k' on 'P7hL23'
res
## id.exposure id.outcome outcome exposure method
## 1 EmiO5k P7hL23 Anxiety Alertness Factor Maximum likelihood
## 2 EmiO5k P7hL23 Anxiety Alertness Factor MR Egger
## 3 EmiO5k P7hL23 Anxiety Alertness Factor Weighted mode
## 4 EmiO5k P7hL23 Anxiety Alertness Factor Weighted median
## 5 EmiO5k P7hL23 Anxiety Alertness Factor Inverse variance weighted
## nsnp b se pval
## 1 82 1.0787578 0.7499414 0.1503047
## 2 82 -3.2475578 2.8052696 0.2504461
## 3 82 -0.4882190 1.5936979 0.7601291
## 4 82 0.1430443 1.2374047 0.9079693
## 5 82 1.0438428 0.9223994 0.2577772
mr_heterogeneity(alertness_anx_dat)
## id.exposure id.outcome outcome exposure method
## 1 EmiO5k P7hL23 Anxiety Alertness Factor MR Egger
## 2 EmiO5k P7hL23 Anxiety Alertness Factor Inverse variance weighted
## Q Q_df Q_pval
## 1 122.6475 80 0.0015377500
## 2 126.6605 81 0.0008915931
mr_pleiotropy_test(alertness_anx_dat)
## id.exposure id.outcome outcome exposure egger_intercept se
## 1 EmiO5k P7hL23 Anxiety Alertness Factor 0.01470021 0.009085904
## pval
## 1 0.1096175
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = alertness_anx_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, alertness_anx_dat)
p1
## $EmiO5k.P7hL23
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 EmiO5k P7hL23
res_single <- mr_singlesnp(alertness_anx_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome samplesize SNP b
## 1 Alertness Factor Anxiety EmiO5k P7hL23 117893.2 rs2431108 27.78324
## se p
## 1 6.155789 6.381124e-06
scz_out_dat <- extract_outcome_data(snps = alertness_exp_dat$SNP, outcomes = scz)
## Extracting data for 85 SNP(s) from 1 GWAS(s)
## Finding proxies for 5 SNPs in outcome ieu-b-42
## Extracting data for 5 SNP(s) from 1 GWAS(s)
alertness_scz_dat <- harmonise_data(alertness_exp_dat, scz_out_dat)
## Harmonising Alertness Factor (EmiO5k) and schizophrenia || id:ieu-b-42 (ieu-b-42)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs1843815, rs2916622
res <- mr(alertness_scz_dat, method_list = methods)
## Analysing 'EmiO5k' on 'ieu-b-42'
res
## id.exposure id.outcome outcome exposure
## 1 EmiO5k ieu-b-42 schizophrenia || id:ieu-b-42 Alertness Factor
## 2 EmiO5k ieu-b-42 schizophrenia || id:ieu-b-42 Alertness Factor
## 3 EmiO5k ieu-b-42 schizophrenia || id:ieu-b-42 Alertness Factor
## 4 EmiO5k ieu-b-42 schizophrenia || id:ieu-b-42 Alertness Factor
## 5 EmiO5k ieu-b-42 schizophrenia || id:ieu-b-42 Alertness Factor
## method nsnp b se pval
## 1 Maximum likelihood 83 -1.362173 0.4706408 0.003800121
## 2 MR Egger 83 -1.943601 3.4530094 0.575076986
## 3 Weighted mode 83 -4.866616 1.8192093 0.009015900
## 4 Weighted median 83 -2.141998 0.9104651 0.018640598
## 5 Inverse variance weighted 83 -1.267243 0.9621506 0.187807180
mr_heterogeneity(alertness_scz_dat)
## id.exposure id.outcome outcome exposure
## 1 EmiO5k ieu-b-42 schizophrenia || id:ieu-b-42 Alertness Factor
## 2 EmiO5k ieu-b-42 schizophrenia || id:ieu-b-42 Alertness Factor
## method Q Q_df Q_pval
## 1 MR Egger 383.0581 81 9.090253e-41
## 2 Inverse variance weighted 383.2550 82 1.840068e-40
mr_pleiotropy_test(alertness_scz_dat)
## id.exposure id.outcome outcome exposure
## 1 EmiO5k ieu-b-42 schizophrenia || id:ieu-b-42 Alertness Factor
## egger_intercept se pval
## 1 0.002127136 0.01042437 0.838823
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = alertness_scz_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, alertness_scz_dat)
p1
## $`EmiO5k.ieu-b-42`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 EmiO5k ieu-b-42
res_single <- mr_singlesnp(alertness_scz_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome
## 1 Alertness Factor schizophrenia || id:ieu-b-42 EmiO5k ieu-b-42
## 2 Alertness Factor schizophrenia || id:ieu-b-42 EmiO5k ieu-b-42
## 3 Alertness Factor schizophrenia || id:ieu-b-42 EmiO5k ieu-b-42
## 4 Alertness Factor schizophrenia || id:ieu-b-42 EmiO5k ieu-b-42
## 5 Alertness Factor schizophrenia || id:ieu-b-42 EmiO5k ieu-b-42
## 6 Alertness Factor schizophrenia || id:ieu-b-42 EmiO5k ieu-b-42
## 7 Alertness Factor schizophrenia || id:ieu-b-42 EmiO5k ieu-b-42
## 8 Alertness Factor schizophrenia || id:ieu-b-42 EmiO5k ieu-b-42
## 9 Alertness Factor schizophrenia || id:ieu-b-42 EmiO5k ieu-b-42
## 10 Alertness Factor schizophrenia || id:ieu-b-42 EmiO5k ieu-b-42
## 11 Alertness Factor schizophrenia || id:ieu-b-42 EmiO5k ieu-b-42
## 12 Alertness Factor schizophrenia || id:ieu-b-42 EmiO5k ieu-b-42
## 13 Alertness Factor schizophrenia || id:ieu-b-42 EmiO5k ieu-b-42
## 14 Alertness Factor schizophrenia || id:ieu-b-42 EmiO5k ieu-b-42
## 15 Alertness Factor schizophrenia || id:ieu-b-42 EmiO5k ieu-b-42
## 16 Alertness Factor schizophrenia || id:ieu-b-42 EmiO5k ieu-b-42
## samplesize SNP b se p
## 1 77096 rs10192988 -20.034795 4.8761561 3.978456e-05
## 2 77096 rs11649804 19.728250 4.4667736 1.002346e-05
## 3 77096 rs12506659 -22.107550 4.7033700 2.596986e-06
## 4 77096 rs13010456 10.374190 2.8931589 3.360905e-04
## 5 77096 rs13330072 -17.223528 4.8766241 4.126558e-04
## 6 77096 rs17158413 13.859631 3.7852730 2.507805e-04
## 7 77096 rs1846644 -7.438941 1.8227467 4.480934e-05
## 8 77096 rs2393923 -29.829140 4.2766814 3.062336e-12
## 9 77096 rs2555582 14.847883 4.8897284 2.393060e-03
## 10 77096 rs2893323 -16.682126 4.7241567 4.136179e-04
## 11 77096 rs34097347 -8.414345 2.5065606 7.881347e-04
## 12 77096 rs34728579 -16.503983 4.9132391 7.820130e-04
## 13 77096 rs4648390 -14.719671 5.1186639 4.031502e-03
## 14 77096 rs62519825 12.441157 4.1149667 2.499584e-03
## 15 77096 rs6757852 21.648103 4.4962310 1.474048e-06
## 16 77096 All - Maximum likelihood -1.362173 0.4706408 3.800121e-03
bip_out_dat <- read_outcome_data(
snps = alertness_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/BiP_withNeff.txt.gz",
sep = "\t",
snp_col = "SNP",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
# eaf_col = "MAF",
pval_col = "PVAL"
)
## No phenotype name specified, defaulting to 'outcome'.
bip_out_dat$outcome<- rep('Bipolar Disorder', 1, nrow(bip_out_dat))
alertness_bip_dat <- harmonise_data(alertness_exp_dat, bip_out_dat)
## Harmonising Alertness Factor (EmiO5k) and Bipolar Disorder (FFzPgI)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs1843815, rs2916622, rs9389556, rs9998136
res <- mr(alertness_bip_dat, method_list = methods)
## Analysing 'EmiO5k' on 'FFzPgI'
res
## id.exposure id.outcome outcome exposure
## 1 EmiO5k FFzPgI Bipolar Disorder Alertness Factor
## 2 EmiO5k FFzPgI Bipolar Disorder Alertness Factor
## 3 EmiO5k FFzPgI Bipolar Disorder Alertness Factor
## 4 EmiO5k FFzPgI Bipolar Disorder Alertness Factor
## 5 EmiO5k FFzPgI Bipolar Disorder Alertness Factor
## method nsnp b se pval
## 1 Maximum likelihood 81 -1.1550455 0.4021194 0.004073743
## 2 MR Egger 81 1.9908040 2.6045959 0.446940078
## 3 Weighted mode 81 -0.5766868 1.3115147 0.661332346
## 4 Weighted median 81 -0.4600667 0.7022123 0.512359892
## 5 Inverse variance weighted 81 -1.0930059 0.7564023 0.148456194
mr_heterogeneity(alertness_bip_dat)
## id.exposure id.outcome outcome exposure
## 1 EmiO5k FFzPgI Bipolar Disorder Alertness Factor
## 2 EmiO5k FFzPgI Bipolar Disorder Alertness Factor
## method Q Q_df Q_pval
## 1 MR Egger 303.0030 79 5.796794e-28
## 2 Inverse variance weighted 308.8713 80 1.276982e-28
mr_pleiotropy_test(alertness_bip_dat)
## id.exposure id.outcome outcome exposure egger_intercept
## 1 EmiO5k FFzPgI Bipolar Disorder Alertness Factor -0.00980656
## se pval
## 1 0.00792809 0.2197743
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = alertness_bip_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, alertness_bip_dat)
p1
## $EmiO5k.FFzPgI
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 EmiO5k FFzPgI
res_single <- mr_singlesnp(alertness_bip_dat,all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome samplesize
## 1 Alertness Factor Bipolar Disorder EmiO5k FFzPgI NA
## 2 Alertness Factor Bipolar Disorder EmiO5k FFzPgI NA
## 3 Alertness Factor Bipolar Disorder EmiO5k FFzPgI NA
## 4 Alertness Factor Bipolar Disorder EmiO5k FFzPgI NA
## 5 Alertness Factor Bipolar Disorder EmiO5k FFzPgI NA
## 6 Alertness Factor Bipolar Disorder EmiO5k FFzPgI NA
## 7 Alertness Factor Bipolar Disorder EmiO5k FFzPgI NA
## 8 Alertness Factor Bipolar Disorder EmiO5k FFzPgI NA
## 9 Alertness Factor Bipolar Disorder EmiO5k FFzPgI NA
## 10 Alertness Factor Bipolar Disorder EmiO5k FFzPgI NA
## 11 Alertness Factor Bipolar Disorder EmiO5k FFzPgI NA
## 12 Alertness Factor Bipolar Disorder EmiO5k FFzPgI NA
## 13 Alertness Factor Bipolar Disorder EmiO5k FFzPgI NA
## SNP b se p
## 1 rs113632119 -15.442868 4.5056534 6.092954e-04
## 2 rs13330072 -19.308171 4.0900718 2.349865e-06
## 3 rs17158413 10.511547 3.2029233 1.031246e-03
## 4 rs174541 -29.112852 4.2786471 1.015990e-11
## 5 rs224111 -13.587289 3.4687241 8.962591e-05
## 6 rs2393923 -10.690135 3.6351792 3.274238e-03
## 7 rs2431108 -14.081204 2.8681129 9.127581e-07
## 8 rs4648390 -14.386273 4.5833787 1.696458e-03
## 9 rs4665972 -14.438208 4.0083894 3.157816e-04
## 10 rs4983329 14.642353 4.1710403 4.472986e-04
## 11 rs60579048 -11.130698 3.2290781 5.668057e-04
## 12 rs886114 12.441909 3.6950366 7.593697e-04
## 13 All - Maximum likelihood -1.155046 0.4021194 4.073743e-03
adhd_out_dat <- extract_outcome_data(snps = alertness_exp_dat$SNP, outcomes = adhd)
## Extracting data for 85 SNP(s) from 1 GWAS(s)
## Finding proxies for 1 SNPs in outcome ieu-a-1183
## Extracting data for 1 SNP(s) from 1 GWAS(s)
alertness_adhd_dat <- harmonise_data(alertness_exp_dat, adhd_out_dat)
## Harmonising Alertness Factor (EmiO5k) and ADHD || id:ieu-a-1183 (ieu-a-1183)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs1843815, rs2916622, rs9389556, rs9998136
res <- mr(alertness_adhd_dat, method_list = methods)
## Analysing 'EmiO5k' on 'ieu-a-1183'
res
## id.exposure id.outcome outcome exposure
## 1 EmiO5k ieu-a-1183 ADHD || id:ieu-a-1183 Alertness Factor
## 2 EmiO5k ieu-a-1183 ADHD || id:ieu-a-1183 Alertness Factor
## 3 EmiO5k ieu-a-1183 ADHD || id:ieu-a-1183 Alertness Factor
## 4 EmiO5k ieu-a-1183 ADHD || id:ieu-a-1183 Alertness Factor
## 5 EmiO5k ieu-a-1183 ADHD || id:ieu-a-1183 Alertness Factor
## method nsnp b se pval
## 1 Maximum likelihood 80 -1.458220 0.5625438 0.009536711
## 2 MR Egger 80 -1.563416 2.8837844 0.589267370
## 3 Weighted mode 80 -3.217872 2.0034206 0.112222488
## 4 Weighted median 80 -2.002937 0.9333184 0.031869896
## 5 Inverse variance weighted 80 -1.428021 0.8401279 0.089174982
mr_heterogeneity(alertness_adhd_dat)
## id.exposure id.outcome outcome exposure
## 1 EmiO5k ieu-a-1183 ADHD || id:ieu-a-1183 Alertness Factor
## 2 EmiO5k ieu-a-1183 ADHD || id:ieu-a-1183 Alertness Factor
## method Q Q_df Q_pval
## 1 MR Egger 185.5931 78 9.338384e-11
## 2 Inverse variance weighted 185.5989 79 1.455398e-10
mr_pleiotropy_test(alertness_adhd_dat)
## id.exposure id.outcome outcome exposure egger_intercept
## 1 EmiO5k ieu-a-1183 ADHD || id:ieu-a-1183 Alertness Factor 0.000432442
## se pval
## 1 0.008805841 0.9609583
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = alertness_adhd_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, alertness_adhd_dat)
p1
## $`EmiO5k.ieu-a-1183`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 EmiO5k ieu-a-1183
res_single <- mr_singlesnp(alertness_adhd_dat,all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome samplesize
## 1 Alertness Factor ADHD || id:ieu-a-1183 EmiO5k ieu-a-1183 55374
## 2 Alertness Factor ADHD || id:ieu-a-1183 EmiO5k ieu-a-1183 55374
## 3 Alertness Factor ADHD || id:ieu-a-1183 EmiO5k ieu-a-1183 55374
## 4 Alertness Factor ADHD || id:ieu-a-1183 EmiO5k ieu-a-1183 55374
## 5 Alertness Factor ADHD || id:ieu-a-1183 EmiO5k ieu-a-1183 55374
## SNP b se p
## 1 rs10514370 -19.52940 5.339894 2.549230e-04
## 2 rs2431108 -20.73700 4.072720 3.548989e-07
## 3 rs28768443 16.96883 5.010270 7.071046e-04
## 4 rs35508926 -19.33737 6.297906 2.137404e-03
## 5 rs4147132 -21.78956 5.340700 4.505379e-05
# dpw<- fread("/Users/claire/Desktop/Desktop/sleepMR/DrinksPerWeek.txt.gz", header=T, data.table=F)
drinkspw_out_dat <- read_outcome_data(
snps = alertness_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/DrinksPerWeek.txt.gz",
sep = "\t",
snp_col = "RSID",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "REF",
other_allele_col = "ALT",
eaf_col = "AF",
pval_col = "PVALUE"
)
## No phenotype name specified, defaulting to 'outcome'.
drinkspw_out_dat$outcome<- rep('Drinks per Week', 1, nrow(drinkspw_out_dat))
alertness_dpw_dat <- harmonise_data(alertness_exp_dat, drinkspw_out_dat)
## Harmonising Alertness Factor (EmiO5k) and Drinks per Week (WiqIQF)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs1843815, rs2916622
res <- mr(alertness_dpw_dat, method_list = methods)
## Analysing 'EmiO5k' on 'WiqIQF'
res
## id.exposure id.outcome outcome exposure
## 1 EmiO5k WiqIQF Drinks per Week Alertness Factor
## 2 EmiO5k WiqIQF Drinks per Week Alertness Factor
## 3 EmiO5k WiqIQF Drinks per Week Alertness Factor
## 4 EmiO5k WiqIQF Drinks per Week Alertness Factor
## 5 EmiO5k WiqIQF Drinks per Week Alertness Factor
## method nsnp b se pval
## 1 Maximum likelihood 82 -0.1771796 0.08369167 0.03425545
## 2 MR Egger 82 0.3582516 0.62752708 0.56967153
## 3 Weighted mode 82 -0.1624339 0.21439056 0.45085661
## 4 Weighted median 82 -0.1534620 0.13064554 0.24013706
## 5 Inverse variance weighted 82 -0.1709809 0.18146074 0.34606593
mr_heterogeneity(alertness_dpw_dat)
## id.exposure id.outcome outcome exposure
## 1 EmiO5k WiqIQF Drinks per Week Alertness Factor
## 2 EmiO5k WiqIQF Drinks per Week Alertness Factor
## method Q Q_df Q_pval
## 1 MR Egger 429.3522 80 3.046928e-49
## 2 Inverse variance weighted 433.5188 81 1.292061e-49
mr_pleiotropy_test(alertness_dpw_dat)
## id.exposure id.outcome outcome exposure egger_intercept
## 1 EmiO5k WiqIQF Drinks per Week Alertness Factor -0.001678731
## se pval
## 1 0.001905243 0.3808972
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = alertness_dpw_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, alertness_dpw_dat)
p1
## $EmiO5k.WiqIQF
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 EmiO5k WiqIQF
res_single <- mr_singlesnp(alertness_dpw_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome samplesize
## 1 Alertness Factor Drinks per Week EmiO5k WiqIQF NA
## 2 Alertness Factor Drinks per Week EmiO5k WiqIQF NA
## 3 Alertness Factor Drinks per Week EmiO5k WiqIQF NA
## 4 Alertness Factor Drinks per Week EmiO5k WiqIQF NA
## 5 Alertness Factor Drinks per Week EmiO5k WiqIQF NA
## 6 Alertness Factor Drinks per Week EmiO5k WiqIQF NA
## 7 Alertness Factor Drinks per Week EmiO5k WiqIQF NA
## 8 Alertness Factor Drinks per Week EmiO5k WiqIQF NA
## 9 Alertness Factor Drinks per Week EmiO5k WiqIQF NA
## 10 Alertness Factor Drinks per Week EmiO5k WiqIQF NA
## 11 Alertness Factor Drinks per Week EmiO5k WiqIQF NA
## SNP b se p
## 1 rs1001817 -2.855441 0.6466301 1.005997e-05
## 2 rs113632119 -3.407350 0.9308171 2.516243e-04
## 3 rs11649804 2.323575 0.7904963 3.288614e-03
## 4 rs12615434 2.846349 0.8826154 1.260153e-03
## 5 rs13330072 -3.765090 0.8482860 9.060137e-06
## 6 rs17158413 -2.239872 0.6605021 6.959619e-04
## 7 rs34097347 3.662294 0.4240175 5.764321e-18
## 8 rs4147132 2.196474 0.7879805 5.312105e-03
## 9 rs4648390 -2.682934 0.8933192 2.670414e-03
## 10 rs4665972 -9.124538 0.8096718 1.857735e-29
## 11 rs60222088 -2.770791 0.7202329 1.195355e-04
#cigs<- fread("/Users/claire/Desktop/Desktop/sleepMR/cigs_withNeff.txt.gz", header=T, data.table = F)
cigs_out_dat <- read_outcome_data(
snps = alertness_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/cigs_withNeff.txt.gz",
sep = "\t",
snp_col = "RSID",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
eaf_col = "MAF",
pval_col = "PVALUE"
)
## No phenotype name specified, defaulting to 'outcome'.
cigs_out_dat$outcome<- rep('Cigarettes per Day', 1, nrow(cigs_out_dat))
alertness_cigs_dat <- harmonise_data(alertness_exp_dat, cigs_out_dat)
## Harmonising Alertness Factor (EmiO5k) and Cigarettes per Day (XnN5dj)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs1843815, rs2916622
res <- mr(alertness_cigs_dat, method_list = methods)
## Analysing 'EmiO5k' on 'XnN5dj'
res
## id.exposure id.outcome outcome exposure
## 1 EmiO5k XnN5dj Cigarettes per Day Alertness Factor
## 2 EmiO5k XnN5dj Cigarettes per Day Alertness Factor
## 3 EmiO5k XnN5dj Cigarettes per Day Alertness Factor
## 4 EmiO5k XnN5dj Cigarettes per Day Alertness Factor
## 5 EmiO5k XnN5dj Cigarettes per Day Alertness Factor
## method nsnp b se pval
## 1 Maximum likelihood 82 0.3991191 0.2293477 0.08181755
## 2 MR Egger 82 0.4437374 1.0687834 0.67912161
## 3 Weighted mode 82 0.7255469 0.8012982 0.36790495
## 4 Weighted median 82 0.6106759 0.3726587 0.10127577
## 5 Inverse variance weighted 82 0.3821186 0.3083218 0.21521591
mr_heterogeneity(alertness_cigs_dat)
## id.exposure id.outcome outcome exposure
## 1 EmiO5k XnN5dj Cigarettes per Day Alertness Factor
## 2 EmiO5k XnN5dj Cigarettes per Day Alertness Factor
## method Q Q_df Q_pval
## 1 MR Egger 152.6858 80 1.831256e-06
## 2 Inverse variance weighted 152.6927 81 2.565422e-06
mr_pleiotropy_test(alertness_cigs_dat)
## id.exposure id.outcome outcome exposure egger_intercept
## 1 EmiO5k XnN5dj Cigarettes per Day Alertness Factor -0.0001957359
## se pval
## 1 0.003248884 0.9521091
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = alertness_cigs_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, alertness_cigs_dat)
p1
## $EmiO5k.XnN5dj
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 EmiO5k XnN5dj
res_single <- mr_singlesnp(alertness_cigs_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome samplesize
## 1 Alertness Factor Cigarettes per Day EmiO5k XnN5dj NA
## 2 Alertness Factor Cigarettes per Day EmiO5k XnN5dj NA
## 3 Alertness Factor Cigarettes per Day EmiO5k XnN5dj NA
## 4 Alertness Factor Cigarettes per Day EmiO5k XnN5dj NA
## 5 Alertness Factor Cigarettes per Day EmiO5k XnN5dj NA
## SNP b se p
## 1 rs174541 -7.050595 2.514864 0.0050540392
## 2 rs4983329 7.873291 2.697345 0.0035126449
## 3 rs60579048 5.612710 1.940036 0.0038146562
## 4 rs75932578 -7.418435 2.613032 0.0045253184
## 5 rs7814873 -9.524623 2.283354 0.0000302826
should have 191 loci
# chrono_exp_dat <- extract_instruments(outcomes = chrono)
chrono_gwas <-
subset(gwas_catalog,
grepl("Jones SE", Author) & Phenotype == "Chronotype")
chrono_exp_dat <- format_data(chrono_gwas)
nrow(chrono_exp_dat)
## [1] 450
nrow(chrono_exp_dat)
## [1] 450
chrono_exp_dat$samplesize.exposure<- 449734
chrono_exp_dat <- chrono_exp_dat %>% as.data.table
chrono_exp_dat <- chrono_exp_dat[, F_STAT := qf(
pval.exposure,
df1=1,
df2=samplesize.exposure,
lower.tail=F
)] # this piece calculates the F statistic of each SNP in the IV and adds a column called F_STAT
chrono_exp_dat$F_STAT %>% mean # to calculate the overall F stat of your exposure
## [1] 50.77243
chrono_exp_dat$F_STAT %>% min # yo
## [1] 20.4882
dep_out_dat <- extract_outcome_data(snps = chrono_exp_dat$SNP, outcomes = dep)
## Extracting data for 450 SNP(s) from 1 GWAS(s)
## Finding proxies for 74 SNPs in outcome ieu-b-102
## Extracting data for 74 SNP(s) from 1 GWAS(s)
chrono_exp_dep_dat <- harmonise_data(chrono_exp_dat, dep_out_dat)
## Harmonising Chronotype (NA) (cCmfJ6) and Major depression || id:ieu-b-102 (ieu-b-102)
## Removing the following SNPs for incompatible alleles:
## rs10254050, rs11788633, rs12206814, rs12445235, rs13172141, rs187028, rs247929, rs28380327, rs3138490, rs412000, rs42210, rs4698678, rs4785296, rs6047481, rs71523448, rs9347926, rs9956387
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10254050, rs10520176, rs11597421, rs11788633, rs12206814, rs12445235, rs12464387, rs13172141, rs1599374, rs17007397, rs187028, rs247929, rs2580160, rs28380327, rs3138490, rs34967119, rs359248, rs3796618, rs3807651, rs412000, rs4121878, rs42210, rs4365329, rs4698678, rs4729854, rs4785296, rs4878734, rs6047481, rs6433478, rs6544906, rs6560218, rs662094, rs6718511, rs71523448, rs7203707, rs848552, rs9347926, rs9394154, rs9476310, rs9956387
## Harmonising Chronotype (unit decrease) (dJYLi9) and Major depression || id:ieu-b-102 (ieu-b-102)
## Removing the following SNPs for incompatible alleles:
## rs1075265, rs10754194, rs3780204
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs1075265, rs10754194, rs13059636, rs3780204, rs4909296
## Harmonising Chronotype (unit increase) (BeKig2) and Major depression || id:ieu-b-102 (ieu-b-102)
## Removing the following SNPs for incompatible alleles:
## rs10999667
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10999667, rs2378824
res <- mr(chrono_exp_dep_dat, method_list = methods)
## Analysing 'BeKig2' on 'ieu-b-102'
## No SNPs available for MR analysis of 'cCmfJ6' on 'ieu-b-102'
## Analysing 'dJYLi9' on 'ieu-b-102'
res
## id.exposure id.outcome outcome
## 1 BeKig2 ieu-b-102 Major depression || id:ieu-b-102
## 2 BeKig2 ieu-b-102 Major depression || id:ieu-b-102
## 3 BeKig2 ieu-b-102 Major depression || id:ieu-b-102
## 4 BeKig2 ieu-b-102 Major depression || id:ieu-b-102
## 5 BeKig2 ieu-b-102 Major depression || id:ieu-b-102
## 6 dJYLi9 ieu-b-102 Major depression || id:ieu-b-102
## 7 dJYLi9 ieu-b-102 Major depression || id:ieu-b-102
## 8 dJYLi9 ieu-b-102 Major depression || id:ieu-b-102
## 9 dJYLi9 ieu-b-102 Major depression || id:ieu-b-102
## 10 dJYLi9 ieu-b-102 Major depression || id:ieu-b-102
## exposure method nsnp b
## 1 Chronotype (unit increase) Maximum likelihood 41 -0.12161950
## 2 Chronotype (unit increase) MR Egger 41 -0.10478408
## 3 Chronotype (unit increase) Weighted mode 41 0.06016080
## 4 Chronotype (unit increase) Weighted median 41 0.02250966
## 5 Chronotype (unit increase) Inverse variance weighted 41 -0.12398002
## 6 Chronotype (unit decrease) Maximum likelihood 41 -0.03775968
## 7 Chronotype (unit decrease) MR Egger 41 0.04331516
## 8 Chronotype (unit decrease) Weighted mode 41 0.12686957
## 9 Chronotype (unit decrease) Weighted median 41 0.08201793
## 10 Chronotype (unit decrease) Inverse variance weighted 41 -0.03709659
## se pval
## 1 0.05124598 0.01763236
## 2 0.17566152 0.55428072
## 3 0.11326673 0.59825707
## 4 0.08513681 0.79147636
## 5 0.08184016 0.12979660
## 6 0.05581613 0.49872251
## 7 0.14930194 0.77326311
## 8 0.10912115 0.25186176
## 9 0.08672772 0.34430444
## 10 0.06241602 0.55228194
mr_heterogeneity(chrono_exp_dep_dat)
## Not enough SNPs available for Heterogeneity analysis of 'cCmfJ6' on 'ieu-b-102'
## id.exposure id.outcome outcome
## 1 BeKig2 ieu-b-102 Major depression || id:ieu-b-102
## 2 BeKig2 ieu-b-102 Major depression || id:ieu-b-102
## 3 dJYLi9 ieu-b-102 Major depression || id:ieu-b-102
## 4 dJYLi9 ieu-b-102 Major depression || id:ieu-b-102
## exposure method Q Q_df
## 1 Chronotype (unit increase) MR Egger 108.45396 39
## 2 Chronotype (unit increase) Inverse variance weighted 108.49668 40
## 3 Chronotype (unit decrease) MR Egger 50.97052 39
## 4 Chronotype (unit decrease) Inverse variance weighted 51.43152 40
## Q_pval
## 1 1.841089e-08
## 2 3.087779e-08
## 3 9.491854e-02
## 4 1.063265e-01
mr_pleiotropy_test(chrono_exp_dep_dat)
## Not enough SNPs available for pleiotropy analysis of 'cCmfJ6' on 'ieu-b-102'
## id.exposure id.outcome outcome
## 1 BeKig2 ieu-b-102 Major depression || id:ieu-b-102
## 2 dJYLi9 ieu-b-102 Major depression || id:ieu-b-102
## exposure egger_intercept se pval
## 1 Chronotype (unit increase) -0.0003558751 0.002871471 0.9020035
## 2 Chronotype (unit decrease) -0.0012831176 0.002160443 0.5559990
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = chrono_exp_dep_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, chrono_exp_dep_dat)
p1
## $`BeKig2.ieu-b-102`
##
## $`cCmfJ6.ieu-b-102`
##
## $`dJYLi9.ieu-b-102`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 BeKig2 ieu-b-102
## 2 cCmfJ6 ieu-b-102
## 3 dJYLi9 ieu-b-102
res_single <- mr_singlesnp(chrono_exp_dep_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure
## 1 Chronotype (unit increase) Major depression || id:ieu-b-102 BeKig2
## 2 Chronotype (unit increase) Major depression || id:ieu-b-102 BeKig2
## 3 Chronotype (unit increase) Major depression || id:ieu-b-102 BeKig2
## 4 Chronotype (unit increase) Major depression || id:ieu-b-102 BeKig2
## id.outcome samplesize SNP b se p
## 1 ieu-b-102 NA rs28602385 1.9390143 0.4101761 2.275555e-06
## 2 ieu-b-102 NA rs4821940 -0.6363636 0.1954545 1.130678e-03
## 3 ieu-b-102 NA rs72834074 -1.2894254 0.4455606 3.804416e-03
## 4 ieu-b-102 NA rs8063159 -1.1932433 0.3034839 8.430582e-05
anx_out_dat <- read_outcome_data(
snps = chrono_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/anxiety_withNeff.txt.gz",
sep = "\t",
snp_col = "SNP",
beta_col = "effect",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
eaf_col = "MAF",
pval_col = "P",
samplesize_col = "Neff"
)
## No phenotype name specified, defaulting to 'outcome'.
anx_out_dat$outcome<- rep('Anxiety', 1, nrow(anx_out_dat))
chrono_anx_dat <- harmonise_data(chrono_exp_dat, anx_out_dat)
## Harmonising Chronotype (NA) (cCmfJ6) and Anxiety (PXh41O)
## Removing the following SNPs for incompatible alleles:
## rs10254050, rs11788633, rs12206814, rs12445235, rs13172141, rs187028, rs247929, rs28380327, rs3138490, rs412000, rs42210, rs4698678, rs4785296, rs6047481, rs71523448, rs9347926, rs9956387
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10254050, rs10520176, rs10951325, rs111261826, rs113851554, rs11588913, rs11597421, rs11788633, rs11845599, rs12140153, rs12206814, rs12436039, rs12445235, rs12464387, rs12518401, rs1278402, rs13172141, rs1599374, rs17007397, rs17396357, rs17455138, rs17604349, rs187028, rs247929, rs2580160, rs28380327, rs2881955, rs2978382, rs3138490, rs34967119, rs35346733, rs35524253, rs359248, rs3796618, rs3807651, rs4027217, rs412000, rs4121878, rs42210, rs4365329, rs4550384, rs4550782, rs45597035, rs4698678, rs4729854, rs4785296, rs4878734, rs58876439, rs6007594, rs6047481, rs6433478, rs6544906, rs6560218, rs6573308, rs662094, rs66507804, rs6718511, rs6838677, rs7006885, rs71523448, rs7203707, rs7429614, rs76518095, rs7700110, rs7959983, rs80097534, rs848552, rs9347926, rs9381812, rs9394154, rs9476310, rs9496623, rs9573980, rs962961, rs9956387
## Harmonising Chronotype (unit decrease) (dJYLi9) and Anxiety (PXh41O)
## Removing the following SNPs for incompatible alleles:
## rs1075265, rs10754194, rs3780204
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs1075265, rs10754194, rs11174782, rs116291712, rs13059636, rs1458146, rs2236950, rs2742986, rs34580810, rs3780204, rs4834311, rs4909296, rs57690685, rs62378355, rs6725031, rs75457814, rs827749
## Harmonising Chronotype (unit increase) (BeKig2) and Anxiety (PXh41O)
## Removing the following SNPs for incompatible alleles:
## rs10999667
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10999667, rs1131359, rs2378824, rs41279738, rs4484214, rs80261926
res <- mr(chrono_anx_dat, method_list = methods)
## Analysing 'BeKig2' on 'PXh41O'
## No SNPs available for MR analysis of 'cCmfJ6' on 'PXh41O'
## Analysing 'dJYLi9' on 'PXh41O'
res
## id.exposure id.outcome outcome exposure
## 1 BeKig2 PXh41O Anxiety Chronotype (unit increase)
## 2 BeKig2 PXh41O Anxiety Chronotype (unit increase)
## 3 BeKig2 PXh41O Anxiety Chronotype (unit increase)
## 4 BeKig2 PXh41O Anxiety Chronotype (unit increase)
## 5 BeKig2 PXh41O Anxiety Chronotype (unit increase)
## 6 dJYLi9 PXh41O Anxiety Chronotype (unit decrease)
## 7 dJYLi9 PXh41O Anxiety Chronotype (unit decrease)
## 8 dJYLi9 PXh41O Anxiety Chronotype (unit decrease)
## 9 dJYLi9 PXh41O Anxiety Chronotype (unit decrease)
## 10 dJYLi9 PXh41O Anxiety Chronotype (unit decrease)
## method nsnp b se pval
## 1 Maximum likelihood 41 0.147060295 0.1572195 0.3495915
## 2 MR Egger 41 0.052881628 0.2749516 0.8484812
## 3 Weighted mode 41 0.162049907 0.2369458 0.4979743
## 4 Weighted median 41 0.061343055 0.2481442 0.8047478
## 5 Inverse variance weighted 41 0.144745131 0.1555664 0.3521436
## 6 Maximum likelihood 30 0.279286306 0.2039462 0.1708706
## 7 MR Egger 30 -0.325269615 0.4211164 0.4463496
## 8 Weighted mode 30 -0.071569242 0.3155367 0.8221570
## 9 Weighted median 30 -0.007635418 0.3252014 0.9812682
## 10 Inverse variance weighted 30 0.271507273 0.2396527 0.2572480
sleep_psych_MR<- rbind(sleep_psych_MR, res)
mr_heterogeneity(chrono_anx_dat)
## Not enough SNPs available for Heterogeneity analysis of 'cCmfJ6' on 'PXh41O'
## id.exposure id.outcome outcome exposure
## 1 BeKig2 PXh41O Anxiety Chronotype (unit increase)
## 2 BeKig2 PXh41O Anxiety Chronotype (unit increase)
## 3 dJYLi9 PXh41O Anxiety Chronotype (unit decrease)
## 4 dJYLi9 PXh41O Anxiety Chronotype (unit decrease)
## method Q Q_df Q_pval
## 1 MR Egger 32.74516 39 0.74966725
## 2 Inverse variance weighted 32.90935 40 0.77915837
## 3 MR Egger 37.81474 28 0.10195527
## 4 Inverse variance weighted 41.71208 29 0.05959253
mr_pleiotropy_test(chrono_anx_dat)
## Not enough SNPs available for pleiotropy analysis of 'cCmfJ6' on 'PXh41O'
## id.exposure id.outcome outcome exposure egger_intercept
## 1 BeKig2 PXh41O Anxiety Chronotype (unit increase) 0.002425767
## 2 dJYLi9 PXh41O Anxiety Chronotype (unit decrease) 0.014141403
## se pval
## 1 0.005986553 0.6875428
## 2 0.008324531 0.1004508
p1 <- mr_scatter_plot(res, chrono_anx_dat)
p1
## $BeKig2.PXh41O
##
## $cCmfJ6.PXh41O
##
## $dJYLi9.PXh41O
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 BeKig2 PXh41O
## 2 cCmfJ6 PXh41O
## 3 dJYLi9 PXh41O
res_single <- mr_singlesnp(chrono_anx_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## [1] exposure outcome id.exposure id.outcome samplesize SNP
## [7] b se p
## <0 rows> (or 0-length row.names)
scz_out_dat <- extract_outcome_data(snps = chrono_exp_dat$SNP, outcomes = scz)
## Extracting data for 450 SNP(s) from 1 GWAS(s)
## Finding proxies for 57 SNPs in outcome ieu-b-42
## Extracting data for 57 SNP(s) from 1 GWAS(s)
chrono_scz_dat <- harmonise_data(chrono_exp_dat, scz_out_dat)
## Harmonising Chronotype (NA) (cCmfJ6) and schizophrenia || id:ieu-b-42 (ieu-b-42)
## Removing the following SNPs for incompatible alleles:
## rs10254050, rs11788633, rs12206814, rs12445235, rs13172141, rs187028, rs247929, rs28380327, rs3138490, rs412000, rs42210, rs4698678, rs4785296, rs6047481, rs71523448, rs9347926, rs9956387
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10254050, rs10520176, rs11588913, rs11597421, rs11788633, rs12206814, rs12445235, rs12464387, rs13172141, rs1599374, rs187028, rs247929, rs2580160, rs28380327, rs3138490, rs34967119, rs359248, rs3796618, rs3807651, rs412000, rs4121878, rs42210, rs4365329, rs4698678, rs4729854, rs4785296, rs4878734, rs6047481, rs6433478, rs6544906, rs6560218, rs662094, rs6718511, rs711098, rs71523448, rs7203707, rs7248205, rs848552, rs9347926, rs9394154, rs9476310, rs9956387
## Harmonising Chronotype (unit decrease) (dJYLi9) and schizophrenia || id:ieu-b-42 (ieu-b-42)
## Removing the following SNPs for incompatible alleles:
## rs1075265, rs10754194, rs3780204
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs1075265, rs10754194, rs13059636, rs3780204, rs4834311, rs4909296
## Harmonising Chronotype (unit increase) (BeKig2) and schizophrenia || id:ieu-b-42 (ieu-b-42)
## Removing the following SNPs for incompatible alleles:
## rs10999667
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10999667, rs2378824
res <- mr(chrono_scz_dat, method_list = methods)
## Analysing 'BeKig2' on 'ieu-b-42'
## No SNPs available for MR analysis of 'cCmfJ6' on 'ieu-b-42'
## Analysing 'dJYLi9' on 'ieu-b-42'
res
## id.exposure id.outcome outcome
## 1 BeKig2 ieu-b-42 schizophrenia || id:ieu-b-42
## 2 BeKig2 ieu-b-42 schizophrenia || id:ieu-b-42
## 3 BeKig2 ieu-b-42 schizophrenia || id:ieu-b-42
## 4 BeKig2 ieu-b-42 schizophrenia || id:ieu-b-42
## 5 BeKig2 ieu-b-42 schizophrenia || id:ieu-b-42
## 6 dJYLi9 ieu-b-42 schizophrenia || id:ieu-b-42
## 7 dJYLi9 ieu-b-42 schizophrenia || id:ieu-b-42
## 8 dJYLi9 ieu-b-42 schizophrenia || id:ieu-b-42
## 9 dJYLi9 ieu-b-42 schizophrenia || id:ieu-b-42
## 10 dJYLi9 ieu-b-42 schizophrenia || id:ieu-b-42
## exposure method nsnp b
## 1 Chronotype (unit increase) Maximum likelihood 43 0.05627971
## 2 Chronotype (unit increase) MR Egger 43 -0.11288084
## 3 Chronotype (unit increase) Weighted mode 43 -0.21132940
## 4 Chronotype (unit increase) Weighted median 43 -0.01915937
## 5 Chronotype (unit increase) Inverse variance weighted 43 0.05255838
## 6 Chronotype (unit decrease) Maximum likelihood 41 -0.03281390
## 7 Chronotype (unit decrease) MR Egger 41 0.02220192
## 8 Chronotype (unit decrease) Weighted mode 41 -0.17958058
## 9 Chronotype (unit decrease) Weighted median 41 -0.10547836
## 10 Chronotype (unit decrease) Inverse variance weighted 41 -0.03177907
## se pval
## 1 0.1263860 0.6561028
## 2 0.4237508 0.7912779
## 3 0.3227442 0.5161737
## 4 0.2101672 0.9273634
## 5 0.2009872 0.7937061
## 6 0.1351086 0.8081057
## 7 0.3682152 0.9522278
## 8 0.2624307 0.4977332
## 9 0.2046047 0.6061878
## 10 0.1818676 0.8612860
mr_heterogeneity(chrono_scz_dat)
## Not enough SNPs available for Heterogeneity analysis of 'cCmfJ6' on 'ieu-b-42'
## id.exposure id.outcome outcome
## 1 BeKig2 ieu-b-42 schizophrenia || id:ieu-b-42
## 2 BeKig2 ieu-b-42 schizophrenia || id:ieu-b-42
## 3 dJYLi9 ieu-b-42 schizophrenia || id:ieu-b-42
## 4 dJYLi9 ieu-b-42 schizophrenia || id:ieu-b-42
## exposure method Q Q_df
## 1 Chronotype (unit increase) MR Egger 113.44070 41
## 2 Chronotype (unit increase) Inverse variance weighted 113.98794 42
## 3 Chronotype (unit decrease) MR Egger 74.93178 39
## 4 Chronotype (unit decrease) Inverse variance weighted 74.98684 40
## Q_pval
## 1 1.020935e-08
## 2 1.445900e-08
## 3 4.734889e-04
## 4 6.667365e-04
mr_pleiotropy_test(chrono_scz_dat)
## Not enough SNPs available for pleiotropy analysis of 'cCmfJ6' on 'ieu-b-42'
## id.exposure id.outcome outcome
## 1 BeKig2 ieu-b-42 schizophrenia || id:ieu-b-42
## 2 dJYLi9 ieu-b-42 schizophrenia || id:ieu-b-42
## exposure egger_intercept se pval
## 1 Chronotype (unit increase) 0.0031528912 0.007089421 0.6588525
## 2 Chronotype (unit decrease) -0.0009639244 0.005694128 0.8664483
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = chrono_scz_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, chrono_scz_dat)
p1
## $`BeKig2.ieu-b-42`
##
## $`cCmfJ6.ieu-b-42`
##
## $`dJYLi9.ieu-b-42`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 BeKig2 ieu-b-42
## 2 cCmfJ6 ieu-b-42
## 3 dJYLi9 ieu-b-42
res_single <- mr_singlesnp(chrono_scz_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure
## 1 Chronotype (unit increase) schizophrenia || id:ieu-b-42 BeKig2
## 2 Chronotype (unit increase) schizophrenia || id:ieu-b-42 BeKig2
## 3 Chronotype (unit increase) schizophrenia || id:ieu-b-42 BeKig2
## 4 Chronotype (unit decrease) schizophrenia || id:ieu-b-42 dJYLi9
## 5 Chronotype (unit decrease) schizophrenia || id:ieu-b-42 dJYLi9
## id.outcome samplesize SNP b se p
## 1 ieu-b-42 77096 rs6702412 4.794342 1.107215 1.490472e-05
## 2 ieu-b-42 77096 rs73182221 -2.896791 1.012059 4.206116e-03
## 3 ieu-b-42 77096 rs7964138 -4.219056 1.195932 4.189653e-04
## 4 ieu-b-42 77096 rs34580810 -3.749548 1.039107 3.080499e-04
## 5 ieu-b-42 77096 rs6537747 4.002099 1.132976 4.118417e-04
bip_out_dat <- read_outcome_data(
snps = chrono_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/BiP_withNeff.txt.gz",
sep = "\t",
snp_col = "SNP",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
# eaf_col = "MAF",
pval_col = "PVAL"
)
## No phenotype name specified, defaulting to 'outcome'.
bip_out_dat$outcome<- rep('Bipolar Disorder', 1, nrow(bip_out_dat))
chrono_bip_dat <- harmonise_data(chrono_exp_dat, bip_out_dat)
## Harmonising Chronotype (NA) (cCmfJ6) and Bipolar Disorder (H9adZq)
## Removing the following SNPs for incompatible alleles:
## rs10254050, rs11788633, rs12206814, rs12445235, rs13172141, rs187028, rs247929, rs28380327, rs3138490, rs412000, rs42210, rs4698678, rs4785296, rs6047481, rs71523448, rs9347926, rs9956387
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10254050, rs10520176, rs1061032, rs10742179, rs10762434, rs10951325, rs111261826, rs11200159, rs113851554, rs1144566, rs114848860, rs11588913, rs11597421, rs11678584, rs11788633, rs118047999, rs11845599, rs12140153, rs12195792, rs12206814, rs12445235, rs12464387, rs12470914, rs12518401, rs1278402, rs13011556, rs13172141, rs1508608, rs1599374, rs17007397, rs17396357, rs17455138, rs17604349, rs1799464, rs1800828, rs187028, rs2304467, rs247929, rs2580160, rs2653349, rs28380327, rs2881955, rs2978382, rs3138490, rs34967119, rs35346733, rs35524253, rs359248, rs3796618, rs3807651, rs3850174, rs4027217, rs412000, rs4121878, rs42210, rs4365329, rs4550384, rs45597035, rs4657983, rs4698678, rs4729854, rs4785296, rs4800998, rs481214, rs4878734, rs555784, rs57236847, rs58876439, rs59986227, rs6007594, rs6047481, rs6433478, rs6544906, rs6560218, rs6573308, rs662094, rs66507804, rs6690292, rs6718511, rs67988891, rs6838677, rs7006885, rs711098, rs71523448, rs7203707, rs7248205, rs72796401, rs7304278, rs7429614, rs76518095, rs7700110, rs7701529, rs7959983, rs80097534, rs8072058, rs812925, rs848552, rs9347926, rs9381812, rs9394154, rs9476310, rs9496623, rs9573980, rs9611597, rs962961, rs9956387
## Harmonising Chronotype (unit decrease) (dJYLi9) and Bipolar Disorder (H9adZq)
## Removing the following SNPs for incompatible alleles:
## rs1075265, rs10754194, rs3780204
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10495976, rs1075265, rs10754194, rs11162296, rs11174782, rs116291712, rs13059636, rs1458146, rs2236950, rs2742986, rs34580810, rs35888008, rs3780204, rs482204, rs4834311, rs4909296, rs57690685, rs62378355, rs6725031, rs75457814, rs827749
## Harmonising Chronotype (unit increase) (BeKig2) and Bipolar Disorder (H9adZq)
## Removing the following SNPs for incompatible alleles:
## rs10999667, rs4436614
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10999667, rs1131359, rs1593205, rs17643207, rs2050122, rs2232831, rs2378824, rs41279738, rs4436614, rs4484214, rs62436127, rs66888174, rs80261926
res <- mr(chrono_bip_dat, method_list = methods)
## Analysing 'BeKig2' on 'H9adZq'
## No SNPs available for MR analysis of 'cCmfJ6' on 'H9adZq'
## Analysing 'dJYLi9' on 'H9adZq'
res
## id.exposure id.outcome outcome exposure
## 1 BeKig2 H9adZq Bipolar Disorder Chronotype (unit increase)
## 2 BeKig2 H9adZq Bipolar Disorder Chronotype (unit increase)
## 3 BeKig2 H9adZq Bipolar Disorder Chronotype (unit increase)
## 4 BeKig2 H9adZq Bipolar Disorder Chronotype (unit increase)
## 5 BeKig2 H9adZq Bipolar Disorder Chronotype (unit increase)
## 6 dJYLi9 H9adZq Bipolar Disorder Chronotype (unit decrease)
## 7 dJYLi9 H9adZq Bipolar Disorder Chronotype (unit decrease)
## 8 dJYLi9 H9adZq Bipolar Disorder Chronotype (unit decrease)
## 9 dJYLi9 H9adZq Bipolar Disorder Chronotype (unit decrease)
## 10 dJYLi9 H9adZq Bipolar Disorder Chronotype (unit decrease)
## method nsnp b se pval
## 1 Maximum likelihood 35 -0.11861536 0.1209217 0.3266288
## 2 MR Egger 35 -0.25245375 0.3491971 0.4748008
## 3 Weighted mode 35 -0.18280735 0.2132237 0.3972546
## 4 Weighted median 35 -0.12925912 0.1909107 0.4983642
## 5 Inverse variance weighted 35 -0.12092276 0.1622052 0.4559740
## 6 Maximum likelihood 26 -0.25767455 0.1629639 0.1138378
## 7 MR Egger 26 -0.75850727 0.5721356 0.1974046
## 8 Weighted mode 26 -0.06138106 0.3820746 0.8736586
## 9 Weighted median 26 -0.04989338 0.2416038 0.8363933
## 10 Inverse variance weighted 26 -0.26595849 0.2219109 0.2307255
mr_heterogeneity(chrono_bip_dat)
## Not enough SNPs available for Heterogeneity analysis of 'cCmfJ6' on 'H9adZq'
## id.exposure id.outcome outcome exposure
## 1 BeKig2 H9adZq Bipolar Disorder Chronotype (unit increase)
## 2 BeKig2 H9adZq Bipolar Disorder Chronotype (unit increase)
## 3 dJYLi9 H9adZq Bipolar Disorder Chronotype (unit decrease)
## 4 dJYLi9 H9adZq Bipolar Disorder Chronotype (unit decrease)
## method Q Q_df Q_pval
## 1 MR Egger 62.88067 33 0.001303589
## 2 Inverse variance weighted 63.22775 34 0.001703199
## 3 MR Egger 46.95306 24 0.003394303
## 4 Inverse variance weighted 48.66131 25 0.003105161
mr_pleiotropy_test(chrono_bip_dat)
## Not enough SNPs available for pleiotropy analysis of 'cCmfJ6' on 'H9adZq'
## id.exposure id.outcome outcome exposure
## 1 BeKig2 H9adZq Bipolar Disorder Chronotype (unit increase)
## 2 dJYLi9 H9adZq Bipolar Disorder Chronotype (unit decrease)
## egger_intercept se pval
## 1 0.002364385 0.005539943 0.6723049
## 2 0.007251554 0.007760363 0.3593868
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = chrono_bip_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, chrono_bip_dat)
p1
## $BeKig2.H9adZq
##
## $cCmfJ6.H9adZq
##
## $dJYLi9.H9adZq
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 BeKig2 H9adZq
## 2 cCmfJ6 H9adZq
## 3 dJYLi9 H9adZq
res_single <- mr_singlesnp(chrono_bip_dat,all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome samplesize
## 1 Chronotype (unit increase) Bipolar Disorder BeKig2 H9adZq NA
## 2 Chronotype (unit increase) Bipolar Disorder BeKig2 H9adZq NA
## 3 Chronotype (unit decrease) Bipolar Disorder dJYLi9 H9adZq NA
## 4 Chronotype (unit decrease) Bipolar Disorder dJYLi9 H9adZq NA
## SNP b se p
## 1 rs1630848 -3.291486 1.0109929 0.0011311456
## 2 rs7964138 -2.918116 1.0237177 0.0043649326
## 3 rs35233100 -2.902610 0.8621433 0.0007606324
## 4 rs7949336 -3.459958 0.9526292 0.0002812229
adhd_out_dat <- extract_outcome_data(snps = chrono_exp_dat$SNP, outcomes = adhd)
## Extracting data for 450 SNP(s) from 1 GWAS(s)
## Finding proxies for 37 SNPs in outcome ieu-a-1183
## Extracting data for 37 SNP(s) from 1 GWAS(s)
chrono_adhd_dat <- harmonise_data(chrono_exp_dat, adhd_out_dat)
## Harmonising Chronotype (NA) (cCmfJ6) and ADHD || id:ieu-a-1183 (ieu-a-1183)
## Removing the following SNPs for incompatible alleles:
## rs10254050, rs11788633, rs12445235, rs13172141, rs187028, rs247929, rs28380327, rs3138490, rs412000, rs42210, rs4698678, rs4785296, rs6047481, rs71523448, rs9347926, rs9956387
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10254050, rs10520176, rs1061032, rs10742179, rs10762434, rs10951325, rs111261826, rs11200159, rs113851554, rs1144566, rs114848860, rs11588913, rs11597421, rs11678584, rs11788633, rs118047999, rs11845599, rs12140153, rs12195792, rs12436039, rs12445235, rs12464387, rs12470914, rs12518401, rs1278402, rs13011556, rs13172141, rs1508608, rs1599374, rs17007397, rs17396357, rs17455138, rs17604349, rs1799464, rs1800828, rs187028, rs2304467, rs247929, rs2580160, rs2653349, rs28380327, rs2881955, rs2978382, rs3138490, rs34967119, rs35346733, rs35524253, rs359248, rs3796618, rs3807651, rs3850174, rs4027217, rs412000, rs4121878, rs42210, rs4365329, rs4550384, rs4550782, rs45597035, rs4657983, rs4698678, rs4785296, rs4800998, rs481214, rs4878734, rs555784, rs57236847, rs58876439, rs59986227, rs6007594, rs6047481, rs6433478, rs6544906, rs6560218, rs6573308, rs662094, rs66507804, rs6690292, rs6718511, rs67988891, rs6838677, rs7006885, rs711098, rs71523448, rs7203707, rs7248205, rs72796401, rs7304278, rs7429614, rs76518095, rs7700110, rs7701529, rs7959983, rs80097534, rs8072058, rs812925, rs848552, rs9347926, rs9381812, rs9394154, rs9476310, rs9496623, rs9573980, rs9611597, rs962961, rs9956387, rs9991917
## Harmonising Chronotype (unit decrease) (dJYLi9) and ADHD || id:ieu-a-1183 (ieu-a-1183)
## Removing the following SNPs for incompatible alleles:
## rs1075265, rs10754194, rs3780204
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10495976, rs1075265, rs10754194, rs11162296, rs11174782, rs13059636, rs1458146, rs2236950, rs2742986, rs34580810, rs35888008, rs3780204, rs482204, rs4909296, rs57690685, rs62378355, rs6725031, rs75457814, rs827749
## Harmonising Chronotype (unit increase) (BeKig2) and ADHD || id:ieu-a-1183 (ieu-a-1183)
## Removing the following SNPs for incompatible alleles:
## rs10999667
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10999667, rs1131359, rs1593205, rs17643207, rs2050122, rs2232831, rs2378824, rs41279738, rs4484214, rs62436127, rs66888174
res <- mr(chrono_adhd_dat, method_list = methods)
## Analysing 'BeKig2' on 'ieu-a-1183'
## No SNPs available for MR analysis of 'cCmfJ6' on 'ieu-a-1183'
## Analysing 'dJYLi9' on 'ieu-a-1183'
res
## id.exposure id.outcome outcome exposure
## 1 BeKig2 ieu-a-1183 ADHD || id:ieu-a-1183 Chronotype (unit increase)
## 2 BeKig2 ieu-a-1183 ADHD || id:ieu-a-1183 Chronotype (unit increase)
## 3 BeKig2 ieu-a-1183 ADHD || id:ieu-a-1183 Chronotype (unit increase)
## 4 BeKig2 ieu-a-1183 ADHD || id:ieu-a-1183 Chronotype (unit increase)
## 5 BeKig2 ieu-a-1183 ADHD || id:ieu-a-1183 Chronotype (unit increase)
## 6 dJYLi9 ieu-a-1183 ADHD || id:ieu-a-1183 Chronotype (unit decrease)
## 7 dJYLi9 ieu-a-1183 ADHD || id:ieu-a-1183 Chronotype (unit decrease)
## 8 dJYLi9 ieu-a-1183 ADHD || id:ieu-a-1183 Chronotype (unit decrease)
## 9 dJYLi9 ieu-a-1183 ADHD || id:ieu-a-1183 Chronotype (unit decrease)
## 10 dJYLi9 ieu-a-1183 ADHD || id:ieu-a-1183 Chronotype (unit decrease)
## method nsnp b se pval
## 1 Maximum likelihood 33 -0.07659742 0.1841468 0.67744040
## 2 MR Egger 33 -0.19437488 0.6053586 0.75029661
## 3 Weighted mode 33 -0.06922949 0.4204873 0.87026212
## 4 Weighted median 33 -0.05373841 0.2931192 0.85453679
## 5 Inverse variance weighted 33 -0.07200630 0.2769853 0.79489126
## 6 Maximum likelihood 24 -0.38560886 0.2392457 0.10701214
## 7 MR Egger 24 -0.48875656 0.5969514 0.42170737
## 8 Weighted mode 24 -0.81020344 0.4902613 0.11200085
## 9 Weighted median 24 -0.69186675 0.3233260 0.03236748
## 10 Inverse variance weighted 24 -0.38035214 0.2365225 0.10781297
mr_heterogeneity(chrono_adhd_dat)
## Not enough SNPs available for Heterogeneity analysis of 'cCmfJ6' on 'ieu-a-1183'
## id.exposure id.outcome outcome exposure
## 1 BeKig2 ieu-a-1183 ADHD || id:ieu-a-1183 Chronotype (unit increase)
## 2 BeKig2 ieu-a-1183 ADHD || id:ieu-a-1183 Chronotype (unit increase)
## 3 dJYLi9 ieu-a-1183 ADHD || id:ieu-a-1183 Chronotype (unit decrease)
## 4 dJYLi9 ieu-a-1183 ADHD || id:ieu-a-1183 Chronotype (unit decrease)
## method Q Q_df Q_pval
## 1 MR Egger 76.98418 31 8.745985e-06
## 2 Inverse variance weighted 77.11357 32 1.360496e-05
## 3 MR Egger 19.38274 22 6.215902e-01
## 4 Inverse variance weighted 19.42186 23 6.764863e-01
mr_pleiotropy_test(chrono_adhd_dat)
## Not enough SNPs available for pleiotropy analysis of 'cCmfJ6' on 'ieu-a-1183'
## id.exposure id.outcome outcome exposure
## 1 BeKig2 ieu-a-1183 ADHD || id:ieu-a-1183 Chronotype (unit increase)
## 2 dJYLi9 ieu-a-1183 ADHD || id:ieu-a-1183 Chronotype (unit decrease)
## egger_intercept se pval
## 1 0.002156284 0.009446621 0.8209433
## 2 0.001596761 0.008073259 0.8450302
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = chrono_adhd_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, chrono_adhd_dat)
p1
## $`BeKig2.ieu-a-1183`
##
## $`cCmfJ6.ieu-a-1183`
##
## $`dJYLi9.ieu-a-1183`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 BeKig2 ieu-a-1183
## 2 cCmfJ6 ieu-a-1183
## 3 dJYLi9 ieu-a-1183
res_single <- mr_singlesnp(chrono_adhd_dat,all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome
## 1 Chronotype (unit increase) ADHD || id:ieu-a-1183 BeKig2 ieu-a-1183
## 2 Chronotype (unit increase) ADHD || id:ieu-a-1183 BeKig2 ieu-a-1183
## samplesize SNP b se p
## 1 55374 rs12998046 4.003475 1.293624 1.969631e-03
## 2 55374 rs2256459 4.317026 1.055654 4.324287e-05
# dpw<- fread("/Users/claire/Desktop/Desktop/sleepMR/DrinksPerWeek.txt.gz", header=T, data.table=F)
drinkspw_out_dat <- read_outcome_data(
snps = chrono_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/DrinksPerWeek.txt.gz",
sep = "\t",
snp_col = "RSID",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "REF",
other_allele_col = "ALT",
eaf_col = "AF",
pval_col = "PVALUE"
)
## No phenotype name specified, defaulting to 'outcome'.
drinkspw_out_dat$outcome<- rep('Drinks per Week', 1, nrow(drinkspw_out_dat))
chrono_dpw_dat <- harmonise_data(chrono_exp_dat, drinkspw_out_dat)
## Harmonising Chronotype (NA) (cCmfJ6) and Drinks per Week (wpcGB4)
## Removing the following SNPs for incompatible alleles:
## rs10254050, rs11788633, rs12206814, rs12445235, rs13172141, rs187028, rs247929, rs28380327, rs3138490, rs412000, rs42210, rs4698678, rs4785296, rs6047481, rs71523448, rs9347926, rs9956387
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10254050, rs10520176, rs1061032, rs10742179, rs10951325, rs111261826, rs11200159, rs113851554, rs1144566, rs11588913, rs11597421, rs11788633, rs11845599, rs12140153, rs12206814, rs12445235, rs12464387, rs12518401, rs1278402, rs13172141, rs1508608, rs1599374, rs17007397, rs17396357, rs17455138, rs17604349, rs1799464, rs187028, rs247929, rs2580160, rs2653349, rs28380327, rs2881955, rs2978382, rs3138490, rs34967119, rs35346733, rs35524253, rs359248, rs3796618, rs3807651, rs4027217, rs412000, rs4121878, rs42210, rs4365329, rs4550384, rs45597035, rs4657983, rs4698678, rs4729854, rs4785296, rs4878734, rs58876439, rs6007594, rs6047481, rs6433478, rs6544906, rs6560218, rs6573308, rs662094, rs66507804, rs6690292, rs6838677, rs7006885, rs711098, rs71523448, rs7203707, rs7248205, rs7304278, rs7429614, rs76518095, rs7700110, rs7959983, rs80097534, rs848552, rs9347926, rs9381812, rs9394154, rs9476310, rs9496623, rs9573980, rs962961, rs9956387
## Harmonising Chronotype (unit decrease) (dJYLi9) and Drinks per Week (wpcGB4)
## Removing the following SNPs for incompatible alleles:
## rs1075265, rs10754194, rs3780204
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs1075265, rs10754194, rs11174782, rs116291712, rs13059636, rs1458146, rs2236950, rs2742986, rs34580810, rs3780204, rs482204, rs4834311, rs4909296, rs57690685, rs62378355, rs6725031, rs75457814, rs827749
## Harmonising Chronotype (unit increase) (BeKig2) and Drinks per Week (wpcGB4)
## Removing the following SNPs for incompatible alleles:
## rs10999667
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10999667, rs1131359, rs2050122, rs2378824, rs41279738, rs4484214, rs80261926
res <- mr(chrono_dpw_dat, method_list = methods)
## Analysing 'BeKig2' on 'wpcGB4'
## No SNPs available for MR analysis of 'cCmfJ6' on 'wpcGB4'
## Analysing 'dJYLi9' on 'wpcGB4'
res
## id.exposure id.outcome outcome exposure
## 1 BeKig2 wpcGB4 Drinks per Week Chronotype (unit increase)
## 2 BeKig2 wpcGB4 Drinks per Week Chronotype (unit increase)
## 3 BeKig2 wpcGB4 Drinks per Week Chronotype (unit increase)
## 4 BeKig2 wpcGB4 Drinks per Week Chronotype (unit increase)
## 5 BeKig2 wpcGB4 Drinks per Week Chronotype (unit increase)
## 6 dJYLi9 wpcGB4 Drinks per Week Chronotype (unit decrease)
## 7 dJYLi9 wpcGB4 Drinks per Week Chronotype (unit decrease)
## 8 dJYLi9 wpcGB4 Drinks per Week Chronotype (unit decrease)
## 9 dJYLi9 wpcGB4 Drinks per Week Chronotype (unit decrease)
## 10 dJYLi9 wpcGB4 Drinks per Week Chronotype (unit decrease)
## method nsnp b se pval
## 1 Maximum likelihood 41 0.04843365 0.02264355 0.03243889
## 2 MR Egger 41 -0.06764861 0.08158462 0.41204707
## 3 Weighted mode 41 0.04694315 0.03558996 0.19467067
## 4 Weighted median 41 0.04550824 0.03543051 0.19898918
## 5 Inverse variance weighted 41 0.04628250 0.03999235 0.24715632
## 6 Maximum likelihood 31 0.05635651 0.02731789 0.03911367
## 7 MR Egger 31 -0.10158747 0.05658436 0.08303024
## 8 Weighted mode 31 -0.03552490 0.04836528 0.46833930
## 9 Weighted median 31 -0.01086569 0.04137467 0.79284591
## 10 Inverse variance weighted 31 0.05479665 0.03317369 0.09857324
mr_heterogeneity(chrono_dpw_dat)
## Not enough SNPs available for Heterogeneity analysis of 'cCmfJ6' on 'wpcGB4'
## id.exposure id.outcome outcome exposure
## 1 BeKig2 wpcGB4 Drinks per Week Chronotype (unit increase)
## 2 BeKig2 wpcGB4 Drinks per Week Chronotype (unit increase)
## 3 dJYLi9 wpcGB4 Drinks per Week Chronotype (unit decrease)
## 4 dJYLi9 wpcGB4 Drinks per Week Chronotype (unit decrease)
## method Q Q_df Q_pval
## 1 MR Egger 122.79502 39 1.333403e-10
## 2 Inverse variance weighted 130.78384 40 1.432145e-11
## 3 MR Egger 33.87579 29 2.438359e-01
## 4 Inverse variance weighted 45.96647 30 3.130380e-02
mr_pleiotropy_test(chrono_dpw_dat)
## Not enough SNPs available for pleiotropy analysis of 'cCmfJ6' on 'wpcGB4'
## id.exposure id.outcome outcome exposure
## 1 BeKig2 wpcGB4 Drinks per Week Chronotype (unit increase)
## 2 dJYLi9 wpcGB4 Drinks per Week Chronotype (unit decrease)
## egger_intercept se pval
## 1 0.002142688 0.0013451653 0.119260747
## 2 0.002826882 0.0008786744 0.003175575
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = chrono_dpw_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, chrono_dpw_dat)
p1
## $BeKig2.wpcGB4
##
## $cCmfJ6.wpcGB4
##
## $dJYLi9.wpcGB4
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 BeKig2 wpcGB4
## 2 cCmfJ6 wpcGB4
## 3 dJYLi9 wpcGB4
res_single <- mr_singlesnp(chrono_dpw_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome samplesize
## 1 Chronotype (unit increase) Drinks per Week BeKig2 wpcGB4 NA
## 2 Chronotype (unit increase) Drinks per Week BeKig2 wpcGB4 NA
## 3 Chronotype (unit increase) Drinks per Week BeKig2 wpcGB4 NA
## 4 Chronotype (unit increase) Drinks per Week BeKig2 wpcGB4 NA
## 5 Chronotype (unit decrease) Drinks per Week dJYLi9 wpcGB4 NA
## SNP b se p
## 1 rs28602385 0.8890751 0.1849833 1.537907e-06
## 2 rs32897 0.6601068 0.2112950 1.783499e-03
## 3 rs4838192 0.9739997 0.2115392 4.137645e-06
## 4 rs66888174 -0.6143242 0.2124685 3.835706e-03
## 5 rs4324483 0.5732701 0.2048700 5.138610e-03
#cigs<- fread("/Users/claire/Desktop/Desktop/sleepMR/cigs_withNeff.txt.gz", header=T, data.table = F)
cigs_out_dat <- read_outcome_data(
snps = chrono_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/cigs_withNeff.txt.gz",
sep = "\t",
snp_col = "RSID",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
eaf_col = "MAF",
pval_col = "PVALUE"
)
## No phenotype name specified, defaulting to 'outcome'.
cigs_out_dat$outcome<- rep('Cigarettes per Day', 1, nrow(cigs_out_dat))
chrono_cigs_dat <- harmonise_data(chrono_exp_dat, cigs_out_dat)
## Harmonising Chronotype (NA) (cCmfJ6) and Cigarettes per Day (BHgu7t)
## Removing the following SNPs for incompatible alleles:
## rs10254050, rs11788633, rs12206814, rs12445235, rs13172141, rs187028, rs247929, rs28380327, rs3138490, rs412000, rs42210, rs4698678, rs4785296, rs6047481, rs71523448, rs9347926, rs9956387
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10254050, rs10520176, rs1061032, rs10742179, rs10951325, rs111261826, rs11200159, rs113851554, rs1144566, rs11588913, rs11597421, rs11788633, rs11845599, rs12140153, rs12206814, rs12445235, rs12464387, rs12518401, rs1278402, rs13172141, rs1508608, rs1599374, rs17007397, rs17396357, rs17455138, rs17604349, rs1799464, rs187028, rs247929, rs2580160, rs2653349, rs28380327, rs2881955, rs2978382, rs3138490, rs34967119, rs35346733, rs35524253, rs359248, rs3796618, rs3807651, rs4027217, rs412000, rs4121878, rs42210, rs4365329, rs4550384, rs45597035, rs4657983, rs4698678, rs4729854, rs4785296, rs4878734, rs58876439, rs6007594, rs6047481, rs6433478, rs6544906, rs6560218, rs6573308, rs662094, rs66507804, rs6690292, rs6838677, rs7006885, rs711098, rs71523448, rs7203707, rs7248205, rs7304278, rs7429614, rs76518095, rs7700110, rs7959983, rs80097534, rs848552, rs9347926, rs9381812, rs9394154, rs9476310, rs9496623, rs9573980, rs962961, rs9956387
## Harmonising Chronotype (unit decrease) (dJYLi9) and Cigarettes per Day (BHgu7t)
## Removing the following SNPs for incompatible alleles:
## rs1075265, rs10754194, rs3780204
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs1075265, rs10754194, rs11174782, rs116291712, rs13059636, rs1458146, rs2236950, rs2742986, rs34580810, rs3780204, rs482204, rs4834311, rs4909296, rs57690685, rs62378355, rs6725031, rs75457814, rs827749
## Harmonising Chronotype (unit increase) (BeKig2) and Cigarettes per Day (BHgu7t)
## Removing the following SNPs for incompatible alleles:
## rs10999667
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10999667, rs1131359, rs2050122, rs2378824, rs41279738, rs4484214, rs80261926
res <- mr(chrono_cigs_dat, method_list = methods)
## Analysing 'BeKig2' on 'BHgu7t'
## No SNPs available for MR analysis of 'cCmfJ6' on 'BHgu7t'
## Analysing 'dJYLi9' on 'BHgu7t'
res
## id.exposure id.outcome outcome exposure
## 1 BeKig2 BHgu7t Cigarettes per Day Chronotype (unit increase)
## 2 BeKig2 BHgu7t Cigarettes per Day Chronotype (unit increase)
## 3 BeKig2 BHgu7t Cigarettes per Day Chronotype (unit increase)
## 4 BeKig2 BHgu7t Cigarettes per Day Chronotype (unit increase)
## 5 BeKig2 BHgu7t Cigarettes per Day Chronotype (unit increase)
## 6 dJYLi9 BHgu7t Cigarettes per Day Chronotype (unit decrease)
## 7 dJYLi9 BHgu7t Cigarettes per Day Chronotype (unit decrease)
## 8 dJYLi9 BHgu7t Cigarettes per Day Chronotype (unit decrease)
## 9 dJYLi9 BHgu7t Cigarettes per Day Chronotype (unit decrease)
## 10 dJYLi9 BHgu7t Cigarettes per Day Chronotype (unit decrease)
## method nsnp b se pval
## 1 Maximum likelihood 41 -0.01935322 0.06531945 0.7670119
## 2 MR Egger 41 0.07024635 0.20882488 0.7383810
## 3 Weighted mode 41 -0.14215613 0.12725231 0.2706082
## 4 Weighted median 41 -0.04393369 0.11003816 0.6897026
## 5 Inverse variance weighted 41 -0.01837428 0.09930448 0.8532057
## 6 Maximum likelihood 31 0.03077241 0.07969550 0.6994042
## 7 MR Egger 31 -0.11777978 0.26005622 0.6539902
## 8 Weighted mode 31 0.02021882 0.16689559 0.9043828
## 9 Weighted median 31 -0.03630128 0.11827181 0.7588959
## 10 Inverse variance weighted 31 0.02967175 0.13023431 0.8197756
mr_heterogeneity(chrono_cigs_dat)
## Not enough SNPs available for Heterogeneity analysis of 'cCmfJ6' on 'BHgu7t'
## id.exposure id.outcome outcome exposure
## 1 BeKig2 BHgu7t Cigarettes per Day Chronotype (unit increase)
## 2 BeKig2 BHgu7t Cigarettes per Day Chronotype (unit increase)
## 3 dJYLi9 BHgu7t Cigarettes per Day Chronotype (unit decrease)
## 4 dJYLi9 BHgu7t Cigarettes per Day Chronotype (unit decrease)
## method Q Q_df Q_pval
## 1 MR Egger 97.99554 39 5.546879e-07
## 2 Inverse variance weighted 98.58366 40 7.478335e-07
## 3 MR Egger 83.69936 29 3.287270e-07
## 4 Inverse variance weighted 84.94589 30 3.752312e-07
mr_pleiotropy_test(chrono_cigs_dat)
## Not enough SNPs available for pleiotropy analysis of 'cCmfJ6' on 'BHgu7t'
## id.exposure id.outcome outcome exposure
## 1 BeKig2 BHgu7t Cigarettes per Day Chronotype (unit increase)
## 2 dJYLi9 BHgu7t Cigarettes per Day Chronotype (unit decrease)
## egger_intercept se pval
## 1 -0.001668958 0.003449708 0.6312355
## 2 0.002636861 0.004012345 0.5162431
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = chrono_cigs_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, chrono_cigs_dat)
p1
## $BeKig2.BHgu7t
##
## $cCmfJ6.BHgu7t
##
## $dJYLi9.BHgu7t
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 BeKig2 BHgu7t
## 2 cCmfJ6 BHgu7t
## 3 dJYLi9 BHgu7t
res_single <- mr_singlesnp(chrono_cigs_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome
## 1 Chronotype (unit increase) Cigarettes per Day BeKig2 BHgu7t
## 2 Chronotype (unit increase) Cigarettes per Day BeKig2 BHgu7t
## 3 Chronotype (unit increase) Cigarettes per Day BeKig2 BHgu7t
## 4 Chronotype (unit decrease) Cigarettes per Day dJYLi9 BHgu7t
## 5 Chronotype (unit decrease) Cigarettes per Day dJYLi9 BHgu7t
## samplesize SNP b se p
## 1 NA rs271043 1.410586 0.5137050 6.034404e-03
## 2 NA rs28602385 -1.530393 0.5286654 3.793724e-03
## 3 NA rs73182221 1.828252 0.4768451 1.260465e-04
## 4 NA rs11641811 -1.215745 0.4084374 2.914876e-03
## 5 NA rs297343 3.534785 0.6062107 5.511207e-09
## exposure data
circ_full<- fread("/Users/claire/Desktop/sleepGWAS/sleep_rr_upd/circadian_pref_gsem.txt.gz", header=T, data.table = F)
cir<- fread("/Users/claire/Desktop/sleepGWAS/FUMA_out/circadian//GenomicRiskLoci.txt", header=T, data.table=F)
cir<- cir %>% select(rsID) %>%
rename(SNP=rsID)
circ_full<- circ_full %>% right_join(cir)
## Joining with `by = join_by(SNP)`
circadian_exp_dat <- format_data(circ_full, type="exposure",
snp_col = "SNP", beta_col = "est", se_col = "SE", effect_allele_col = "A1", other_allele_col = "A2", eaf_col = "MAF", pval_col = "Pval_Estimate")
## No phenotype name specified, defaulting to 'exposure'.
circadian_exp_dat$exposure<- rep("Circadian Preference Factor", 1, nrow(circadian_exp_dat))
head(circadian_exp_dat) ### this is the exposure data frame. looks the same as online phenos
## SNP eaf.exposure effect_allele.exposure other_allele.exposure
## 1 rs4417706 0.4781310 A T
## 2 rs55740938 0.1202780 G A
## 3 rs149611468 0.0149105 T C
## 4 rs6577620 0.4194830 C T
## 5 rs13059636 0.4324060 A G
## 6 rs62261468 0.0646123 C T
## beta.exposure se.exposure pval.exposure exposure
## 1 -0.009161351 0.001505120 1.151971e-09 Circadian Preference Factor
## 2 0.022497695 0.002262016 2.628920e-23 Circadian Preference Factor
## 3 0.038680984 0.006950079 2.613324e-08 Circadian Preference Factor
## 4 0.009349209 0.001502184 4.854289e-10 Circadian Preference Factor
## 5 -0.009502656 0.001508987 3.027252e-10 Circadian Preference Factor
## 6 -0.018278115 0.002927987 4.304822e-10 Circadian Preference Factor
## mr_keep.exposure pval_origin.exposure id.exposure
## 1 TRUE reported UDyoeg
## 2 TRUE reported UDyoeg
## 3 TRUE reported UDyoeg
## 4 TRUE reported UDyoeg
## 5 TRUE reported UDyoeg
## 6 TRUE reported UDyoeg
nrow(circadian_exp_dat)
## [1] 98
circadian_exp_dat$samplesize.exposure<- 79508
circadian_exp_dat <- circadian_exp_dat %>% as.data.table
circadian_exp_dat <- circadian_exp_dat[, F_STAT := qf(
pval.exposure,
df1=1,
df2=samplesize.exposure,
lower.tail=F
)] # this piece calculates the F statistic of each SNP in the IV and adds a column called F_STAT
circadian_exp_dat$F_STAT %>% mean # to calculate the overall F stat of your exposure
## [1] 45.63469
circadian_exp_dat$F_STAT %>% min # yo
## [1] 29.75972
dep_out_dat <- extract_outcome_data(snps = circadian_exp_dat$SNP, outcomes = dep)
## Extracting data for 98 SNP(s) from 1 GWAS(s)
## Finding proxies for 6 SNPs in outcome ieu-b-102
## Extracting data for 6 SNP(s) from 1 GWAS(s)
circadian_exp_dep_dat <- harmonise_data(circadian_exp_dat, dep_out_dat)
## Harmonising Circadian Preference Factor (UDyoeg) and Major depression || id:ieu-b-102 (ieu-b-102)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs1122967, rs1558902, rs4417706, rs4729854, rs848552, rs9956721
res <- mr(circadian_exp_dep_dat, method_list = methods)
## Analysing 'UDyoeg' on 'ieu-b-102'
res
## id.exposure id.outcome outcome
## 1 UDyoeg ieu-b-102 Major depression || id:ieu-b-102
## 2 UDyoeg ieu-b-102 Major depression || id:ieu-b-102
## 3 UDyoeg ieu-b-102 Major depression || id:ieu-b-102
## 4 UDyoeg ieu-b-102 Major depression || id:ieu-b-102
## 5 UDyoeg ieu-b-102 Major depression || id:ieu-b-102
## exposure method nsnp b
## 1 Circadian Preference Factor Maximum likelihood 91 -0.12296935
## 2 Circadian Preference Factor MR Egger 91 0.04579730
## 3 Circadian Preference Factor Weighted mode 91 0.13885678
## 4 Circadian Preference Factor Weighted median 91 -0.01326723
## 5 Circadian Preference Factor Inverse variance weighted 91 -0.11943957
## se pval
## 1 0.04616303 0.007726209
## 2 0.21512237 0.831900000
## 3 0.18068210 0.444193638
## 4 0.07605503 0.861517675
## 5 0.06872765 0.082234091
mr_heterogeneity(circadian_exp_dep_dat)
## id.exposure id.outcome outcome
## 1 UDyoeg ieu-b-102 Major depression || id:ieu-b-102
## 2 UDyoeg ieu-b-102 Major depression || id:ieu-b-102
## exposure method Q Q_df
## 1 Circadian Preference Factor MR Egger 208.1920 89
## 2 Circadian Preference Factor Inverse variance weighted 209.7297 90
## Q_pval
## 1 1.508533e-11
## 2 1.486924e-11
mr_pleiotropy_test(circadian_exp_dep_dat)
## id.exposure id.outcome outcome
## 1 UDyoeg ieu-b-102 Major depression || id:ieu-b-102
## exposure egger_intercept se pval
## 1 Circadian Preference Factor -0.002065365 0.002547433 0.4196643
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = circadian_exp_dep_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, circadian_exp_dep_dat)
p1
## $`UDyoeg.ieu-b-102`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 UDyoeg ieu-b-102
res_single <- mr_singlesnp(circadian_exp_dep_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure
## 1 Circadian Preference Factor Major depression || id:ieu-b-102 UDyoeg
## 2 Circadian Preference Factor Major depression || id:ieu-b-102 UDyoeg
## 3 Circadian Preference Factor Major depression || id:ieu-b-102 UDyoeg
## 4 Circadian Preference Factor Major depression || id:ieu-b-102 UDyoeg
## 5 Circadian Preference Factor Major depression || id:ieu-b-102 UDyoeg
## 6 Circadian Preference Factor Major depression || id:ieu-b-102 UDyoeg
## 7 Circadian Preference Factor Major depression || id:ieu-b-102 UDyoeg
## 8 Circadian Preference Factor Major depression || id:ieu-b-102 UDyoeg
## id.outcome samplesize SNP b se p
## 1 ieu-b-102 NA rs12145203 -1.6022089 0.4999801 1.352759e-03
## 2 ieu-b-102 NA rs139911 -1.5781838 0.3857783 4.296856e-05
## 3 ieu-b-102 NA rs308521 1.8827846 0.4960630 1.473732e-04
## 4 ieu-b-102 NA rs4269995 -1.5627811 0.4764577 1.038071e-03
## 5 ieu-b-102 NA rs61931739 -0.8751482 0.3105365 4.829645e-03
## 6 ieu-b-102 NA rs7148842 1.3712393 0.4897283 5.110261e-03
## 7 ieu-b-102 NA rs7948839 -1.5168469 0.5200618 3.537936e-03
## 8 ieu-b-102 NA rs9390489 -2.4003032 0.5297967 5.881300e-06
anx_out_dat <- read_outcome_data(
snps = circadian_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/anxiety_withNeff.txt.gz",
sep = "\t",
snp_col = "SNP",
beta_col = "effect",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
eaf_col = "MAF",
pval_col = "P",
samplesize_col = "Neff"
)
## No phenotype name specified, defaulting to 'outcome'.
anx_out_dat$outcome<- rep('Anxiety', 1, nrow(anx_out_dat))
circadian_anx_dat <- harmonise_data(circadian_exp_dat, anx_out_dat)
## Harmonising Circadian Preference Factor (UDyoeg) and Anxiety (8ftPg8)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs1122967, rs1558902, rs4417706, rs4729854, rs848552
res <- mr(circadian_anx_dat, method_list = methods)
## Analysing 'UDyoeg' on '8ftPg8'
res
## id.exposure id.outcome outcome exposure
## 1 UDyoeg 8ftPg8 Anxiety Circadian Preference Factor
## 2 UDyoeg 8ftPg8 Anxiety Circadian Preference Factor
## 3 UDyoeg 8ftPg8 Anxiety Circadian Preference Factor
## 4 UDyoeg 8ftPg8 Anxiety Circadian Preference Factor
## 5 UDyoeg 8ftPg8 Anxiety Circadian Preference Factor
## method nsnp b se pval
## 1 Maximum likelihood 93 -0.02036889 0.1496539 0.8917370
## 2 MR Egger 93 -0.48837019 0.3570585 0.1747557
## 3 Weighted mode 93 -0.10253379 0.2974381 0.7310893
## 4 Weighted median 93 -0.02332608 0.2702124 0.9312081
## 5 Inverse variance weighted 93 -0.01969967 0.1757937 0.9107748
mr_heterogeneity(circadian_anx_dat)
## id.exposure id.outcome outcome exposure
## 1 UDyoeg 8ftPg8 Anxiety Circadian Preference Factor
## 2 UDyoeg 8ftPg8 Anxiety Circadian Preference Factor
## method Q Q_df Q_pval
## 1 MR Egger 129.3152 91 0.005151018
## 2 Inverse variance weighted 132.5329 92 0.003640895
mr_pleiotropy_test(circadian_anx_dat)
## id.exposure id.outcome outcome exposure egger_intercept
## 1 UDyoeg 8ftPg8 Anxiety Circadian Preference Factor 0.008229361
## se pval
## 1 0.005468881 0.1358485
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = circadian_anx_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, circadian_anx_dat)
p1
## $UDyoeg.8ftPg8
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 UDyoeg 8ftPg8
res_single <- mr_singlesnp(circadian_anx_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome samplesize
## 1 Circadian Preference Factor Anxiety UDyoeg 8ftPg8 117893.2
## 2 Circadian Preference Factor Anxiety UDyoeg 8ftPg8 117893.2
## 3 Circadian Preference Factor Anxiety UDyoeg 8ftPg8 117893.2
## SNP b se p
## 1 rs149611468 -1.777571 0.5685584 0.0017692874
## 2 rs4729303 -4.423872 1.5504148 0.0043261339
## 3 rs9390489 8.669711 2.3013626 0.0001650835
scz_out_dat <- extract_outcome_data(snps = circadian_exp_dat$SNP, outcomes = scz)
## Extracting data for 98 SNP(s) from 1 GWAS(s)
## Finding proxies for 5 SNPs in outcome ieu-b-42
## Extracting data for 5 SNP(s) from 1 GWAS(s)
circadian_scz_dat <- harmonise_data(circadian_exp_dat, scz_out_dat)
## Harmonising Circadian Preference Factor (UDyoeg) and schizophrenia || id:ieu-b-42 (ieu-b-42)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs1122967, rs1558902, rs4417706, rs4729854, rs848552, rs9956721
res <- mr(circadian_scz_dat, method_list = methods)
## Analysing 'UDyoeg' on 'ieu-b-42'
res
## id.exposure id.outcome outcome
## 1 UDyoeg ieu-b-42 schizophrenia || id:ieu-b-42
## 2 UDyoeg ieu-b-42 schizophrenia || id:ieu-b-42
## 3 UDyoeg ieu-b-42 schizophrenia || id:ieu-b-42
## 4 UDyoeg ieu-b-42 schizophrenia || id:ieu-b-42
## 5 UDyoeg ieu-b-42 schizophrenia || id:ieu-b-42
## exposure method nsnp b
## 1 Circadian Preference Factor Maximum likelihood 92 -0.4548319
## 2 Circadian Preference Factor MR Egger 92 -0.6151879
## 3 Circadian Preference Factor Weighted mode 92 -0.3630295
## 4 Circadian Preference Factor Weighted median 92 -0.2927365
## 5 Circadian Preference Factor Inverse variance weighted 92 -0.4443889
## se pval
## 1 0.1183090 0.0001208277
## 2 0.6228068 0.3259149870
## 3 0.3888304 0.3529579176
## 4 0.1848758 0.1133252829
## 5 0.1931464 0.0214035960
mr_heterogeneity(circadian_scz_dat)
## id.exposure id.outcome outcome
## 1 UDyoeg ieu-b-42 schizophrenia || id:ieu-b-42
## 2 UDyoeg ieu-b-42 schizophrenia || id:ieu-b-42
## exposure method Q Q_df
## 1 Circadian Preference Factor MR Egger 259.0030 90
## 2 Circadian Preference Factor Inverse variance weighted 259.2427 91
## Q_pval
## 1 2.828084e-18
## 2 4.470334e-18
mr_pleiotropy_test(circadian_scz_dat)
## id.exposure id.outcome outcome
## 1 UDyoeg ieu-b-42 schizophrenia || id:ieu-b-42
## exposure egger_intercept se pval
## 1 Circadian Preference Factor 0.002109127 0.007307643 0.7735364
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = circadian_scz_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, circadian_scz_dat)
p1
## $`UDyoeg.ieu-b-42`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 UDyoeg ieu-b-42
res_single <- mr_singlesnp(circadian_scz_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure
## 1 Circadian Preference Factor schizophrenia || id:ieu-b-42 UDyoeg
## 2 Circadian Preference Factor schizophrenia || id:ieu-b-42 UDyoeg
## 3 Circadian Preference Factor schizophrenia || id:ieu-b-42 UDyoeg
## 4 Circadian Preference Factor schizophrenia || id:ieu-b-42 UDyoeg
## 5 Circadian Preference Factor schizophrenia || id:ieu-b-42 UDyoeg
## 6 Circadian Preference Factor schizophrenia || id:ieu-b-42 UDyoeg
## 7 Circadian Preference Factor schizophrenia || id:ieu-b-42 UDyoeg
## 8 Circadian Preference Factor schizophrenia || id:ieu-b-42 UDyoeg
## 9 Circadian Preference Factor schizophrenia || id:ieu-b-42 UDyoeg
## 10 Circadian Preference Factor schizophrenia || id:ieu-b-42 UDyoeg
## 11 Circadian Preference Factor schizophrenia || id:ieu-b-42 UDyoeg
## 12 Circadian Preference Factor schizophrenia || id:ieu-b-42 UDyoeg
## id.outcome samplesize SNP b se
## 1 ieu-b-42 77096 rs10196909 -4.6562618 1.1430913
## 2 ieu-b-42 77096 rs12145203 -4.1697202 1.2613134
## 3 ieu-b-42 77096 rs208829 -4.6162028 1.3173829
## 4 ieu-b-42 77096 rs2910032 -5.8433213 1.0430363
## 5 ieu-b-42 77096 rs308521 -5.0164370 1.2627058
## 6 ieu-b-42 77096 rs4075359 4.4107601 1.1726329
## 7 ieu-b-42 77096 rs4269995 4.3067960 1.1911441
## 8 ieu-b-42 77096 rs60616179 -3.1267248 1.1258176
## 9 ieu-b-42 77096 rs72720396 -3.3485300 0.9905581
## 10 ieu-b-42 77096 rs7942129 -4.4167186 1.1502100
## 11 ieu-b-42 77096 rs7948839 -4.0635244 1.2893198
## 12 ieu-b-42 77096 All - Maximum likelihood -0.4548319 0.1183090
## p
## 1 4.633285e-05
## 2 9.468678e-04
## 3 4.582035e-04
## 4 2.116210e-08
## 5 7.104228e-05
## 6 1.689542e-04
## 7 2.995602e-04
## 8 5.481381e-03
## 9 7.236783e-04
## 10 1.230726e-04
## 11 1.623337e-03
## 12 1.208277e-04
bip_out_dat <- read_outcome_data(
snps = circadian_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/BiP_withNeff.txt.gz",
sep = "\t",
snp_col = "SNP",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
# eaf_col = "MAF",
pval_col = "PVAL"
)
## No phenotype name specified, defaulting to 'outcome'.
bip_out_dat$outcome<- rep('Bipolar Disorder', 1, nrow(bip_out_dat))
circadian_bip_dat <- harmonise_data(circadian_exp_dat, bip_out_dat)
## Harmonising Circadian Preference Factor (UDyoeg) and Bipolar Disorder (F59OX8)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10495976, rs1122967, rs150594726, rs1558902, rs2585405, rs2820321, rs2968511, rs4417706, rs4470727, rs4729854, rs812925, rs848552, rs9956721
res <- mr(circadian_bip_dat, method_list = methods)
## Analysing 'UDyoeg' on 'F59OX8'
res
## id.exposure id.outcome outcome exposure
## 1 UDyoeg F59OX8 Bipolar Disorder Circadian Preference Factor
## 2 UDyoeg F59OX8 Bipolar Disorder Circadian Preference Factor
## 3 UDyoeg F59OX8 Bipolar Disorder Circadian Preference Factor
## 4 UDyoeg F59OX8 Bipolar Disorder Circadian Preference Factor
## 5 UDyoeg F59OX8 Bipolar Disorder Circadian Preference Factor
## method nsnp b se pval
## 1 Maximum likelihood 84 0.10074636 0.1050239 0.3374222
## 2 MR Egger 84 -0.13191333 0.5728807 0.8184608
## 3 Weighted mode 84 0.05469270 0.4802042 0.9095964
## 4 Weighted median 84 0.19975367 0.1872355 0.2860361
## 5 Inverse variance weighted 84 0.09606874 0.1746788 0.5823375
mr_heterogeneity(circadian_bip_dat)
## id.exposure id.outcome outcome exposure
## 1 UDyoeg F59OX8 Bipolar Disorder Circadian Preference Factor
## 2 UDyoeg F59OX8 Bipolar Disorder Circadian Preference Factor
## method Q Q_df Q_pval
## 1 MR Egger 244.7989 82 4.088039e-18
## 2 Inverse variance weighted 245.3207 83 5.978950e-18
mr_pleiotropy_test(circadian_bip_dat)
## id.exposure id.outcome outcome exposure
## 1 UDyoeg F59OX8 Bipolar Disorder Circadian Preference Factor
## egger_intercept se pval
## 1 0.002826664 0.006761209 0.6769882
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = circadian_bip_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, circadian_bip_dat)
p1
## $UDyoeg.F59OX8
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 UDyoeg F59OX8
res_single <- mr_singlesnp(circadian_bip_dat,all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome
## 1 Circadian Preference Factor Bipolar Disorder UDyoeg F59OX8
## 2 Circadian Preference Factor Bipolar Disorder UDyoeg F59OX8
## 3 Circadian Preference Factor Bipolar Disorder UDyoeg F59OX8
## 4 Circadian Preference Factor Bipolar Disorder UDyoeg F59OX8
## 5 Circadian Preference Factor Bipolar Disorder UDyoeg F59OX8
## 6 Circadian Preference Factor Bipolar Disorder UDyoeg F59OX8
## 7 Circadian Preference Factor Bipolar Disorder UDyoeg F59OX8
## 8 Circadian Preference Factor Bipolar Disorder UDyoeg F59OX8
## samplesize SNP b se p
## 1 NA rs11757278 2.263602 0.8229840 5.950779e-03
## 2 NA rs12927162 2.050435 0.7043853 3.603246e-03
## 3 NA rs17604349 -3.424321 0.7850920 1.290668e-05
## 4 NA rs2910032 -2.646332 0.8981702 3.215392e-03
## 5 NA rs34536594 -3.418520 1.0675949 1.364409e-03
## 6 NA rs4075359 3.642098 0.9858418 2.204032e-04
## 7 NA rs593955 2.253719 0.8193907 5.950779e-03
## 8 NA rs7948839 -5.590204 1.1268005 7.008438e-07
adhd_out_dat <- extract_outcome_data(snps = circadian_exp_dat$SNP, outcomes = adhd)
## Extracting data for 98 SNP(s) from 1 GWAS(s)
## Finding proxies for 4 SNPs in outcome ieu-a-1183
## Extracting data for 4 SNP(s) from 1 GWAS(s)
circadian_adhd_dat <- harmonise_data(circadian_exp_dat, adhd_out_dat)
## Harmonising Circadian Preference Factor (UDyoeg) and ADHD || id:ieu-a-1183 (ieu-a-1183)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10495976, rs1122967, rs150594726, rs1558902, rs2585405, rs2820321, rs2968511, rs4417706, rs4470727, rs812925, rs848552, rs9956721
res <- mr(circadian_adhd_dat, method_list = methods)
## Analysing 'UDyoeg' on 'ieu-a-1183'
res
## id.exposure id.outcome outcome exposure
## 1 UDyoeg ieu-a-1183 ADHD || id:ieu-a-1183 Circadian Preference Factor
## 2 UDyoeg ieu-a-1183 ADHD || id:ieu-a-1183 Circadian Preference Factor
## 3 UDyoeg ieu-a-1183 ADHD || id:ieu-a-1183 Circadian Preference Factor
## 4 UDyoeg ieu-a-1183 ADHD || id:ieu-a-1183 Circadian Preference Factor
## 5 UDyoeg ieu-a-1183 ADHD || id:ieu-a-1183 Circadian Preference Factor
## method nsnp b se pval
## 1 Maximum likelihood 82 -0.18623983 0.1492828 0.2121907
## 2 MR Egger 82 0.05959422 0.7129600 0.9335936
## 3 Weighted mode 82 -0.49985931 0.6209429 0.4231761
## 4 Weighted median 82 -0.36023305 0.2381404 0.1303580
## 5 Inverse variance weighted 82 -0.17899674 0.2165324 0.4084348
mr_heterogeneity(circadian_adhd_dat)
## id.exposure id.outcome outcome exposure
## 1 UDyoeg ieu-a-1183 ADHD || id:ieu-a-1183 Circadian Preference Factor
## 2 UDyoeg ieu-a-1183 ADHD || id:ieu-a-1183 Circadian Preference Factor
## method Q Q_df Q_pval
## 1 MR Egger 178.7213 80 1.656235e-09
## 2 Inverse variance weighted 178.9972 81 2.318519e-09
mr_pleiotropy_test(circadian_adhd_dat)
## id.exposure id.outcome outcome exposure
## 1 UDyoeg ieu-a-1183 ADHD || id:ieu-a-1183 Circadian Preference Factor
## egger_intercept se pval
## 1 -0.002950118 0.008394501 0.7261862
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = circadian_adhd_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, circadian_adhd_dat)
p1
## $`UDyoeg.ieu-a-1183`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 UDyoeg ieu-a-1183
res_single <- mr_singlesnp(circadian_adhd_dat,all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome
## 1 Circadian Preference Factor ADHD || id:ieu-a-1183 UDyoeg ieu-a-1183
## 2 Circadian Preference Factor ADHD || id:ieu-a-1183 UDyoeg ieu-a-1183
## 3 Circadian Preference Factor ADHD || id:ieu-a-1183 UDyoeg ieu-a-1183
## 4 Circadian Preference Factor ADHD || id:ieu-a-1183 UDyoeg ieu-a-1183
## 5 Circadian Preference Factor ADHD || id:ieu-a-1183 UDyoeg ieu-a-1183
## samplesize SNP b se p
## 1 55374 rs10799831 4.243400 1.549162 6.159684e-03
## 2 55374 rs2550298 -3.548281 1.263816 4.991333e-03
## 3 55374 rs4269995 5.003244 1.457960 5.998699e-04
## 4 55374 rs7047907 -6.092148 1.493208 4.505379e-05
## 5 55374 rs72720396 -4.346414 1.182756 2.380183e-04
# dpw<- fread("/Users/claire/Desktop/Desktop/sleepMR/DrinksPerWeek.txt.gz", header=T, data.table=F)
drinkspw_out_dat <- read_outcome_data(
snps = circadian_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/DrinksPerWeek.txt.gz",
sep = "\t",
snp_col = "RSID",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "REF",
other_allele_col = "ALT",
eaf_col = "AF",
pval_col = "PVALUE"
)
## No phenotype name specified, defaulting to 'outcome'.
drinkspw_out_dat$outcome<- rep('Drinks per Week', 1, nrow(drinkspw_out_dat))
circadian_dpw_dat <- harmonise_data(circadian_exp_dat, drinkspw_out_dat)
## Harmonising Circadian Preference Factor (UDyoeg) and Drinks per Week (SWfDMI)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs1122967, rs1558902, rs4417706, rs4729854, rs848552
res <- mr(circadian_dpw_dat, method_list = methods)
## Analysing 'UDyoeg' on 'SWfDMI'
res
## id.exposure id.outcome outcome exposure
## 1 UDyoeg SWfDMI Drinks per Week Circadian Preference Factor
## 2 UDyoeg SWfDMI Drinks per Week Circadian Preference Factor
## 3 UDyoeg SWfDMI Drinks per Week Circadian Preference Factor
## 4 UDyoeg SWfDMI Drinks per Week Circadian Preference Factor
## 5 UDyoeg SWfDMI Drinks per Week Circadian Preference Factor
## method nsnp b se pval
## 1 Maximum likelihood 93 0.09673006 0.02062257 2.725461e-06
## 2 MR Egger 93 0.19414157 0.10858566 7.711885e-02
## 3 Weighted mode 93 0.10149349 0.06708910 1.337541e-01
## 4 Weighted median 93 0.09604648 0.03319985 3.816069e-03
## 5 Inverse variance weighted 93 0.09592230 0.03446395 5.381489e-03
mr_heterogeneity(circadian_dpw_dat)
## id.exposure id.outcome outcome exposure
## 1 UDyoeg SWfDMI Drinks per Week Circadian Preference Factor
## 2 UDyoeg SWfDMI Drinks per Week Circadian Preference Factor
## method Q Q_df Q_pval
## 1 MR Egger 272.3485 91 5.586380e-20
## 2 Inverse variance weighted 275.0718 92 3.888068e-20
mr_pleiotropy_test(circadian_dpw_dat)
## id.exposure id.outcome outcome exposure
## 1 UDyoeg SWfDMI Drinks per Week Circadian Preference Factor
## egger_intercept se pval
## 1 -0.001221857 0.001280902 0.3426595
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = circadian_dpw_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, circadian_dpw_dat)
p1
## $UDyoeg.SWfDMI
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 UDyoeg SWfDMI
res_single <- mr_singlesnp(circadian_dpw_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome
## 1 Circadian Preference Factor Drinks per Week UDyoeg SWfDMI
## 2 Circadian Preference Factor Drinks per Week UDyoeg SWfDMI
## 3 Circadian Preference Factor Drinks per Week UDyoeg SWfDMI
## 4 Circadian Preference Factor Drinks per Week UDyoeg SWfDMI
## 5 Circadian Preference Factor Drinks per Week UDyoeg SWfDMI
## 6 Circadian Preference Factor Drinks per Week UDyoeg SWfDMI
## 7 Circadian Preference Factor Drinks per Week UDyoeg SWfDMI
## 8 Circadian Preference Factor Drinks per Week UDyoeg SWfDMI
## 9 Circadian Preference Factor Drinks per Week UDyoeg SWfDMI
## 10 Circadian Preference Factor Drinks per Week UDyoeg SWfDMI
## 11 Circadian Preference Factor Drinks per Week UDyoeg SWfDMI
## 12 Circadian Preference Factor Drinks per Week UDyoeg SWfDMI
## samplesize SNP b se
## 1 NA rs117494948 0.51462181 0.18667295
## 2 NA rs13405986 -1.31755654 0.23401281
## 3 NA rs150594726 0.67408272 0.22671855
## 4 NA rs17604349 0.57962350 0.16594572
## 5 NA rs335433 -1.03010304 0.23327240
## 6 NA rs3808477 0.66202659 0.20977115
## 7 NA rs3809162 0.99668449 0.19776109
## 8 NA rs4733462 0.70395877 0.20321539
## 9 NA rs72720396 0.59751477 0.17106798
## 10 NA All - Maximum likelihood 0.09673006 0.02062257
## 11 NA All - Weighted median 0.09604648 0.03268071
## 12 NA All - Inverse variance weighted 0.09592230 0.03446395
## p
## 1 5.836830e-03
## 2 1.799222e-08
## 3 2.946991e-03
## 4 4.778952e-04
## 5 1.005997e-05
## 6 1.599781e-03
## 7 4.659181e-07
## 8 5.320055e-04
## 9 4.778952e-04
## 10 2.725461e-06
## 11 3.293428e-03
## 12 5.381489e-03
#cigs<- fread("/Users/claire/Desktop/Desktop/sleepMR/cigs_withNeff.txt.gz", header=T, data.table = F)
cigs_out_dat <- read_outcome_data(
snps = circadian_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/cigs_withNeff.txt.gz",
sep = "\t",
snp_col = "RSID",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
eaf_col = "MAF",
pval_col = "PVALUE"
)
## No phenotype name specified, defaulting to 'outcome'.
cigs_out_dat$outcome<- rep('Cigarettes per Day', 1, nrow(cigs_out_dat))
circadian_cigs_dat <- harmonise_data(circadian_exp_dat, cigs_out_dat)
## Harmonising Circadian Preference Factor (UDyoeg) and Cigarettes per Day (UanOkJ)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs1122967, rs1558902, rs4417706, rs4729854, rs848552
res <- mr(circadian_cigs_dat, method_list = methods)
## Analysing 'UDyoeg' on 'UanOkJ'
res
## id.exposure id.outcome outcome exposure
## 1 UDyoeg UanOkJ Cigarettes per Day Circadian Preference Factor
## 2 UDyoeg UanOkJ Cigarettes per Day Circadian Preference Factor
## 3 UDyoeg UanOkJ Cigarettes per Day Circadian Preference Factor
## 4 UDyoeg UanOkJ Cigarettes per Day Circadian Preference Factor
## 5 UDyoeg UanOkJ Cigarettes per Day Circadian Preference Factor
## method nsnp b se pval
## 1 Maximum likelihood 93 0.06264775 0.05887593 0.2872998
## 2 MR Egger 93 0.18336620 0.29641118 0.5377115
## 3 Weighted mode 93 0.07010766 0.18251761 0.7017799
## 4 Weighted median 93 0.03166778 0.09226980 0.7314416
## 5 Inverse variance weighted 93 0.06025033 0.09355561 0.5195719
mr_heterogeneity(circadian_cigs_dat)
## id.exposure id.outcome outcome exposure
## 1 UDyoeg UanOkJ Cigarettes per Day Circadian Preference Factor
## 2 UDyoeg UanOkJ Cigarettes per Day Circadian Preference Factor
## method Q Q_df Q_pval
## 1 MR Egger 246.2193 91 3.118658e-16
## 2 Inverse variance weighted 246.7383 92 4.384851e-16
mr_pleiotropy_test(circadian_cigs_dat)
## id.exposure id.outcome outcome exposure
## 1 UDyoeg UanOkJ Cigarettes per Day Circadian Preference Factor
## egger_intercept se pval
## 1 -0.001529563 0.00349259 0.6624638
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = circadian_cigs_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, circadian_cigs_dat)
p1
## $UDyoeg.UanOkJ
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 UDyoeg UanOkJ
res_single <- mr_singlesnp(circadian_cigs_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome
## 1 Circadian Preference Factor Cigarettes per Day UDyoeg UanOkJ
## 2 Circadian Preference Factor Cigarettes per Day UDyoeg UanOkJ
## 3 Circadian Preference Factor Cigarettes per Day UDyoeg UanOkJ
## 4 Circadian Preference Factor Cigarettes per Day UDyoeg UanOkJ
## 5 Circadian Preference Factor Cigarettes per Day UDyoeg UanOkJ
## 6 Circadian Preference Factor Cigarettes per Day UDyoeg UanOkJ
## samplesize SNP b se p
## 1 NA rs12669911 4.699945 0.5898016 1.603668e-15
## 2 NA rs13059636 -2.189804 0.5811135 1.643705e-04
## 3 NA rs208829 -2.879999 0.6695861 1.699043e-05
## 4 NA rs4733462 1.712014 0.5804272 3.182101e-03
## 5 NA rs6577620 -1.660282 0.5925802 5.082071e-03
## 6 NA rs72720396 1.797019 0.4890866 2.385635e-04
should have 45 loci
insom<- grep("Lane", gwas_catalog$Author)
#gwas_catalog[insom,] ###
insom_gwas <-
subset(gwas_catalog,
grepl("Lane", Author) & Phenotype == "Insomnia symptoms (never/rarely vs. sometimes/usually)")
insomnia_exp_dat <- format_data(insom_gwas)
## Warning in format_data(insom_gwas): other_allele column has some values that
## are not A/C/T/G or an indel comprising only these characters or D/I. These SNPs
## will be excluded
## Warning in format_data(insom_gwas): The following SNP(s) are missing required information for the MR tests and will be excluded
## rs10280045
## rs1031654
## rs10947690
## rs11097861
## rs11191595
## rs113851554
## rs11793831
## rs1841625
## rs2192338
## rs28061
## rs324017
## rs4577309
## rs4886140
## rs4886860
nrow(insomnia_exp_dat)
## [1] 49
nrow(insomnia_exp_dat)
## [1] 49
insomnia_exp_dat$samplesize.exposure<- 259365
insomnia_exp_dat <- insomnia_exp_dat %>% as.data.table
insomnia_exp_dat <- insomnia_exp_dat[, F_STAT := qf(
pval.exposure,
df1=1,
df2=samplesize.exposure,
lower.tail=F
)] # this piece calculates the F statistic of each SNP in the IV and adds a column called F_STAT
insomnia_exp_dat$F_STAT %>% mean # to calculate the overall F stat of your exposure
## [1] 34.06865
insomnia_exp_dat$F_STAT %>% min # yo
## [1] 19.71351
dep_out_dat <- extract_outcome_data(snps = insomnia_exp_dat$SNP, outcomes = dep)
## Extracting data for 49 SNP(s) from 1 GWAS(s)
## Finding proxies for 5 SNPs in outcome ieu-b-102
## Extracting data for 5 SNP(s) from 1 GWAS(s)
insomnia_exp_dep_dat <- harmonise_data(insomnia_exp_dat, dep_out_dat)
## Harmonising Insomnia symptoms (never/rarely vs. sometimes/usually) (OBv4yn) and Major depression || id:ieu-b-102 (ieu-b-102)
## Removing the following SNPs for incompatible alleles:
## rs10280045, rs2192338, rs4886860
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10280045, rs1841625, rs2147141, rs2192338, rs2644128, rs4886860
res <- mr(insomnia_exp_dep_dat, method_list = methods)
## Analysing 'OBv4yn' on 'ieu-b-102'
res
## id.exposure id.outcome outcome
## 1 OBv4yn ieu-b-102 Major depression || id:ieu-b-102
## 2 OBv4yn ieu-b-102 Major depression || id:ieu-b-102
## 3 OBv4yn ieu-b-102 Major depression || id:ieu-b-102
## 4 OBv4yn ieu-b-102 Major depression || id:ieu-b-102
## 5 OBv4yn ieu-b-102 Major depression || id:ieu-b-102
## exposure
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 2 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 3 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 4 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 5 Insomnia symptoms (never/rarely vs. sometimes/usually)
## method nsnp b se pval
## 1 Maximum likelihood 41 0.29309918 0.02756321 2.076856e-26
## 2 MR Egger 41 -0.11776941 0.11478018 3.111934e-01
## 3 Weighted mode 41 0.04532944 0.04889632 3.594596e-01
## 4 Weighted median 41 0.10742957 0.04630670 2.034319e-02
## 5 Inverse variance weighted 41 0.26675314 0.04872829 4.392516e-08
mr_heterogeneity(insomnia_exp_dep_dat)
## id.exposure id.outcome outcome
## 1 OBv4yn ieu-b-102 Major depression || id:ieu-b-102
## 2 OBv4yn ieu-b-102 Major depression || id:ieu-b-102
## exposure
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 2 Insomnia symptoms (never/rarely vs. sometimes/usually)
## method Q Q_df Q_pval
## 1 MR Egger 114.6402 39 2.271515e-09
## 2 Inverse variance weighted 152.9367 40 4.101476e-15
mr_pleiotropy_test(insomnia_exp_dep_dat)
## id.exposure id.outcome outcome
## 1 OBv4yn ieu-b-102 Major depression || id:ieu-b-102
## exposure egger_intercept
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually) 0.01271544
## se pval
## 1 0.003522801 0.0008627778
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = insomnia_exp_dep_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, insomnia_exp_dep_dat)
p1
## $`OBv4yn.ieu-b-102`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 OBv4yn ieu-b-102
res_single <- mr_singlesnp(insomnia_exp_dep_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 2 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 3 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 4 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 5 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 6 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 7 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 8 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 9 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 10 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 11 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 12 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 13 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 14 Insomnia symptoms (never/rarely vs. sometimes/usually)
## outcome id.exposure id.outcome samplesize
## 1 Major depression || id:ieu-b-102 OBv4yn ieu-b-102 NA
## 2 Major depression || id:ieu-b-102 OBv4yn ieu-b-102 NA
## 3 Major depression || id:ieu-b-102 OBv4yn ieu-b-102 NA
## 4 Major depression || id:ieu-b-102 OBv4yn ieu-b-102 NA
## 5 Major depression || id:ieu-b-102 OBv4yn ieu-b-102 NA
## 6 Major depression || id:ieu-b-102 OBv4yn ieu-b-102 NA
## 7 Major depression || id:ieu-b-102 OBv4yn ieu-b-102 NA
## 8 Major depression || id:ieu-b-102 OBv4yn ieu-b-102 NA
## 9 Major depression || id:ieu-b-102 OBv4yn ieu-b-102 NA
## 10 Major depression || id:ieu-b-102 OBv4yn ieu-b-102 NA
## 11 Major depression || id:ieu-b-102 OBv4yn ieu-b-102 NA
## 12 Major depression || id:ieu-b-102 OBv4yn ieu-b-102 NA
## 13 Major depression || id:ieu-b-102 OBv4yn ieu-b-102 NA
## 14 Major depression || id:ieu-b-102 OBv4yn ieu-b-102 NA
## SNP b se p
## 1 rs10156602 0.7271762 0.22724257 1.374276e-03
## 2 rs10865954 1.1059139 0.23229241 1.927606e-06
## 3 rs11793074 0.6191049 0.20298522 2.288414e-03
## 4 rs12713372 0.7423257 0.21714290 6.294311e-04
## 5 rs1430205 1.1362129 0.21714290 1.671800e-07
## 6 rs1923770 0.6394034 0.14885583 1.743358e-05
## 7 rs1942262 0.5991732 0.11983464 5.733031e-07
## 8 rs2613503 1.1231849 0.18268670 7.839280e-10
## 9 rs2956278 0.5683586 0.17592052 1.234576e-03
## 10 rs35881094 0.3901000 0.11218562 5.065423e-04
## 11 rs4886140 0.4973138 0.15562200 1.395152e-03
## 12 rs6932158 0.5717417 0.14547274 8.486374e-05
## 13 All - Maximum likelihood 0.2930992 0.02756321 2.076856e-26
## 14 All - Inverse variance weighted 0.2667531 0.04872829 4.392516e-08
anx_out_dat <- read_outcome_data(
snps = insomnia_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/anxiety_withNeff.txt.gz",
sep = "\t",
snp_col = "SNP",
beta_col = "effect",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
eaf_col = "MAF",
pval_col = "P",
samplesize_col = "Neff"
)
## No phenotype name specified, defaulting to 'outcome'.
anx_out_dat$outcome<- rep('Anxiety', 1, nrow(anx_out_dat))
insom_anx_dat <- harmonise_data(insomnia_exp_dat, anx_out_dat)
## Harmonising Insomnia symptoms (never/rarely vs. sometimes/usually) (OBv4yn) and Anxiety (66McLm)
## Removing the following SNPs for incompatible alleles:
## rs10280045, rs2192338, rs4886860
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10280045, rs10947690, rs11191595, rs113851554, rs11793831, rs1841625, rs2147141, rs2192338, rs2644128, rs28061, rs4577309, rs4886860
res <- mr(insom_anx_dat, method_list = methods)
## Analysing 'OBv4yn' on '66McLm'
res
## id.exposure id.outcome outcome
## 1 OBv4yn 66McLm Anxiety
## 2 OBv4yn 66McLm Anxiety
## 3 OBv4yn 66McLm Anxiety
## 4 OBv4yn 66McLm Anxiety
## 5 OBv4yn 66McLm Anxiety
## exposure
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 2 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 3 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 4 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 5 Insomnia symptoms (never/rarely vs. sometimes/usually)
## method nsnp b se pval
## 1 Maximum likelihood 37 -0.5083527 0.1170617 1.408037e-05
## 2 MR Egger 37 0.6495107 0.3559954 7.662405e-02
## 3 Weighted mode 37 -0.2171819 0.1839615 2.455100e-01
## 4 Weighted median 37 -0.3241149 0.1756522 6.500731e-02
## 5 Inverse variance weighted 37 -0.5173412 0.1527229 7.054537e-04
mr_heterogeneity(insom_anx_dat)
## id.exposure id.outcome outcome
## 1 OBv4yn 66McLm Anxiety
## 2 OBv4yn 66McLm Anxiety
## exposure
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 2 Insomnia symptoms (never/rarely vs. sometimes/usually)
## method Q Q_df Q_pval
## 1 MR Egger 53.59881 35 0.0229807228
## 2 Inverse variance weighted 72.71904 36 0.0002791889
mr_pleiotropy_test(insom_anx_dat)
## id.exposure id.outcome outcome
## 1 OBv4yn 66McLm Anxiety
## exposure egger_intercept
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually) -0.04159447
## se pval
## 1 0.01177152 0.001174454
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = insom_anx_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, insom_anx_dat)
p1
## $OBv4yn.66McLm
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 OBv4yn 66McLm
res_single <- mr_singlesnp(insom_anx_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually) Anxiety OBv4yn
## 2 Insomnia symptoms (never/rarely vs. sometimes/usually) Anxiety OBv4yn
## 3 Insomnia symptoms (never/rarely vs. sometimes/usually) Anxiety OBv4yn
## id.outcome samplesize SNP b se
## 1 66McLm 117893.2 rs10156602 -3.5761669 1.0962526
## 2 66McLm 117893.2 All - Maximum likelihood -0.5083527 0.1170617
## 3 66McLm 117893.2 All - Inverse variance weighted -0.5173412 0.1527229
## p
## 1 1.105612e-03
## 2 1.408037e-05
## 3 7.054537e-04
scz_out_dat <- extract_outcome_data(snps = insomnia_exp_dat$SNP, outcomes = scz)
## Extracting data for 49 SNP(s) from 1 GWAS(s)
## Finding proxies for 5 SNPs in outcome ieu-b-42
## Extracting data for 5 SNP(s) from 1 GWAS(s)
insomnia_scz_dat <- harmonise_data(insomnia_exp_dat, scz_out_dat)
## Harmonising Insomnia symptoms (never/rarely vs. sometimes/usually) (OBv4yn) and schizophrenia || id:ieu-b-42 (ieu-b-42)
## Removing the following SNPs for incompatible alleles:
## rs10280045, rs2192338, rs4886860
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10280045, rs11793831, rs1841625, rs2147141, rs2192338, rs2644128, rs4886860
res <- mr(insomnia_scz_dat, method_list = methods)
## Analysing 'OBv4yn' on 'ieu-b-42'
res
## id.exposure id.outcome outcome
## 1 OBv4yn ieu-b-42 schizophrenia || id:ieu-b-42
## 2 OBv4yn ieu-b-42 schizophrenia || id:ieu-b-42
## 3 OBv4yn ieu-b-42 schizophrenia || id:ieu-b-42
## 4 OBv4yn ieu-b-42 schizophrenia || id:ieu-b-42
## 5 OBv4yn ieu-b-42 schizophrenia || id:ieu-b-42
## exposure
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 2 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 3 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 4 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 5 Insomnia symptoms (never/rarely vs. sometimes/usually)
## method nsnp b se pval
## 1 Maximum likelihood 40 -0.05733181 0.07086249 0.41848220
## 2 MR Egger 40 -0.26685673 0.38653421 0.49414870
## 3 Weighted mode 40 -0.30050111 0.13150574 0.02782872
## 4 Weighted median 40 -0.26047983 0.10782259 0.01569988
## 5 Inverse variance weighted 40 -0.05673112 0.14363634 0.69286975
mr_heterogeneity(insomnia_scz_dat)
## id.exposure id.outcome outcome
## 1 OBv4yn ieu-b-42 schizophrenia || id:ieu-b-42
## 2 OBv4yn ieu-b-42 schizophrenia || id:ieu-b-42
## exposure
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 2 Insomnia symptoms (never/rarely vs. sometimes/usually)
## method Q Q_df Q_pval
## 1 MR Egger 194.2055 38 7.594069e-23
## 2 Inverse variance weighted 195.9625 39 8.515473e-23
mr_pleiotropy_test(insomnia_scz_dat)
## id.exposure id.outcome outcome
## 1 OBv4yn ieu-b-42 schizophrenia || id:ieu-b-42
## exposure egger_intercept
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually) 0.006953808
## se pval
## 1 0.01185952 0.5611088
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = insomnia_scz_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, insomnia_scz_dat)
p1
## $`OBv4yn.ieu-b-42`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 OBv4yn ieu-b-42
res_single <- mr_singlesnp(insomnia_scz_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 2 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 3 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 4 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 5 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 6 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 7 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 8 Insomnia symptoms (never/rarely vs. sometimes/usually)
## outcome id.exposure id.outcome samplesize SNP
## 1 schizophrenia || id:ieu-b-42 OBv4yn ieu-b-42 77096 rs11651809
## 2 schizophrenia || id:ieu-b-42 OBv4yn ieu-b-42 77096 rs12713372
## 3 schizophrenia || id:ieu-b-42 OBv4yn ieu-b-42 77096 rs17669584
## 4 schizophrenia || id:ieu-b-42 OBv4yn ieu-b-42 77096 rs2062113
## 5 schizophrenia || id:ieu-b-42 OBv4yn ieu-b-42 77096 rs324017
## 6 schizophrenia || id:ieu-b-42 OBv4yn ieu-b-42 77096 rs35881094
## 7 schizophrenia || id:ieu-b-42 OBv4yn ieu-b-42 77096 rs68094047
## 8 schizophrenia || id:ieu-b-42 OBv4yn ieu-b-42 77096 rs9845387
## b se p
## 1 1.299038 0.4059704 1.375071e-03
## 2 3.312439 0.5554818 2.473729e-09
## 3 -1.640933 0.4973138 9.682554e-04
## 4 -1.681494 0.5554818 2.469197e-03
## 5 -2.320798 0.4364182 1.050124e-07
## 6 1.004469 0.2779144 3.011463e-04
## 7 -1.600234 0.4296521 1.957119e-04
## 8 1.420225 0.3599224 7.949396e-05
bip_out_dat <- read_outcome_data(
snps = insomnia_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/BiP_withNeff.txt.gz",
sep = "\t",
snp_col = "SNP",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
# eaf_col = "MAF",
pval_col = "PVAL"
)
## No phenotype name specified, defaulting to 'outcome'.
bip_out_dat$outcome<- rep('Bipolar Disorder', 1, nrow(bip_out_dat))
insomnia_bip_dat <- harmonise_data(insomnia_exp_dat, bip_out_dat)
## Harmonising Insomnia symptoms (never/rarely vs. sometimes/usually) (OBv4yn) and Bipolar Disorder (RNqGYc)
## Removing the following SNPs for incompatible alleles:
## rs10280045, rs2192338, rs4886860
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10280045, rs1031654, rs10947690, rs11097861, rs11191595, rs113851554, rs11651809, rs11793831, rs1841625, rs1923770, rs2147141, rs2192338, rs2644128, rs28061, rs324017, rs4577309, rs4886140, rs4886860
res <- mr(insomnia_bip_dat, method_list = methods)
## Analysing 'OBv4yn' on 'RNqGYc'
res
## id.exposure id.outcome outcome
## 1 OBv4yn RNqGYc Bipolar Disorder
## 2 OBv4yn RNqGYc Bipolar Disorder
## 3 OBv4yn RNqGYc Bipolar Disorder
## 4 OBv4yn RNqGYc Bipolar Disorder
## 5 OBv4yn RNqGYc Bipolar Disorder
## exposure
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 2 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 3 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 4 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 5 Insomnia symptoms (never/rarely vs. sometimes/usually)
## method nsnp b se pval
## 1 Maximum likelihood 31 0.2108701 0.07026602 0.002690729
## 2 MR Egger 31 -0.2698612 0.34902825 0.445673480
## 3 Weighted mode 31 0.1622870 0.15631623 0.307474302
## 4 Weighted median 31 0.1401818 0.10684765 0.189527614
## 5 Inverse variance weighted 31 0.2063835 0.10992536 0.060451348
mr_heterogeneity(insomnia_bip_dat)
## id.exposure id.outcome outcome
## 1 OBv4yn RNqGYc Bipolar Disorder
## 2 OBv4yn RNqGYc Bipolar Disorder
## exposure
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 2 Insomnia symptoms (never/rarely vs. sometimes/usually)
## method Q Q_df Q_pval
## 1 MR Egger 76.89836 29 3.263579e-06
## 2 Inverse variance weighted 82.35843 30 8.999585e-07
mr_pleiotropy_test(insomnia_bip_dat)
## id.exposure id.outcome outcome
## 1 OBv4yn RNqGYc Bipolar Disorder
## exposure egger_intercept
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually) 0.01441143
## se pval
## 1 0.01004309 0.1619965
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = insomnia_bip_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, insomnia_bip_dat)
p1
## $OBv4yn.RNqGYc
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 OBv4yn RNqGYc
res_single <- mr_singlesnp(insomnia_bip_dat,all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually) Bipolar Disorder
## 2 Insomnia symptoms (never/rarely vs. sometimes/usually) Bipolar Disorder
## 3 Insomnia symptoms (never/rarely vs. sometimes/usually) Bipolar Disorder
## 4 Insomnia symptoms (never/rarely vs. sometimes/usually) Bipolar Disorder
## id.exposure id.outcome samplesize SNP b
## 1 OBv4yn RNqGYc NA rs11184946 1.4642684
## 2 OBv4yn RNqGYc NA rs11635495 1.5048322
## 3 OBv4yn RNqGYc NA rs3824081 1.3030690
## 4 OBv4yn RNqGYc NA All - Maximum likelihood 0.2108701
## se p
## 1 0.47973432 0.002271340
## 2 0.46963465 0.001354095
## 3 0.47468449 0.006048757
## 4 0.07026602 0.002690729
adhd_out_dat <- extract_outcome_data(snps = insomnia_exp_dat$SNP, outcomes = adhd)
## Extracting data for 49 SNP(s) from 1 GWAS(s)
## Finding proxies for 2 SNPs in outcome ieu-a-1183
## Extracting data for 2 SNP(s) from 1 GWAS(s)
insomnia_adhd_dat <- harmonise_data(insomnia_exp_dat, adhd_out_dat)
## Harmonising Insomnia symptoms (never/rarely vs. sometimes/usually) (OBv4yn) and ADHD || id:ieu-a-1183 (ieu-a-1183)
## Removing the following SNPs for incompatible alleles:
## rs10280045, rs2192338, rs4886860
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10280045, rs1031654, rs10947690, rs11097861, rs113851554, rs11651809, rs11793831, rs1841625, rs1923770, rs2192338, rs2644128, rs28061, rs324017, rs4577309, rs4886140, rs4886860
res <- mr(insomnia_adhd_dat, method_list = methods)
## Analysing 'OBv4yn' on 'ieu-a-1183'
res
## id.exposure id.outcome outcome
## 1 OBv4yn ieu-a-1183 ADHD || id:ieu-a-1183
## 2 OBv4yn ieu-a-1183 ADHD || id:ieu-a-1183
## 3 OBv4yn ieu-a-1183 ADHD || id:ieu-a-1183
## 4 OBv4yn ieu-a-1183 ADHD || id:ieu-a-1183
## 5 OBv4yn ieu-a-1183 ADHD || id:ieu-a-1183
## exposure
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 2 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 3 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 4 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 5 Insomnia symptoms (never/rarely vs. sometimes/usually)
## method nsnp b se pval
## 1 Maximum likelihood 31 0.38373402 0.09912829 0.0001083521
## 2 MR Egger 31 0.05402753 0.50762710 0.9159728235
## 3 Weighted mode 31 0.38535436 0.19152717 0.0532744445
## 4 Weighted median 31 0.41087322 0.13875255 0.0030644891
## 5 Inverse variance weighted 31 0.37389318 0.15622429 0.0166971217
mr_heterogeneity(insomnia_adhd_dat)
## id.exposure id.outcome outcome
## 1 OBv4yn ieu-a-1183 ADHD || id:ieu-a-1183
## 2 OBv4yn ieu-a-1183 ADHD || id:ieu-a-1183
## exposure
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 2 Insomnia symptoms (never/rarely vs. sometimes/usually)
## method Q Q_df Q_pval
## 1 MR Egger 80.88021 29 8.604693e-07
## 2 Inverse variance weighted 82.10587 30 9.795253e-07
mr_pleiotropy_test(insomnia_adhd_dat)
## id.exposure id.outcome outcome
## 1 OBv4yn ieu-a-1183 ADHD || id:ieu-a-1183
## exposure egger_intercept
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually) 0.009692287
## se pval
## 1 0.01462055 0.5126155
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = insomnia_adhd_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, insomnia_adhd_dat)
p1
## $`OBv4yn.ieu-a-1183`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 OBv4yn ieu-a-1183
res_single <- mr_singlesnp(insomnia_adhd_dat,all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually) ADHD || id:ieu-a-1183
## 2 Insomnia symptoms (never/rarely vs. sometimes/usually) ADHD || id:ieu-a-1183
## 3 Insomnia symptoms (never/rarely vs. sometimes/usually) ADHD || id:ieu-a-1183
## 4 Insomnia symptoms (never/rarely vs. sometimes/usually) ADHD || id:ieu-a-1183
## 5 Insomnia symptoms (never/rarely vs. sometimes/usually) ADHD || id:ieu-a-1183
## 6 Insomnia symptoms (never/rarely vs. sometimes/usually) ADHD || id:ieu-a-1183
## 7 Insomnia symptoms (never/rarely vs. sometimes/usually) ADHD || id:ieu-a-1183
## id.exposure id.outcome samplesize SNP b
## 1 OBv4yn ieu-a-1183 55374 rs10865954 2.5853539
## 2 OBv4yn ieu-a-1183 55374 rs11804386 -1.5527490
## 3 OBv4yn ieu-a-1183 55374 rs1430205 -3.0451616
## 4 OBv4yn ieu-a-1183 55374 rs4688760 1.6374006
## 5 OBv4yn ieu-a-1183 55374 rs6593005 2.3378363
## 6 OBv4yn ieu-a-1183 55374 All - Maximum likelihood 0.3837340
## 7 OBv4yn ieu-a-1183 55374 All - Weighted median 0.4108732
## se p
## 1 0.71202673 2.823485e-04
## 2 0.48039836 1.228362e-03
## 3 0.67162805 5.787703e-06
## 4 0.50407997 1.160987e-03
## 5 0.75242541 1.889535e-03
## 6 0.09912829 1.083521e-04
## 7 0.13862383 3.037239e-03
# dpw<- fread("/Users/claire/Desktop/Desktop/sleepMR/DrinksPerWeek.txt.gz", header=T, data.table=F)
drinkspw_out_dat <- read_outcome_data(
snps = insomnia_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/DrinksPerWeek.txt.gz",
sep = "\t",
snp_col = "RSID",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "REF",
other_allele_col = "ALT",
eaf_col = "AF",
pval_col = "PVALUE"
)
## No phenotype name specified, defaulting to 'outcome'.
drinkspw_out_dat$outcome<- rep('Drinks per Week', 1, nrow(drinkspw_out_dat))
insomnia_dpw_dat <- harmonise_data(insomnia_exp_dat, drinkspw_out_dat)
## Harmonising Insomnia symptoms (never/rarely vs. sometimes/usually) (OBv4yn) and Drinks per Week (jH0BtB)
## Removing the following SNPs for incompatible alleles:
## rs10280045, rs2192338, rs4886860
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10280045, rs1031654, rs10947690, rs11097861, rs11191595, rs113851554, rs11793831, rs1841625, rs2147141, rs2192338, rs2644128, rs28061, rs324017, rs4577309, rs4886140, rs4886860
res <- mr(insomnia_dpw_dat, method_list = methods)
## Analysing 'OBv4yn' on 'jH0BtB'
res
## id.exposure id.outcome outcome
## 1 OBv4yn jH0BtB Drinks per Week
## 2 OBv4yn jH0BtB Drinks per Week
## 3 OBv4yn jH0BtB Drinks per Week
## 4 OBv4yn jH0BtB Drinks per Week
## 5 OBv4yn jH0BtB Drinks per Week
## exposure
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 2 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 3 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 4 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 5 Insomnia symptoms (never/rarely vs. sometimes/usually)
## method nsnp b se pval
## 1 Maximum likelihood 33 -0.05057106 0.01438494 0.0004388359
## 2 MR Egger 33 -0.02418010 0.07974648 0.7637538148
## 3 Weighted mode 33 -0.07483079 0.03637937 0.0479184914
## 4 Weighted median 33 -0.06110825 0.02211196 0.0057170372
## 5 Inverse variance weighted 33 -0.04650546 0.02351348 0.0479488481
mr_heterogeneity(insomnia_dpw_dat)
## id.exposure id.outcome outcome
## 1 OBv4yn jH0BtB Drinks per Week
## 2 OBv4yn jH0BtB Drinks per Week
## exposure
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 2 Insomnia symptoms (never/rarely vs. sometimes/usually)
## method Q Q_df Q_pval
## 1 MR Egger 102.3800 31 1.469288e-09
## 2 Inverse variance weighted 102.6643 32 2.463762e-09
mr_pleiotropy_test(insomnia_dpw_dat)
## id.exposure id.outcome outcome
## 1 OBv4yn jH0BtB Drinks per Week
## exposure egger_intercept
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually) -0.0006757831
## se pval
## 1 0.002303359 0.7711791
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = insomnia_dpw_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, insomnia_dpw_dat)
p1
## $OBv4yn.jH0BtB
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 OBv4yn jH0BtB
res_single <- mr_singlesnp(insomnia_dpw_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually) Drinks per Week
## 2 Insomnia symptoms (never/rarely vs. sometimes/usually) Drinks per Week
## 3 Insomnia symptoms (never/rarely vs. sometimes/usually) Drinks per Week
## 4 Insomnia symptoms (never/rarely vs. sometimes/usually) Drinks per Week
## 5 Insomnia symptoms (never/rarely vs. sometimes/usually) Drinks per Week
## 6 Insomnia symptoms (never/rarely vs. sometimes/usually) Drinks per Week
## 7 Insomnia symptoms (never/rarely vs. sometimes/usually) Drinks per Week
## 8 Insomnia symptoms (never/rarely vs. sometimes/usually) Drinks per Week
## 9 Insomnia symptoms (never/rarely vs. sometimes/usually) Drinks per Week
## id.exposure id.outcome samplesize SNP b
## 1 OBv4yn jH0BtB NA rs11793074 -0.26872368
## 2 OBv4yn jH0BtB NA rs12405761 -0.21277963
## 3 OBv4yn jH0BtB NA rs12713372 -0.34637779
## 4 OBv4yn jH0BtB NA rs1430205 -0.37853305
## 5 OBv4yn jH0BtB NA rs17669584 -0.29761555
## 6 OBv4yn jH0BtB NA rs1942262 0.17931569
## 7 OBv4yn jH0BtB NA rs2296580 0.21329750
## 8 OBv4yn jH0BtB NA rs9845387 -0.17034974
## 9 OBv4yn jH0BtB NA All - Maximum likelihood -0.05057106
## se p
## 1 0.09089714 0.0031130452
## 2 0.06598016 0.0012601531
## 3 0.09836468 0.0004293338
## 4 0.09773681 0.0001075112
## 5 0.08318608 0.0003466194
## 6 0.05431316 0.0009616426
## 7 0.07206655 0.0030790905
## 8 0.06220293 0.0061698993
## 9 0.01438494 0.0004388359
#cigs<- fread("/Users/claire/Desktop/Desktop/sleepMR/cigs_withNeff.txt.gz", header=T, data.table = F)
cigs_out_dat <- read_outcome_data(
snps = insomnia_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/cigs_withNeff.txt.gz",
sep = "\t",
snp_col = "RSID",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
eaf_col = "MAF",
pval_col = "PVALUE"
)
## No phenotype name specified, defaulting to 'outcome'.
cigs_out_dat$outcome<- rep('Cigarettes per Day', 1, nrow(cigs_out_dat))
insom_cigs_dat <- harmonise_data(insomnia_exp_dat, cigs_out_dat)
## Harmonising Insomnia symptoms (never/rarely vs. sometimes/usually) (OBv4yn) and Cigarettes per Day (YpjVvT)
## Removing the following SNPs for incompatible alleles:
## rs10280045, rs2192338, rs4886860
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10280045, rs1031654, rs10947690, rs11097861, rs11191595, rs113851554, rs11793831, rs1841625, rs2147141, rs2192338, rs2644128, rs28061, rs324017, rs4577309, rs4886140, rs4886860
res <- mr(insom_cigs_dat, method_list = methods)
## Analysing 'OBv4yn' on 'YpjVvT'
res
## id.exposure id.outcome outcome
## 1 OBv4yn YpjVvT Cigarettes per Day
## 2 OBv4yn YpjVvT Cigarettes per Day
## 3 OBv4yn YpjVvT Cigarettes per Day
## 4 OBv4yn YpjVvT Cigarettes per Day
## 5 OBv4yn YpjVvT Cigarettes per Day
## exposure
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 2 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 3 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 4 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 5 Insomnia symptoms (never/rarely vs. sometimes/usually)
## method nsnp b se pval
## 1 Maximum likelihood 33 -0.1247614 0.04013176 0.001878520
## 2 MR Egger 33 -0.3039990 0.22102635 0.178866664
## 3 Weighted mode 33 -0.1787585 0.09710822 0.074937024
## 4 Weighted median 33 -0.1673192 0.06354738 0.008463859
## 5 Inverse variance weighted 33 -0.1205683 0.06616556 0.068421288
mr_heterogeneity(insom_cigs_dat)
## id.exposure id.outcome outcome
## 1 OBv4yn YpjVvT Cigarettes per Day
## 2 OBv4yn YpjVvT Cigarettes per Day
## exposure
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually)
## 2 Insomnia symptoms (never/rarely vs. sometimes/usually)
## method Q Q_df Q_pval
## 1 MR Egger 97.22540 31 9.325147e-09
## 2 Inverse variance weighted 99.59991 32 7.324466e-09
mr_pleiotropy_test(insom_cigs_dat)
## id.exposure id.outcome outcome
## 1 OBv4yn YpjVvT Cigarettes per Day
## exposure egger_intercept
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually) 0.005558881
## se pval
## 1 0.006388644 0.3909234
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = insom_cigs_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, insom_cigs_dat)
p1
## $OBv4yn.YpjVvT
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 OBv4yn YpjVvT
res_single <- mr_singlesnp(insom_cigs_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome
## 1 Insomnia symptoms (never/rarely vs. sometimes/usually) Cigarettes per Day
## 2 Insomnia symptoms (never/rarely vs. sometimes/usually) Cigarettes per Day
## 3 Insomnia symptoms (never/rarely vs. sometimes/usually) Cigarettes per Day
## 4 Insomnia symptoms (never/rarely vs. sometimes/usually) Cigarettes per Day
## id.exposure id.outcome samplesize SNP b
## 1 OBv4yn YpjVvT NA rs10865954 -1.2885773
## 2 OBv4yn YpjVvT NA rs11651809 0.5850046
## 3 OBv4yn YpjVvT NA rs2062113 0.8880670
## 4 OBv4yn YpjVvT NA All - Maximum likelihood -0.1247614
## se p
## 1 0.29561992 1.307185e-05
## 2 0.20721928 4.755894e-03
## 3 0.28296168 1.698318e-03
## 4 0.04013176 1.878520e-03
should have 22 loci
does not have sufficient loci (only 1!)
active<- grep("Jones SE", gwas_catalog$Author)
#gwas_catalog[active,]$Phenotype ###
episodes_gwas <-
subset(gwas_catalog,
grepl("Jones SE", Author) & Phenotype == "Sleep (number of episodes)")
#head(episodes_gwas)
episodes_exp_dat <- format_data(episodes_gwas)
nrow(episodes_exp_dat)
## [1] 1
eff_full<- fread("/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/effic.txt.gz", header=T, data.table = F)
eff<- fread("/Users/claire/Desktop/sleepGWAS/component/effic_comp/GenomicRiskLoci.txt", header=T, data.table=F)
#head(eff)
#head(eff_full)
eff<- eff %>% select(rsID) %>%
rename(SNP=rsID)
eff_full<- eff_full %>% right_join(eff)
## Joining with `by = join_by(SNP)`
#head(eff_full)
effic_exp_dat <- format_data(eff_full, type="exposure",
snp_col = "SNP", beta_col = "beta", se_col = "SE", effect_allele_col = "A1", other_allele_col = "A2", eaf_col = "MAF", pval_col = "p", samplesize_col = "N")
## No phenotype name specified, defaulting to 'exposure'.
effic_exp_dat$exposure<- rep("Efficiency", 1, nrow(effic_exp_dat))
nrow(effic_exp_dat)
## [1] 5
effic_exp_dat <- effic_exp_dat %>% as.data.table
effic_exp_dat <- effic_exp_dat[, F_STAT := qf(
pval.exposure,
df1=1,
df2=samplesize.exposure,
lower.tail=F
)] # this piece calculates the F statistic of each SNP in the IV and adds a column called F_STAT
effic_exp_dat$F_STAT %>% mean # to calculate the overall F stat of your exposure
## [1] 45.57118
effic_exp_dat$F_STAT %>% min # yo
## [1] 30.64962
dep_out_dat <- extract_outcome_data(snps = effic_exp_dat$SNP, outcomes = dep)
## Extracting data for 5 SNP(s) from 1 GWAS(s)
efficiency_exp_dep_dat <- harmonise_data(effic_exp_dat, dep_out_dat)
## Harmonising Efficiency (GDcEZT) and Major depression || id:ieu-b-102 (ieu-b-102)
res <- mr(efficiency_exp_dep_dat, method_list = methods)
## Analysing 'GDcEZT' on 'ieu-b-102'
res
## id.exposure id.outcome outcome exposure
## 1 GDcEZT ieu-b-102 Major depression || id:ieu-b-102 Efficiency
## 2 GDcEZT ieu-b-102 Major depression || id:ieu-b-102 Efficiency
## 3 GDcEZT ieu-b-102 Major depression || id:ieu-b-102 Efficiency
## 4 GDcEZT ieu-b-102 Major depression || id:ieu-b-102 Efficiency
## 5 GDcEZT ieu-b-102 Major depression || id:ieu-b-102 Efficiency
## method nsnp b se pval
## 1 Maximum likelihood 5 -0.107119338 0.06235467 0.08581413
## 2 MR Egger 5 0.113785364 0.12944401 0.44410264
## 3 Weighted mode 5 0.001679945 0.07950259 0.98415345
## 4 Weighted median 5 -0.062953420 0.07370644 0.39304395
## 5 Inverse variance weighted 5 -0.104391327 0.07402873 0.15849656
sleep_psych_MR<- rbind(sleep_psych_MR, res)
mr_heterogeneity(efficiency_exp_dep_dat)
## id.exposure id.outcome outcome exposure
## 1 GDcEZT ieu-b-102 Major depression || id:ieu-b-102 Efficiency
## 2 GDcEZT ieu-b-102 Major depression || id:ieu-b-102 Efficiency
## method Q Q_df Q_pval
## 1 MR Egger 2.204286 3 0.5311047
## 2 Inverse variance weighted 5.861438 4 0.2097379
mr_pleiotropy_test(efficiency_exp_dep_dat)
## id.exposure id.outcome outcome exposure
## 1 GDcEZT ieu-b-102 Major depression || id:ieu-b-102 Efficiency
## egger_intercept se pval
## 1 -0.0109131 0.005706589 0.151772
p1 <- mr_scatter_plot(res, efficiency_exp_dep_dat)
p1
## $`GDcEZT.ieu-b-102`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 GDcEZT ieu-b-102
res_single <- mr_singlesnp(efficiency_exp_dep_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome samplesize
## 1 Efficiency Major depression || id:ieu-b-102 GDcEZT ieu-b-102 NA
## SNP b se p
## 1 rs13094687 -0.4415994 0.1599494 0.005764769
anx_out_dat <- read_outcome_data(
snps = effic_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/anxiety_withNeff.txt.gz",
sep = "\t",
snp_col = "SNP",
beta_col = "effect",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
eaf_col = "MAF",
pval_col = "P",
samplesize_col = "Neff"
)
## No phenotype name specified, defaulting to 'outcome'.
anx_out_dat$outcome<- rep('Anxiety', 1, nrow(anx_out_dat))
effic_anx_dat <- harmonise_data(effic_exp_dat, anx_out_dat)
## Harmonising Efficiency (GDcEZT) and Anxiety (zfBdQP)
res <- mr(effic_anx_dat, method_list = methods)
## Analysing 'GDcEZT' on 'zfBdQP'
res
## id.exposure id.outcome outcome exposure method nsnp
## 1 GDcEZT zfBdQP Anxiety Efficiency Maximum likelihood 5
## 2 GDcEZT zfBdQP Anxiety Efficiency MR Egger 5
## 3 GDcEZT zfBdQP Anxiety Efficiency Weighted mode 5
## 4 GDcEZT zfBdQP Anxiety Efficiency Weighted median 5
## 5 GDcEZT zfBdQP Anxiety Efficiency Inverse variance weighted 5
## b se pval
## 1 0.0657904319 0.1575535 0.6762577
## 2 -0.2371412163 0.3298658 0.5241378
## 3 0.0008652995 0.1858427 0.9965080
## 4 0.0279757673 0.1778911 0.8750372
## 5 0.0654702270 0.1569549 0.6765850
sleep_psych_MR<- rbind(sleep_psych_MR, res)
mr_heterogeneity(effic_anx_dat)
## id.exposure id.outcome outcome exposure method Q
## 1 GDcEZT zfBdQP Anxiety Efficiency MR Egger 0.3668579
## 2 GDcEZT zfBdQP Anxiety Efficiency Inverse variance weighted 1.4547331
## Q_df Q_pval
## 1 3 0.9470005
## 2 4 0.8346285
mr_pleiotropy_test(effic_anx_dat)
## id.exposure id.outcome outcome exposure egger_intercept se
## 1 GDcEZT zfBdQP Anxiety Efficiency 0.02105005 0.02018197
## pval
## 1 0.3735963
p1 <- mr_scatter_plot(res, effic_anx_dat)
p1
## $GDcEZT.zfBdQP
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 GDcEZT zfBdQP
res_single <- mr_singlesnp(effic_anx_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## [1] exposure outcome id.exposure id.outcome samplesize SNP
## [7] b se p
## <0 rows> (or 0-length row.names)
scz_out_dat <- extract_outcome_data(snps = effic_exp_dat$SNP, outcomes = scz)
## Extracting data for 5 SNP(s) from 1 GWAS(s)
efficiency_scz_dat <- harmonise_data(effic_exp_dat, scz_out_dat)
## Harmonising Efficiency (GDcEZT) and schizophrenia || id:ieu-b-42 (ieu-b-42)
res <- mr(efficiency_scz_dat, method_list = methods)
## Analysing 'GDcEZT' on 'ieu-b-42'
res
## id.exposure id.outcome outcome exposure
## 1 GDcEZT ieu-b-42 schizophrenia || id:ieu-b-42 Efficiency
## 2 GDcEZT ieu-b-42 schizophrenia || id:ieu-b-42 Efficiency
## 3 GDcEZT ieu-b-42 schizophrenia || id:ieu-b-42 Efficiency
## 4 GDcEZT ieu-b-42 schizophrenia || id:ieu-b-42 Efficiency
## 5 GDcEZT ieu-b-42 schizophrenia || id:ieu-b-42 Efficiency
## method nsnp b se pval
## 1 Maximum likelihood 5 0.10423101 0.1684266 0.53601429
## 2 MR Egger 5 1.18252070 0.7632695 0.21908164
## 3 Weighted mode 5 0.53009273 0.2139831 0.06841145
## 4 Weighted median 5 0.48720320 0.1990721 0.01439030
## 5 Inverse variance weighted 5 0.09510575 0.4261437 0.82339723
mr_heterogeneity(efficiency_scz_dat)
## id.exposure id.outcome outcome exposure
## 1 GDcEZT ieu-b-42 schizophrenia || id:ieu-b-42 Efficiency
## 2 GDcEZT ieu-b-42 schizophrenia || id:ieu-b-42 Efficiency
## method Q Q_df Q_pval
## 1 MR Egger 15.89710 3 0.001190417
## 2 Inverse variance weighted 29.72639 4 0.000005564
mr_pleiotropy_test(efficiency_scz_dat)
## id.exposure id.outcome outcome exposure
## 1 GDcEZT ieu-b-42 schizophrenia || id:ieu-b-42 Efficiency
## egger_intercept se pval
## 1 -0.05413207 0.03350836 0.2046212
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = efficiency_scz_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, efficiency_scz_dat)
p1
## $`GDcEZT.ieu-b-42`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 GDcEZT ieu-b-42
res_single <- mr_singlesnp(efficiency_scz_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome samplesize
## 1 Efficiency schizophrenia || id:ieu-b-42 GDcEZT ieu-b-42 77096
## SNP b se p
## 1 rs13094687 -1.849814 0.4033506 4.515576e-06
bip_out_dat <- read_outcome_data(
snps = effic_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/BiP_withNeff.txt.gz",
sep = "\t",
snp_col = "SNP",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
# eaf_col = "MAF",
pval_col = "PVAL"
)
## No phenotype name specified, defaulting to 'outcome'.
bip_out_dat$outcome<- rep('Bipolar Disorder', 1, nrow(bip_out_dat))
efficiency_bip_dat <- harmonise_data(effic_exp_dat, bip_out_dat)
## Harmonising Efficiency (GDcEZT) and Bipolar Disorder (bbLDNL)
res <- mr(efficiency_bip_dat, method_list = methods)
## Analysing 'GDcEZT' on 'bbLDNL'
res
## id.exposure id.outcome outcome exposure method
## 1 GDcEZT bbLDNL Bipolar Disorder Efficiency Maximum likelihood
## 2 GDcEZT bbLDNL Bipolar Disorder Efficiency MR Egger
## 3 GDcEZT bbLDNL Bipolar Disorder Efficiency Weighted mode
## 4 GDcEZT bbLDNL Bipolar Disorder Efficiency Weighted median
## 5 GDcEZT bbLDNL Bipolar Disorder Efficiency Inverse variance weighted
## nsnp b se pval
## 1 5 -0.3472732 0.1454732 0.01697741
## 2 5 0.4322166 0.6055203 0.52687607
## 3 5 -0.0360538 0.1667173 0.83936826
## 4 5 -0.0465839 0.1720546 0.78658276
## 5 5 -0.3140247 0.3169221 0.32175496
mr_heterogeneity(efficiency_bip_dat)
## id.exposure id.outcome outcome exposure method
## 1 GDcEZT bbLDNL Bipolar Disorder Efficiency MR Egger
## 2 GDcEZT bbLDNL Bipolar Disorder Efficiency Inverse variance weighted
## Q Q_df Q_pval
## 1 12.99666 3 0.0046438375
## 2 21.44677 4 0.0002581934
mr_pleiotropy_test(efficiency_bip_dat)
## id.exposure id.outcome outcome exposure egger_intercept se
## 1 GDcEZT bbLDNL Bipolar Disorder Efficiency -0.03681544 0.02636052
## pval
## 1 0.2569199
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = efficiency_bip_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, efficiency_bip_dat)
p1
## $GDcEZT.bbLDNL
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 GDcEZT bbLDNL
res_single <- mr_singlesnp(efficiency_bip_dat,all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome samplesize SNP
## 1 Efficiency Bipolar Disorder GDcEZT bbLDNL NA rs13094687
## b se p
## 1 -1.790764 0.347716 2.603791e-07
adhd_out_dat <- extract_outcome_data(snps = effic_exp_dat$SNP, outcomes = adhd)
## Extracting data for 5 SNP(s) from 1 GWAS(s)
efficiency_adhd_dat <- harmonise_data(effic_exp_dat, adhd_out_dat)
## Harmonising Efficiency (GDcEZT) and ADHD || id:ieu-a-1183 (ieu-a-1183)
res <- mr(efficiency_adhd_dat, method_list = methods)
## Analysing 'GDcEZT' on 'ieu-a-1183'
res
## id.exposure id.outcome outcome exposure
## 1 GDcEZT ieu-a-1183 ADHD || id:ieu-a-1183 Efficiency
## 2 GDcEZT ieu-a-1183 ADHD || id:ieu-a-1183 Efficiency
## 3 GDcEZT ieu-a-1183 ADHD || id:ieu-a-1183 Efficiency
## 4 GDcEZT ieu-a-1183 ADHD || id:ieu-a-1183 Efficiency
## 5 GDcEZT ieu-a-1183 ADHD || id:ieu-a-1183 Efficiency
## method nsnp b se pval
## 1 Maximum likelihood 5 0.27962352 0.2097208 0.1824291
## 2 MR Egger 5 0.62308329 1.0987427 0.6103138
## 3 Weighted mode 5 -0.10836141 0.2709737 0.7096677
## 4 Weighted median 5 -0.08732061 0.2617492 0.7386783
## 5 Inverse variance weighted 5 0.25704036 0.4533974 0.5707681
mr_heterogeneity(efficiency_adhd_dat)
## id.exposure id.outcome outcome exposure
## 1 GDcEZT ieu-a-1183 ADHD || id:ieu-a-1183 Efficiency
## 2 GDcEZT ieu-a-1183 ADHD || id:ieu-a-1183 Efficiency
## method Q Q_df Q_pval
## 1 MR Egger 19.75201 3 0.0001910596
## 2 Inverse variance weighted 20.68503 4 0.0003656047
mr_pleiotropy_test(efficiency_adhd_dat)
## id.exposure id.outcome outcome exposure egger_intercept
## 1 GDcEZT ieu-a-1183 ADHD || id:ieu-a-1183 Efficiency -0.0176609
## se pval
## 1 0.04691514 0.7316343
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = efficiency_adhd_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, efficiency_adhd_dat)
p1
## $`GDcEZT.ieu-a-1183`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 GDcEZT ieu-a-1183
res_single <- mr_singlesnp(efficiency_adhd_dat,all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome samplesize SNP
## 1 Efficiency ADHD || id:ieu-a-1183 GDcEZT ieu-a-1183 55374 rs17400325
## b se p
## 1 2.347519 0.5372395 1.244772e-05
# dpw<- fread("/Users/claire/Desktop/Desktop/sleepMR/DrinksPerWeek.txt.gz", header=T, data.table=F)
drinkspw_out_dat <- read_outcome_data(
snps = effic_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/DrinksPerWeek.txt.gz",
sep = "\t",
snp_col = "RSID",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "REF",
other_allele_col = "ALT",
eaf_col = "AF",
pval_col = "PVALUE"
)
## No phenotype name specified, defaulting to 'outcome'.
drinkspw_out_dat$outcome<- rep('Drinks per Week', 1, nrow(drinkspw_out_dat))
efficiency_dpw_dat <- harmonise_data(effic_exp_dat, drinkspw_out_dat)
## Harmonising Efficiency (GDcEZT) and Drinks per Week (0zfQ7o)
res <- mr(efficiency_dpw_dat, method_list = methods)
## Analysing 'GDcEZT' on '0zfQ7o'
res
## id.exposure id.outcome outcome exposure method
## 1 GDcEZT 0zfQ7o Drinks per Week Efficiency Maximum likelihood
## 2 GDcEZT 0zfQ7o Drinks per Week Efficiency MR Egger
## 3 GDcEZT 0zfQ7o Drinks per Week Efficiency Weighted mode
## 4 GDcEZT 0zfQ7o Drinks per Week Efficiency Weighted median
## 5 GDcEZT 0zfQ7o Drinks per Week Efficiency Inverse variance weighted
## nsnp b se pval
## 1 5 -0.02117207 0.02849268 0.4574390
## 2 5 0.03329073 0.13912641 0.8263014
## 3 5 0.05427187 0.04116256 0.2577701
## 4 5 0.04546139 0.03620457 0.2092316
## 5 5 -0.01945538 0.05928636 0.7427911
mr_heterogeneity(efficiency_dpw_dat)
## id.exposure id.outcome outcome exposure method
## 1 GDcEZT 0zfQ7o Drinks per Week Efficiency MR Egger
## 2 GDcEZT 0zfQ7o Drinks per Week Efficiency Inverse variance weighted
## Q Q_df Q_pval
## 1 17.83612 3 0.0004754409
## 2 18.94301 4 0.0008064661
mr_pleiotropy_test(efficiency_dpw_dat)
## id.exposure id.outcome outcome exposure egger_intercept se
## 1 GDcEZT 0zfQ7o Drinks per Week Efficiency -0.002668788 0.006185145
## pval
## 1 0.695245
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = efficiency_dpw_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, efficiency_dpw_dat)
p1
## $GDcEZT.0zfQ7o
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 GDcEZT 0zfQ7o
res_single <- mr_singlesnp(efficiency_dpw_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome samplesize SNP
## 1 Efficiency Drinks per Week GDcEZT 0zfQ7o NA rs13094687
## b se p
## 1 -0.2313143 0.07172753 0.001260153
#cigs<- fread("/Users/claire/Desktop/Desktop/sleepMR/cigs_withNeff.txt.gz", header=T, data.table = F)
cigs_out_dat <- read_outcome_data(
snps = effic_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/cigs_withNeff.txt.gz",
sep = "\t",
snp_col = "RSID",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
eaf_col = "MAF",
pval_col = "PVALUE"
)
## No phenotype name specified, defaulting to 'outcome'.
cigs_out_dat$outcome<- rep('Cigarettes per Day', 1, nrow(cigs_out_dat))
efficiency_cigs_dat <- harmonise_data(effic_exp_dat, cigs_out_dat)
## Harmonising Efficiency (GDcEZT) and Cigarettes per Day (mgNJjy)
res <- mr(efficiency_cigs_dat, method_list = methods)
## Analysing 'GDcEZT' on 'mgNJjy'
res
## id.exposure id.outcome outcome exposure
## 1 GDcEZT mgNJjy Cigarettes per Day Efficiency
## 2 GDcEZT mgNJjy Cigarettes per Day Efficiency
## 3 GDcEZT mgNJjy Cigarettes per Day Efficiency
## 4 GDcEZT mgNJjy Cigarettes per Day Efficiency
## 5 GDcEZT mgNJjy Cigarettes per Day Efficiency
## method nsnp b se pval
## 1 Maximum likelihood 5 -0.04784597 0.07913275 0.5454255
## 2 MR Egger 5 -0.24347085 0.16459223 0.2356274
## 3 Weighted mode 5 -0.10746079 0.11348969 0.3973178
## 4 Weighted median 5 -0.09980507 0.09638220 0.3004292
## 5 Inverse variance weighted 5 -0.04714966 0.07848026 0.5479841
sleep_psych_MR<- rbind(sleep_psych_MR, res)
mr_heterogeneity(efficiency_cigs_dat)
## id.exposure id.outcome outcome exposure
## 1 GDcEZT mgNJjy Cigarettes per Day Efficiency
## 2 GDcEZT mgNJjy Cigarettes per Day Efficiency
## method Q Q_df Q_pval
## 1 MR Egger 1.395195 3 0.7066615
## 2 Inverse variance weighted 3.236539 4 0.5190496
mr_pleiotropy_test(efficiency_cigs_dat)
## id.exposure id.outcome outcome exposure egger_intercept
## 1 GDcEZT mgNJjy Cigarettes per Day Efficiency 0.00986336
## se pval
## 1 0.00726871 0.2678666
p1 <- mr_scatter_plot(res, efficiency_cigs_dat)
p1
## $GDcEZT.mgNJjy
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 GDcEZT mgNJjy
res_single <- mr_singlesnp(efficiency_cigs_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## [1] exposure outcome id.exposure id.outcome samplesize SNP
## [7] b se p
## <0 rows> (or 0-length row.names)
## exposure data
eff_full<- fread("/Users/claire/Desktop//sleepGWAS/sleep_rr_upd/efficiency_gsem.txt.gz", header=T, data.table = F)
eff<- fread("/Users/claire/Desktop/sleepGWAS/FUMA_out/effic/GenomicRiskLoci.txt", header=T, data.table=F)
#head(eff)
#head(eff_full)
eff<- eff %>% select(rsID) %>%
rename(SNP=rsID)
eff_full<- eff_full %>% right_join(eff)
## Joining with `by = join_by(SNP)`
#head(eff_full)
effic_exp_dat <- format_data(eff_full, type="exposure",
snp_col = "SNP", beta_col = "est", se_col = "SE", effect_allele_col = "A1", other_allele_col = "A2", eaf_col = "MAF", pval_col = "Pval_Estimate")
## No phenotype name specified, defaulting to 'exposure'.
effic_exp_dat$exposure<- rep("Efficiency Factor", 1, nrow(effic_exp_dat))
#head(effic_exp_dat) ### this is the exposure data frame. looks the same as online phenos
effic_exp_dat$samplesize.exposure<- 31645
nrow(effic_exp_dat)
## [1] 8
effic_exp_dat <- effic_exp_dat %>% as.data.table
effic_exp_dat <- effic_exp_dat[, F_STAT := qf(
pval.exposure,
df1=1,
df2=samplesize.exposure,
lower.tail=F
)] # this piece calculates the F statistic of each SNP in the IV and adds a column called F_STAT
effic_exp_dat$F_STAT %>% mean # to calculate the overall F stat of your exposure
## [1] 38.25282
effic_exp_dat$F_STAT %>% min # y
## [1] 30.5137
dep_out_dat <- extract_outcome_data(snps = effic_exp_dat$SNP, outcomes = dep)
## Extracting data for 8 SNP(s) from 1 GWAS(s)
efficiency_exp_dep_dat <- harmonise_data(effic_exp_dat, dep_out_dat)
## Harmonising Efficiency Factor (z8VC6t) and Major depression || id:ieu-b-102 (ieu-b-102)
res <- mr(efficiency_exp_dep_dat, method_list = methods)
## Analysing 'z8VC6t' on 'ieu-b-102'
res
## id.exposure id.outcome outcome exposure
## 1 z8VC6t ieu-b-102 Major depression || id:ieu-b-102 Efficiency Factor
## 2 z8VC6t ieu-b-102 Major depression || id:ieu-b-102 Efficiency Factor
## 3 z8VC6t ieu-b-102 Major depression || id:ieu-b-102 Efficiency Factor
## 4 z8VC6t ieu-b-102 Major depression || id:ieu-b-102 Efficiency Factor
## 5 z8VC6t ieu-b-102 Major depression || id:ieu-b-102 Efficiency Factor
## method nsnp b se pval
## 1 Maximum likelihood 8 -0.41928233 0.09932105 0.0000242698
## 2 MR Egger 8 0.09328376 0.21496672 0.6794975888
## 3 Weighted mode 8 -0.16271281 0.16198349 0.3485890761
## 4 Weighted median 8 -0.23747275 0.13502202 0.0786164926
## 5 Inverse variance weighted 8 -0.40079668 0.13010511 0.0020661133
sleep_psych_MR<- rbind(sleep_psych_MR, res)
mr_heterogeneity(efficiency_exp_dep_dat)
## id.exposure id.outcome outcome exposure
## 1 z8VC6t ieu-b-102 Major depression || id:ieu-b-102 Efficiency Factor
## 2 z8VC6t ieu-b-102 Major depression || id:ieu-b-102 Efficiency Factor
## method Q Q_df Q_pval
## 1 MR Egger 6.351101 6 0.38502982
## 2 Inverse variance weighted 13.367534 7 0.06364398
mr_pleiotropy_test(efficiency_exp_dep_dat)
## id.exposure id.outcome outcome exposure
## 1 z8VC6t ieu-b-102 Major depression || id:ieu-b-102 Efficiency Factor
## egger_intercept se pval
## 1 -0.01244843 0.004835096 0.04207399
p1 <- mr_scatter_plot(res, efficiency_exp_dep_dat)
p1
## $`z8VC6t.ieu-b-102`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 z8VC6t ieu-b-102
res_single <- mr_singlesnp(efficiency_exp_dep_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome
## 1 Efficiency Factor Major depression || id:ieu-b-102 z8VC6t ieu-b-102
## 2 Efficiency Factor Major depression || id:ieu-b-102 z8VC6t ieu-b-102
## 3 Efficiency Factor Major depression || id:ieu-b-102 z8VC6t ieu-b-102
## samplesize SNP b se p
## 1 NA rs3755799 -1.0396023 0.27296821 0.0001398063
## 2 NA All - Maximum likelihood -0.4192823 0.09932105 0.0000242698
## 3 NA All - Inverse variance weighted -0.4007967 0.13010511 0.0020661133
anx_out_dat <- read_outcome_data(
snps = effic_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/anxiety_withNeff.txt.gz",
sep = "\t",
snp_col = "SNP",
beta_col = "effect",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
eaf_col = "MAF",
pval_col = "P",
samplesize_col = "Neff"
)
## No phenotype name specified, defaulting to 'outcome'.
anx_out_dat$outcome<- rep('Anxiety', 1, nrow(anx_out_dat))
effic_anx_dat <- harmonise_data(effic_exp_dat, anx_out_dat)
## Harmonising Efficiency Factor (z8VC6t) and Anxiety (YrdiNe)
res <- mr(effic_anx_dat, method_list = methods)
## Analysing 'z8VC6t' on 'YrdiNe'
res
## id.exposure id.outcome outcome exposure method
## 1 z8VC6t YrdiNe Anxiety Efficiency Factor Maximum likelihood
## 2 z8VC6t YrdiNe Anxiety Efficiency Factor MR Egger
## 3 z8VC6t YrdiNe Anxiety Efficiency Factor Weighted mode
## 4 z8VC6t YrdiNe Anxiety Efficiency Factor Weighted median
## 5 z8VC6t YrdiNe Anxiety Efficiency Factor Inverse variance weighted
## nsnp b se pval
## 1 8 0.3999299 0.2181343 0.06674138
## 2 8 0.1054159 0.3848878 0.79335584
## 3 8 0.2493346 0.2677853 0.38279185
## 4 8 0.2489831 0.2596375 0.33757674
## 5 8 0.3937806 0.2113330 0.06241755
sleep_psych_MR<- rbind(sleep_psych_MR, res)
mr_heterogeneity(effic_anx_dat)
## id.exposure id.outcome outcome exposure method
## 1 z8VC6t YrdiNe Anxiety Efficiency Factor MR Egger
## 2 z8VC6t YrdiNe Anxiety Efficiency Factor Inverse variance weighted
## Q Q_df Q_pval
## 1 4.137953 6 0.6580137
## 2 4.941554 7 0.6670956
mr_pleiotropy_test(effic_anx_dat)
## id.exposure id.outcome outcome exposure egger_intercept se
## 1 z8VC6t YrdiNe Anxiety Efficiency Factor 0.01258802 0.01404227
## pval
## 1 0.4045486
p1 <- mr_scatter_plot(res, effic_anx_dat)
p1
## $z8VC6t.YrdiNe
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 z8VC6t YrdiNe
res_single <- mr_singlesnp(effic_anx_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## [1] exposure outcome id.exposure id.outcome samplesize SNP
## [7] b se p
## <0 rows> (or 0-length row.names)
scz_out_dat <- extract_outcome_data(snps = effic_exp_dat$SNP, outcomes = scz)
## Extracting data for 8 SNP(s) from 1 GWAS(s)
efficiency_scz_dat <- harmonise_data(effic_exp_dat, scz_out_dat)
## Harmonising Efficiency Factor (z8VC6t) and schizophrenia || id:ieu-b-42 (ieu-b-42)
res <- mr(efficiency_scz_dat, method_list = methods)
## Analysing 'z8VC6t' on 'ieu-b-42'
res
## id.exposure id.outcome outcome exposure
## 1 z8VC6t ieu-b-42 schizophrenia || id:ieu-b-42 Efficiency Factor
## 2 z8VC6t ieu-b-42 schizophrenia || id:ieu-b-42 Efficiency Factor
## 3 z8VC6t ieu-b-42 schizophrenia || id:ieu-b-42 Efficiency Factor
## 4 z8VC6t ieu-b-42 schizophrenia || id:ieu-b-42 Efficiency Factor
## 5 z8VC6t ieu-b-42 schizophrenia || id:ieu-b-42 Efficiency Factor
## method nsnp b se pval
## 1 Maximum likelihood 8 0.01663361 0.2306770 0.94251611
## 2 MR Egger 8 1.39727512 0.9476036 0.19077965
## 3 Weighted mode 8 0.83257367 0.3035806 0.02881350
## 4 Weighted median 8 0.71348355 0.3001792 0.01746079
## 5 Inverse variance weighted 8 0.01386742 0.5555972 0.98008729
mr_heterogeneity(efficiency_scz_dat)
## id.exposure id.outcome outcome exposure
## 1 z8VC6t ieu-b-42 schizophrenia || id:ieu-b-42 Efficiency Factor
## 2 z8VC6t ieu-b-42 schizophrenia || id:ieu-b-42 Efficiency Factor
## method Q Q_df Q_pval
## 1 MR Egger 32.01295 6 1.622458e-05
## 2 Inverse variance weighted 47.58641 7 4.288828e-08
mr_pleiotropy_test(efficiency_scz_dat)
## id.exposure id.outcome outcome exposure
## 1 z8VC6t ieu-b-42 schizophrenia || id:ieu-b-42 Efficiency Factor
## egger_intercept se pval
## 1 -0.04010984 0.02347717 0.138413
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = efficiency_scz_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, efficiency_scz_dat)
p1
## $`z8VC6t.ieu-b-42`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 z8VC6t ieu-b-42
res_single <- mr_singlesnp(efficiency_scz_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome
## 1 Efficiency Factor schizophrenia || id:ieu-b-42 z8VC6t ieu-b-42
## 2 Efficiency Factor schizophrenia || id:ieu-b-42 z8VC6t ieu-b-42
## samplesize SNP b se p
## 1 77096 rs3755799 -3.182984 0.6795166 2.810719e-06
## 2 77096 rs441080 -2.567222 0.7439475 5.589052e-04
bip_out_dat <- read_outcome_data(
snps = effic_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/BiP_withNeff.txt.gz",
sep = "\t",
snp_col = "SNP",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
# eaf_col = "MAF",
pval_col = "PVAL"
)
## No phenotype name specified, defaulting to 'outcome'.
bip_out_dat$outcome<- rep('Bipolar Disorder', 1, nrow(bip_out_dat))
efficiency_bip_dat <- harmonise_data(effic_exp_dat, bip_out_dat)
## Harmonising Efficiency Factor (z8VC6t) and Bipolar Disorder (HCX4Wk)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10199876
res <- mr(efficiency_bip_dat, method_list = methods)
## Analysing 'z8VC6t' on 'HCX4Wk'
res
## id.exposure id.outcome outcome exposure
## 1 z8VC6t HCX4Wk Bipolar Disorder Efficiency Factor
## 2 z8VC6t HCX4Wk Bipolar Disorder Efficiency Factor
## 3 z8VC6t HCX4Wk Bipolar Disorder Efficiency Factor
## 4 z8VC6t HCX4Wk Bipolar Disorder Efficiency Factor
## 5 z8VC6t HCX4Wk Bipolar Disorder Efficiency Factor
## method nsnp b se pval
## 1 Maximum likelihood 7 -0.76577958 0.2475863 0.001981571
## 2 MR Egger 7 -0.01964769 1.0967887 0.986400447
## 3 Weighted mode 7 -0.27036668 0.3508613 0.470200624
## 4 Weighted median 7 -0.33039244 0.3126947 0.290695371
## 5 Inverse variance weighted 7 -0.69571497 0.4598512 0.130301711
mr_heterogeneity(efficiency_bip_dat)
## id.exposure id.outcome outcome exposure
## 1 z8VC6t HCX4Wk Bipolar Disorder Efficiency Factor
## 2 z8VC6t HCX4Wk Bipolar Disorder Efficiency Factor
## method Q Q_df Q_pval
## 1 MR Egger 21.35817 5 0.0006930602
## 2 Inverse variance weighted 23.36886 6 0.0006818975
mr_pleiotropy_test(efficiency_bip_dat)
## id.exposure id.outcome outcome exposure egger_intercept
## 1 z8VC6t HCX4Wk Bipolar Disorder Efficiency Factor -0.01676735
## se pval
## 1 0.02443932 0.5231746
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = efficiency_bip_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, efficiency_bip_dat)
p1
## $z8VC6t.HCX4Wk
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 z8VC6t HCX4Wk
res_single <- mr_singlesnp(efficiency_bip_dat,all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome samplesize
## 1 Efficiency Factor Bipolar Disorder z8VC6t HCX4Wk NA
## 2 Efficiency Factor Bipolar Disorder z8VC6t HCX4Wk NA
## SNP b se p
## 1 rs3755799 -3.3337321 0.6040148 3.403738e-08
## 2 All - Maximum likelihood -0.7657796 0.2475863 1.981571e-03
adhd_out_dat <- extract_outcome_data(snps = effic_exp_dat$SNP, outcomes = adhd)
## Extracting data for 8 SNP(s) from 1 GWAS(s)
## Finding proxies for 2 SNPs in outcome ieu-a-1183
## Extracting data for 2 SNP(s) from 1 GWAS(s)
efficiency_adhd_dat <- harmonise_data(effic_exp_dat, adhd_out_dat)
## Harmonising Efficiency Factor (z8VC6t) and ADHD || id:ieu-a-1183 (ieu-a-1183)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs10199876
res <- mr(efficiency_adhd_dat, method_list = methods)
## Analysing 'z8VC6t' on 'ieu-a-1183'
res
## id.exposure id.outcome outcome exposure
## 1 z8VC6t ieu-a-1183 ADHD || id:ieu-a-1183 Efficiency Factor
## 2 z8VC6t ieu-a-1183 ADHD || id:ieu-a-1183 Efficiency Factor
## 3 z8VC6t ieu-a-1183 ADHD || id:ieu-a-1183 Efficiency Factor
## 4 z8VC6t ieu-a-1183 ADHD || id:ieu-a-1183 Efficiency Factor
## 5 z8VC6t ieu-a-1183 ADHD || id:ieu-a-1183 Efficiency Factor
## method nsnp b se pval
## 1 Maximum likelihood 5 1.151044393 0.4388784 0.008723726
## 2 MR Egger 5 5.356360122 1.3964475 0.031239877
## 3 Weighted mode 5 -0.005430581 0.6373629 0.993609804
## 4 Weighted median 5 0.061082886 0.5585536 0.912917724
## 5 Inverse variance weighted 5 1.053595360 0.8088813 0.192733918
mr_heterogeneity(efficiency_adhd_dat)
## id.exposure id.outcome outcome exposure
## 1 z8VC6t ieu-a-1183 ADHD || id:ieu-a-1183 Efficiency Factor
## 2 z8VC6t ieu-a-1183 ADHD || id:ieu-a-1183 Efficiency Factor
## method Q Q_df Q_pval
## 1 MR Egger 3.562299 3 0.312771561
## 2 Inverse variance weighted 16.076211 4 0.002918587
mr_pleiotropy_test(efficiency_adhd_dat)
## id.exposure id.outcome outcome exposure
## 1 z8VC6t ieu-a-1183 ADHD || id:ieu-a-1183 Efficiency Factor
## egger_intercept se pval
## 1 -0.08659474 0.0266747 0.04762196
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = efficiency_adhd_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, efficiency_adhd_dat)
p1
## $`z8VC6t.ieu-a-1183`
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 z8VC6t ieu-a-1183
res_single <- mr_singlesnp(efficiency_adhd_dat,all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## exposure outcome id.exposure id.outcome samplesize
## 1 Efficiency Factor ADHD || id:ieu-a-1183 z8VC6t ieu-a-1183 55374
## SNP b se p
## 1 rs17400325 4.496021 1.028933 1.244772e-05
# dpw<- fread("/Users/claire/Desktop/Desktop/sleepMR/DrinksPerWeek.txt.gz", header=T, data.table=F)
drinkspw_out_dat <- read_outcome_data(
snps = effic_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/DrinksPerWeek.txt.gz",
sep = "\t",
snp_col = "RSID",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "REF",
other_allele_col = "ALT",
eaf_col = "AF",
pval_col = "PVALUE"
)
## No phenotype name specified, defaulting to 'outcome'.
drinkspw_out_dat$outcome<- rep('Drinks per Week', 1, nrow(drinkspw_out_dat))
efficiency_dpw_dat <- harmonise_data(effic_exp_dat, drinkspw_out_dat)
## Harmonising Efficiency Factor (z8VC6t) and Drinks per Week (bP66KT)
res <- mr(efficiency_dpw_dat, method_list = methods)
## Analysing 'z8VC6t' on 'bP66KT'
res
## id.exposure id.outcome outcome exposure
## 1 z8VC6t bP66KT Drinks per Week Efficiency Factor
## 2 z8VC6t bP66KT Drinks per Week Efficiency Factor
## 3 z8VC6t bP66KT Drinks per Week Efficiency Factor
## 4 z8VC6t bP66KT Drinks per Week Efficiency Factor
## 5 z8VC6t bP66KT Drinks per Week Efficiency Factor
## method nsnp b se pval
## 1 Maximum likelihood 8 0.01118971 0.04308320 0.7950772
## 2 MR Egger 8 0.09726732 0.15431006 0.5517098
## 3 Weighted mode 8 0.11636555 0.06681557 0.1251178
## 4 Weighted median 8 0.08302180 0.05999565 0.1664206
## 5 Inverse variance weighted 8 0.01046389 0.06645140 0.8748769
mr_heterogeneity(efficiency_dpw_dat)
## id.exposure id.outcome outcome exposure
## 1 z8VC6t bP66KT Drinks per Week Efficiency Factor
## 2 z8VC6t bP66KT Drinks per Week Efficiency Factor
## method Q Q_df Q_pval
## 1 MR Egger 16.53079 6 0.01117152
## 2 Inverse variance weighted 17.62457 7 0.01378372
mr_pleiotropy_test(efficiency_dpw_dat)
## id.exposure id.outcome outcome exposure egger_intercept
## 1 z8VC6t bP66KT Drinks per Week Efficiency Factor -0.002190526
## se pval
## 1 0.003476599 0.5518686
# MR PRESSO IF SIGNIFICANT HETEROGENEITY
# GET OUTLIER CORRECTED IVW ESTIMATE
pres<- mr_presso(BetaOutcome = "beta.outcome", BetaExposure = "beta.exposure", SdOutcome = "se.outcome", SdExposure = "se.exposure", OUTLIERtest = TRUE, DISTORTIONtest = TRUE, data = efficiency_dpw_dat, NbDistribution = 1000, SignifThreshold = 0.05)
pres<- pres$`Main MR results` %>% filter(`MR Analysis`=="Outlier-corrected") %>%
mutate(id.exposure=NA,
id.outcome=NA,
outcome=NA,
nsnp=NA) %>%
rename(exposure=Exposure,
method=`MR Analysis`,
b=`Causal Estimate`,
se= Sd,
pval=`P-value`) %>%
select(colnames(res))
res<- rbind(res, pres)
sleep_psych_MR<- rbind(sleep_psych_MR, res)
p1 <- mr_scatter_plot(res, efficiency_dpw_dat)
p1
## $z8VC6t.bP66KT
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 z8VC6t bP66KT
res_single <- mr_singlesnp(efficiency_dpw_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## [1] exposure outcome id.exposure id.outcome samplesize SNP
## [7] b se p
## <0 rows> (or 0-length row.names)
#cigs<- fread("/Users/claire/Desktop/Desktop/sleepMR/cigs_withNeff.txt.gz", header=T, data.table = F)
cigs_out_dat <- read_outcome_data(
snps = effic_exp_dat$SNP,
filename = "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sumstats/cigs_withNeff.txt.gz",
sep = "\t",
snp_col = "RSID",
beta_col = "BETA",
se_col = "SE",
effect_allele_col = "A1",
other_allele_col = "A2",
eaf_col = "MAF",
pval_col = "PVALUE"
)
## No phenotype name specified, defaulting to 'outcome'.
cigs_out_dat$outcome<- rep('Cigarettes per Day', 1, nrow(cigs_out_dat))
efficiency_cigs_dat <- harmonise_data(effic_exp_dat, cigs_out_dat)
## Harmonising Efficiency Factor (z8VC6t) and Cigarettes per Day (Ro1a6z)
res <- mr(efficiency_cigs_dat, method_list = methods)
## Analysing 'z8VC6t' on 'Ro1a6z'
res
## id.exposure id.outcome outcome exposure
## 1 z8VC6t Ro1a6z Cigarettes per Day Efficiency Factor
## 2 z8VC6t Ro1a6z Cigarettes per Day Efficiency Factor
## 3 z8VC6t Ro1a6z Cigarettes per Day Efficiency Factor
## 4 z8VC6t Ro1a6z Cigarettes per Day Efficiency Factor
## 5 z8VC6t Ro1a6z Cigarettes per Day Efficiency Factor
## method nsnp b se pval
## 1 Maximum likelihood 8 -0.1685866 0.1256768 0.17978099
## 2 MR Egger 8 -0.6649807 0.2751616 0.05209713
## 3 Weighted mode 8 -0.2983524 0.2506330 0.27269035
## 4 Weighted median 8 -0.2748788 0.1751134 0.11648060
## 5 Inverse variance weighted 8 -0.1655147 0.1423632 0.24498269
sleep_psych_MR<- rbind(sleep_psych_MR, res)
mr_heterogeneity(efficiency_cigs_dat)
## id.exposure id.outcome outcome exposure
## 1 z8VC6t Ro1a6z Cigarettes per Day Efficiency Factor
## 2 z8VC6t Ro1a6z Cigarettes per Day Efficiency Factor
## method Q Q_df Q_pval
## 1 MR Egger 5.230780 6 0.5145729
## 2 Inverse variance weighted 9.351288 7 0.2284091
mr_pleiotropy_test(efficiency_cigs_dat)
## id.exposure id.outcome outcome exposure egger_intercept
## 1 z8VC6t Ro1a6z Cigarettes per Day Efficiency Factor 0.01243988
## se pval
## 1 0.006128312 0.08867565
p1 <- mr_scatter_plot(res, efficiency_cigs_dat)
p1
## $z8VC6t.Ro1a6z
##
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
## id.exposure id.outcome
## 1 z8VC6t Ro1a6z
res_single <- mr_singlesnp(efficiency_cigs_dat, all_method = methods)
p2 <- mr_forest_plot(res_single)
p2[[1]]
res_single %>% filter(p<ivw_p)
## [1] exposure outcome id.exposure id.outcome samplesize SNP
## [7] b se p
## <0 rows> (or 0-length row.names)
save output of res
fwrite(sleep_psych_MR, "/Users/claire/Desktop/dissertation/cotwin_mendelian/sleepMR/sleep_exposure_MR.csv", sep='\t')