library(TwoSampleMR)
## TwoSampleMR version 0.5.6 
## [>] New: Option to use non-European LD reference panels for clumping etc
## [>] Some studies temporarily quarantined to verify effect allele
## [>] See news(package='TwoSampleMR') and https://gwas.mrcieu.ac.uk for further details

Number of children

Effect of intelligence on number of children

d <- make_dat("ebi-a-GCST006250", "ieu-b-4760")
## API: public: http://gwas-api.mrcieu.ac.uk/
## Extracting data for 165 SNP(s) from 1 GWAS(s)
## Finding proxies for 12 SNPs in outcome ieu-b-4760
## Extracting data for 12 SNP(s) from 1 GWAS(s)
## Harmonising Intelligence || id:ebi-a-GCST006250 (ebi-a-GCST006250) and Number of children || id:ieu-b-4760 (ieu-b-4760)
d_mr<-mr(d)
## Analysing 'ebi-a-GCST006250' on 'ieu-b-4760'
d_mr
##        id.exposure id.outcome                             outcome
## 1 ebi-a-GCST006250 ieu-b-4760 Number of children || id:ieu-b-4760
## 2 ebi-a-GCST006250 ieu-b-4760 Number of children || id:ieu-b-4760
## 3 ebi-a-GCST006250 ieu-b-4760 Number of children || id:ieu-b-4760
## 4 ebi-a-GCST006250 ieu-b-4760 Number of children || id:ieu-b-4760
## 5 ebi-a-GCST006250 ieu-b-4760 Number of children || id:ieu-b-4760
##                              exposure                    method nsnp
## 1 Intelligence || id:ebi-a-GCST006250                  MR Egger  162
## 2 Intelligence || id:ebi-a-GCST006250           Weighted median  162
## 3 Intelligence || id:ebi-a-GCST006250 Inverse variance weighted  162
## 4 Intelligence || id:ebi-a-GCST006250               Simple mode  162
## 5 Intelligence || id:ebi-a-GCST006250             Weighted mode  162
##             b         se         pval
## 1 -0.08987827 0.06503381 1.688908e-01
## 2 -0.05420943 0.01451578 1.880760e-04
## 3 -0.07365768 0.01362467 6.437617e-08
## 4 -0.01800980 0.05479361 7.428214e-01
## 5 -0.02026256 0.04824684 6.750622e-01
mr_scatter_plot(d_mr,d)
## $`ebi-a-GCST006250.ieu-b-4760`

## 
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
##        id.exposure id.outcome
## 1 ebi-a-GCST006250 ieu-b-4760

Effect of degree on number of children

d <- make_dat("ukb-b-16489", "ieu-b-4760")
## Extracting data for 261 SNP(s) from 1 GWAS(s)
## Finding proxies for 20 SNPs in outcome ieu-b-4760
## Extracting data for 20 SNP(s) from 1 GWAS(s)
## Harmonising Qualifications: College or University degree || id:ukb-b-16489 (ukb-b-16489) and Number of children || id:ieu-b-4760 (ieu-b-4760)
d_mr<-mr(d)
## Analysing 'ukb-b-16489' on 'ieu-b-4760'
d_mr
##   id.exposure id.outcome                             outcome
## 1 ukb-b-16489 ieu-b-4760 Number of children || id:ieu-b-4760
## 2 ukb-b-16489 ieu-b-4760 Number of children || id:ieu-b-4760
## 3 ukb-b-16489 ieu-b-4760 Number of children || id:ieu-b-4760
## 4 ukb-b-16489 ieu-b-4760 Number of children || id:ieu-b-4760
## 5 ukb-b-16489 ieu-b-4760 Number of children || id:ieu-b-4760
##                                                         exposure
## 1 Qualifications: College or University degree || id:ukb-b-16489
## 2 Qualifications: College or University degree || id:ukb-b-16489
## 3 Qualifications: College or University degree || id:ukb-b-16489
## 4 Qualifications: College or University degree || id:ukb-b-16489
## 5 Qualifications: College or University degree || id:ukb-b-16489
##                      method nsnp          b         se         pval
## 1                  MR Egger  253 -0.5308634 0.11535070 6.642763e-06
## 2           Weighted median  253 -0.3241435 0.03317921 1.522397e-22
## 3 Inverse variance weighted  253 -0.3153327 0.02862108 3.146772e-28
## 4               Simple mode  253 -0.4192495 0.11473844 3.141532e-04
## 5             Weighted mode  253 -0.4192495 0.09473836 1.434420e-05
mr_scatter_plot(d_mr,d)
## $`ukb-b-16489.ieu-b-4760`

## 
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
##   id.exposure id.outcome
## 1 ukb-b-16489 ieu-b-4760

MVMR for both intelligence and degree on number of children

d <- mv_extract_exposures(c("ebi-a-GCST006250", "ukb-b-16489"))
## Please look at vignettes for options on running this locally if you need to run many instances of this command.
## Clumping 1, 421 variants, using EUR population reference
## Removing 129 of 421 variants due to LD with other variants or absence from LD reference panel
## Extracting data for 292 SNP(s) from 2 GWAS(s)
## Finding proxies for 16 SNPs in outcome ebi-a-GCST006250
## Extracting data for 16 SNP(s) from 1 GWAS(s)
## Harmonising Intelligence || id:ebi-a-GCST006250 (ebi-a-GCST006250) and Qualifications: College or University degree || id:ukb-b-16489 (ukb-b-16489)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs1020875, rs10931821, rs12421006, rs12534506, rs13018621, rs1340799, rs13425585, rs17128425, rs175325, rs1913145, rs1968526, rs2299098, rs2420551, rs2478286, rs2923431, rs2987390, rs31768, rs34320898, rs35623690, rs3747631, rs3751661, rs38853, rs422115, rs4457062, rs4484297, rs4887925, rs57985238, rs62477728, rs6440053, rs67482514, rs6867851, rs7047015, rs72748120, rs73068339, rs7573001, rs7624274, rs76577427, rs8054299, rs9363731, rs938964, rs9517313
o <- extract_outcome_data(d$SNP, "ieu-b-4760")
## Extracting data for 286 SNP(s) from 1 GWAS(s)
## Finding proxies for 21 SNPs in outcome ieu-b-4760
## Extracting data for 21 SNP(s) from 1 GWAS(s)
d <- mv_harmonise_data(d, o)
## Harmonising Intelligence || id:ebi-a-GCST006250 (ebi-a-GCST006250) and Number of children || id:ieu-b-4760 (ieu-b-4760)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs1020875, rs10931821, rs12421006, rs12534506, rs13018621, rs1340799, rs13425585, rs17128425, rs175325, rs1913145, rs1968526, rs2299098, rs2478286, rs2923431, rs2987390, rs31768, rs34320898, rs35623690, rs3747631, rs3751661, rs38853, rs422115, rs4457062, rs4484297, rs4887925, rs57985238, rs62477728, rs6440053, rs67482514, rs6867851, rs7047015, rs72748120, rs73068339, rs7573001, rs7624274, rs76577427, rs8054299, rs938964, rs9517313
mv_multiple(d)
## $result
##        id.exposure
## 1 ebi-a-GCST006250
## 2      ukb-b-16489
##                                                         exposure id.outcome
## 1                            Intelligence || id:ebi-a-GCST006250 ieu-b-4760
## 2 Qualifications: College or University degree || id:ukb-b-16489 ieu-b-4760
##                               outcome nsnp           b         se         pval
## 1 Number of children || id:ieu-b-4760   87  0.02293796 0.02411701 3.415479e-01
## 2 Number of children || id:ieu-b-4760  181 -0.35024377 0.05345289 5.662635e-11

Having a degree removes the effect of intelligence.

But does intelligence cause degree? or vice versa?

Effect of intelligence on degree

d <- make_dat("ebi-a-GCST006250", "ukb-b-16489")
## Extracting data for 165 SNP(s) from 1 GWAS(s)
## Harmonising Intelligence || id:ebi-a-GCST006250 (ebi-a-GCST006250) and Qualifications: College or University degree || id:ukb-b-16489 (ukb-b-16489)
d_mr<-mr(d)
## Analysing 'ebi-a-GCST006250' on 'ukb-b-16489'
d_mr
##        id.exposure  id.outcome
## 1 ebi-a-GCST006250 ukb-b-16489
## 2 ebi-a-GCST006250 ukb-b-16489
## 3 ebi-a-GCST006250 ukb-b-16489
## 4 ebi-a-GCST006250 ukb-b-16489
## 5 ebi-a-GCST006250 ukb-b-16489
##                                                          outcome
## 1 Qualifications: College or University degree || id:ukb-b-16489
## 2 Qualifications: College or University degree || id:ukb-b-16489
## 3 Qualifications: College or University degree || id:ukb-b-16489
## 4 Qualifications: College or University degree || id:ukb-b-16489
## 5 Qualifications: College or University degree || id:ukb-b-16489
##                              exposure                    method nsnp         b
## 1 Intelligence || id:ebi-a-GCST006250                  MR Egger  165 0.3068208
## 2 Intelligence || id:ebi-a-GCST006250           Weighted median  165 0.2044947
## 3 Intelligence || id:ebi-a-GCST006250 Inverse variance weighted  165 0.2375428
## 4 Intelligence || id:ebi-a-GCST006250               Simple mode  165 0.2154431
## 5 Intelligence || id:ebi-a-GCST006250             Weighted mode  165 0.2041173
##            se          pval
## 1 0.042304079  1.563959e-11
## 2 0.008439729 1.074511e-129
## 3 0.009128148 2.712061e-149
## 4 0.025957628  3.661673e-14
## 5 0.025010516  8.300426e-14
mr_scatter_plot(d_mr,d)
## $`ebi-a-GCST006250.ukb-b-16489`

## 
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
##        id.exposure  id.outcome
## 1 ebi-a-GCST006250 ukb-b-16489

Very strong relationship

Now apply Steiger filtering

d <- make_dat("ebi-a-GCST006250", "ukb-b-16489")
## Extracting data for 165 SNP(s) from 1 GWAS(s)
## Harmonising Intelligence || id:ebi-a-GCST006250 (ebi-a-GCST006250) and Qualifications: College or University degree || id:ukb-b-16489 (ukb-b-16489)
d <- steiger_filtering(d)
d<-d[d$steiger_dir==TRUE & d$steiger_pval<0.05,]
d_mr<-mr(d)
## Analysing 'ebi-a-GCST006250' on 'ukb-b-16489'
d_mr
##        id.exposure  id.outcome
## 1 ebi-a-GCST006250 ukb-b-16489
## 2 ebi-a-GCST006250 ukb-b-16489
## 3 ebi-a-GCST006250 ukb-b-16489
## 4 ebi-a-GCST006250 ukb-b-16489
## 5 ebi-a-GCST006250 ukb-b-16489
##                                                          outcome
## 1 Qualifications: College or University degree || id:ukb-b-16489
## 2 Qualifications: College or University degree || id:ukb-b-16489
## 3 Qualifications: College or University degree || id:ukb-b-16489
## 4 Qualifications: College or University degree || id:ukb-b-16489
## 5 Qualifications: College or University degree || id:ukb-b-16489
##                              exposure                    method nsnp         b
## 1 Intelligence || id:ebi-a-GCST006250                  MR Egger  114 0.2559459
## 2 Intelligence || id:ebi-a-GCST006250           Weighted median  114 0.1808695
## 3 Intelligence || id:ebi-a-GCST006250 Inverse variance weighted  114 0.1781030
## 4 Intelligence || id:ebi-a-GCST006250               Simple mode  114 0.1974392
## 5 Intelligence || id:ebi-a-GCST006250             Weighted mode  114 0.1974392
##            se          pval
## 1 0.033578255  8.694739e-12
## 2 0.008615529  7.530936e-98
## 3 0.007547373 4.039398e-123
## 4 0.028293244  2.157543e-10
## 5 0.029703461  1.103803e-09
mr_scatter_plot(d_mr,d)
## $`ebi-a-GCST006250.ukb-b-16489`

## 
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
##        id.exposure  id.outcome
## 1 ebi-a-GCST006250 ukb-b-16489

Still a strong relationship. Number of SNPs dropped from 165 to 114.

Effect of degree on intelligence

d <- make_dat("ukb-b-16489", "ebi-a-GCST006250")
## Extracting data for 261 SNP(s) from 1 GWAS(s)
## Finding proxies for 20 SNPs in outcome ebi-a-GCST006250
## Extracting data for 20 SNP(s) from 1 GWAS(s)
## Harmonising Qualifications: College or University degree || id:ukb-b-16489 (ukb-b-16489) and Intelligence || id:ebi-a-GCST006250 (ebi-a-GCST006250)
d_mr<-mr(d)
## Analysing 'ukb-b-16489' on 'ebi-a-GCST006250'
d_mr
##   id.exposure       id.outcome                             outcome
## 1 ukb-b-16489 ebi-a-GCST006250 Intelligence || id:ebi-a-GCST006250
## 2 ukb-b-16489 ebi-a-GCST006250 Intelligence || id:ebi-a-GCST006250
## 3 ukb-b-16489 ebi-a-GCST006250 Intelligence || id:ebi-a-GCST006250
## 4 ukb-b-16489 ebi-a-GCST006250 Intelligence || id:ebi-a-GCST006250
## 5 ukb-b-16489 ebi-a-GCST006250 Intelligence || id:ebi-a-GCST006250
##                                                         exposure
## 1 Qualifications: College or University degree || id:ukb-b-16489
## 2 Qualifications: College or University degree || id:ukb-b-16489
## 3 Qualifications: College or University degree || id:ukb-b-16489
## 4 Qualifications: College or University degree || id:ukb-b-16489
## 5 Qualifications: College or University degree || id:ukb-b-16489
##                      method nsnp        b         se          pval
## 1                  MR Egger  253 1.612662 0.20310186  6.762525e-14
## 2           Weighted median  253 1.363705 0.05468670 2.977984e-137
## 3 Inverse variance weighted  253 1.546310 0.04884885 6.473398e-220
## 4               Simple mode  253 1.349781 0.19911716  8.545724e-11
## 5             Weighted mode  253 1.292415 0.23967515  1.599829e-07
mr_scatter_plot(d_mr,d)
## $`ukb-b-16489.ebi-a-GCST006250`

## 
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
##   id.exposure       id.outcome
## 1 ukb-b-16489 ebi-a-GCST006250

Also a very strong relationship.

Now apply Steiger filtering

d <- make_dat("ukb-b-16489","ebi-a-GCST006250")
## Extracting data for 261 SNP(s) from 1 GWAS(s)
## Finding proxies for 20 SNPs in outcome ebi-a-GCST006250
## Extracting data for 20 SNP(s) from 1 GWAS(s)
## Harmonising Qualifications: College or University degree || id:ukb-b-16489 (ukb-b-16489) and Intelligence || id:ebi-a-GCST006250 (ebi-a-GCST006250)
d <- steiger_filtering(d)
d<-d[d$steiger_dir==TRUE & d$steiger_pval<0.05,]
d_mr<-mr(d)
## Analysing 'ukb-b-16489' on 'ebi-a-GCST006250'
d_mr
##   id.exposure       id.outcome                             outcome
## 1 ukb-b-16489 ebi-a-GCST006250 Intelligence || id:ebi-a-GCST006250
## 2 ukb-b-16489 ebi-a-GCST006250 Intelligence || id:ebi-a-GCST006250
## 3 ukb-b-16489 ebi-a-GCST006250 Intelligence || id:ebi-a-GCST006250
## 4 ukb-b-16489 ebi-a-GCST006250 Intelligence || id:ebi-a-GCST006250
## 5 ukb-b-16489 ebi-a-GCST006250 Intelligence || id:ebi-a-GCST006250
##                                                         exposure
## 1 Qualifications: College or University degree || id:ukb-b-16489
## 2 Qualifications: College or University degree || id:ukb-b-16489
## 3 Qualifications: College or University degree || id:ukb-b-16489
## 4 Qualifications: College or University degree || id:ukb-b-16489
## 5 Qualifications: College or University degree || id:ukb-b-16489
##                      method nsnp         b         se         pval
## 1                  MR Egger   85 1.2664407 0.22432436 2.237819e-07
## 2           Weighted median   85 0.7828054 0.07393214 3.381707e-26
## 3 Inverse variance weighted   85 0.7457074 0.05234029 4.659929e-46
## 4               Simple mode   85 0.8844563 0.20988331 6.282273e-05
## 5             Weighted mode   85 0.9459520 0.20298893 1.175266e-05
mr_scatter_plot(d_mr,d)
## $`ukb-b-16489.ebi-a-GCST006250`

## 
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
##   id.exposure       id.outcome
## 1 ukb-b-16489 ebi-a-GCST006250

Still a strong relationship. Number of SNPs dropped from 253 to 85, meaning 2/3 of the degree SNPs explained more variance in intelligence.

Therefore, having a degree and intelligence cause each other, but having a degree is more important in terms of number of children.

Does this still hold when split by sex?

Number of children fathered

Effect of intelligence on number of children fathered

d <- make_dat("ebi-a-GCST006250", "ukb-b-2227")
## Extracting data for 165 SNP(s) from 1 GWAS(s)
## Harmonising Intelligence || id:ebi-a-GCST006250 (ebi-a-GCST006250) and Number of children fathered || id:ukb-b-2227 (ukb-b-2227)
d_mr<-mr(d)
## Analysing 'ebi-a-GCST006250' on 'ukb-b-2227'
d_mr
##        id.exposure id.outcome                                      outcome
## 1 ebi-a-GCST006250 ukb-b-2227 Number of children fathered || id:ukb-b-2227
## 2 ebi-a-GCST006250 ukb-b-2227 Number of children fathered || id:ukb-b-2227
## 3 ebi-a-GCST006250 ukb-b-2227 Number of children fathered || id:ukb-b-2227
## 4 ebi-a-GCST006250 ukb-b-2227 Number of children fathered || id:ukb-b-2227
## 5 ebi-a-GCST006250 ukb-b-2227 Number of children fathered || id:ukb-b-2227
##                              exposure                    method nsnp
## 1 Intelligence || id:ebi-a-GCST006250                  MR Egger  165
## 2 Intelligence || id:ebi-a-GCST006250           Weighted median  165
## 3 Intelligence || id:ebi-a-GCST006250 Inverse variance weighted  165
## 4 Intelligence || id:ebi-a-GCST006250               Simple mode  165
## 5 Intelligence || id:ebi-a-GCST006250             Weighted mode  165
##              b         se        pval
## 1 -0.054464526 0.06628456 0.412460722
## 2 -0.040168432 0.01756664 0.022217340
## 3 -0.052126199 0.01419349 0.000240149
## 4 -0.006745877 0.06720954 0.920172532
## 5  0.003077109 0.06502027 0.962311484
mr_scatter_plot(d_mr,d)
## $`ebi-a-GCST006250.ukb-b-2227`

## 
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
##        id.exposure id.outcome
## 1 ebi-a-GCST006250 ukb-b-2227

Effect of degree on number of children fathered

d <- make_dat("ukb-b-16489", "ukb-b-2227")
## Extracting data for 261 SNP(s) from 1 GWAS(s)
## Harmonising Qualifications: College or University degree || id:ukb-b-16489 (ukb-b-16489) and Number of children fathered || id:ukb-b-2227 (ukb-b-2227)
## Removing the following SNPs for incompatible alleles:
## rs2606913
d_mr<-mr(d)
## Analysing 'ukb-b-16489' on 'ukb-b-2227'
d_mr
##   id.exposure id.outcome                                      outcome
## 1 ukb-b-16489 ukb-b-2227 Number of children fathered || id:ukb-b-2227
## 2 ukb-b-16489 ukb-b-2227 Number of children fathered || id:ukb-b-2227
## 3 ukb-b-16489 ukb-b-2227 Number of children fathered || id:ukb-b-2227
## 4 ukb-b-16489 ukb-b-2227 Number of children fathered || id:ukb-b-2227
## 5 ukb-b-16489 ukb-b-2227 Number of children fathered || id:ukb-b-2227
##                                                         exposure
## 1 Qualifications: College or University degree || id:ukb-b-16489
## 2 Qualifications: College or University degree || id:ukb-b-16489
## 3 Qualifications: College or University degree || id:ukb-b-16489
## 4 Qualifications: College or University degree || id:ukb-b-16489
## 5 Qualifications: College or University degree || id:ukb-b-16489
##                      method nsnp          b         se         pval
## 1                  MR Egger  261 -0.4399526 0.12120401 3.416623e-04
## 2           Weighted median  261 -0.2604059 0.03888631 2.133321e-11
## 3 Inverse variance weighted  261 -0.2227341 0.02989581 9.309633e-14
## 4               Simple mode  261 -0.2652487 0.13109482 4.406173e-02
## 5             Weighted mode  261 -0.2913719 0.10307360 5.066458e-03
mr_scatter_plot(d_mr,d)
## $`ukb-b-16489.ukb-b-2227`

## 
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
##   id.exposure id.outcome
## 1 ukb-b-16489 ukb-b-2227

MVMR for both intelligence and degree on number of children fathered

d <- mv_extract_exposures(c("ebi-a-GCST006250", "ukb-b-16489"))
## Please look at vignettes for options on running this locally if you need to run many instances of this command.
## Clumping 1, 421 variants, using EUR population reference
## Removing 129 of 421 variants due to LD with other variants or absence from LD reference panel
## Extracting data for 292 SNP(s) from 2 GWAS(s)
## Finding proxies for 16 SNPs in outcome ebi-a-GCST006250
## Extracting data for 16 SNP(s) from 1 GWAS(s)
## Harmonising Intelligence || id:ebi-a-GCST006250 (ebi-a-GCST006250) and Qualifications: College or University degree || id:ukb-b-16489 (ukb-b-16489)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs1020875, rs10931821, rs12421006, rs12534506, rs13018621, rs1340799, rs13425585, rs17128425, rs175325, rs1913145, rs1968526, rs2299098, rs2420551, rs2478286, rs2923431, rs2987390, rs31768, rs34320898, rs35623690, rs3747631, rs3751661, rs38853, rs422115, rs4457062, rs4484297, rs4887925, rs57985238, rs62477728, rs6440053, rs67482514, rs6867851, rs7047015, rs72748120, rs73068339, rs7573001, rs7624274, rs76577427, rs8054299, rs9363731, rs938964, rs9517313
o <- extract_outcome_data(d$SNP, "ukb-b-2227")
## Extracting data for 286 SNP(s) from 1 GWAS(s)
d <- mv_harmonise_data(d, o)
## Harmonising Intelligence || id:ebi-a-GCST006250 (ebi-a-GCST006250) and Number of children fathered || id:ukb-b-2227 (ukb-b-2227)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs1020875, rs10931821, rs12421006, rs12534506, rs13018621, rs1340799, rs13425585, rs17128425, rs175325, rs1913145, rs1968526, rs2299098, rs2420551, rs2478286, rs2923431, rs2987390, rs31768, rs34320898, rs35623690, rs3747631, rs3751661, rs38853, rs422115, rs4457062, rs4484297, rs4887925, rs57985238, rs62477728, rs6440053, rs67482514, rs6867851, rs7047015, rs72748120, rs73068339, rs7573001, rs7624274, rs76577427, rs8054299, rs9363731, rs938964, rs9517313
mv_multiple(d)
## $result
##        id.exposure
## 1 ebi-a-GCST006250
## 2      ukb-b-16489
##                                                         exposure id.outcome
## 1                            Intelligence || id:ebi-a-GCST006250 ukb-b-2227
## 2 Qualifications: College or University degree || id:ukb-b-16489 ukb-b-2227
##                                        outcome nsnp          b         se
## 1 Number of children fathered || id:ukb-b-2227   88  0.0266600 0.02533934
## 2 Number of children fathered || id:ukb-b-2227  185 -0.2667345 0.05615489
##           pval
## 1 2.927449e-01
## 2 2.034385e-06

Having a degree removes the effect of intelligence.

Number of live births

Effect of intelligence on number of live births

d <- make_dat("ebi-a-GCST006250", "ukb-b-1209")
## Extracting data for 165 SNP(s) from 1 GWAS(s)
## Harmonising Intelligence || id:ebi-a-GCST006250 (ebi-a-GCST006250) and Number of live births || id:ukb-b-1209 (ukb-b-1209)
d_mr<-mr(d)
## Analysing 'ebi-a-GCST006250' on 'ukb-b-1209'
d_mr
##        id.exposure id.outcome                                outcome
## 1 ebi-a-GCST006250 ukb-b-1209 Number of live births || id:ukb-b-1209
## 2 ebi-a-GCST006250 ukb-b-1209 Number of live births || id:ukb-b-1209
## 3 ebi-a-GCST006250 ukb-b-1209 Number of live births || id:ukb-b-1209
## 4 ebi-a-GCST006250 ukb-b-1209 Number of live births || id:ukb-b-1209
## 5 ebi-a-GCST006250 ukb-b-1209 Number of live births || id:ukb-b-1209
##                              exposure                    method nsnp          b
## 1 Intelligence || id:ebi-a-GCST006250                  MR Egger  165 -0.1461753
## 2 Intelligence || id:ebi-a-GCST006250           Weighted median  165 -0.1188004
## 3 Intelligence || id:ebi-a-GCST006250 Inverse variance weighted  165 -0.1091967
## 4 Intelligence || id:ebi-a-GCST006250               Simple mode  165 -0.2032403
## 5 Intelligence || id:ebi-a-GCST006250             Weighted mode  165 -0.1994294
##           se         pval
## 1 0.09751364 1.358017e-01
## 2 0.02417013 8.870295e-07
## 3 0.02085754 1.646633e-07
## 4 0.08727096 2.108736e-02
## 5 0.09908981 4.579169e-02
mr_scatter_plot(d_mr,d)
## $`ebi-a-GCST006250.ukb-b-1209`

## 
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
##        id.exposure id.outcome
## 1 ebi-a-GCST006250 ukb-b-1209

Effect of degree on number of live births

d <- make_dat("ukb-b-16489", "ukb-b-1209")
## Extracting data for 261 SNP(s) from 1 GWAS(s)
## Harmonising Qualifications: College or University degree || id:ukb-b-16489 (ukb-b-16489) and Number of live births || id:ukb-b-1209 (ukb-b-1209)
## Removing the following SNPs for incompatible alleles:
## rs2606913
d_mr<-mr(d)
## Analysing 'ukb-b-16489' on 'ukb-b-1209'
d_mr
##   id.exposure id.outcome                                outcome
## 1 ukb-b-16489 ukb-b-1209 Number of live births || id:ukb-b-1209
## 2 ukb-b-16489 ukb-b-1209 Number of live births || id:ukb-b-1209
## 3 ukb-b-16489 ukb-b-1209 Number of live births || id:ukb-b-1209
## 4 ukb-b-16489 ukb-b-1209 Number of live births || id:ukb-b-1209
## 5 ukb-b-16489 ukb-b-1209 Number of live births || id:ukb-b-1209
##                                                         exposure
## 1 Qualifications: College or University degree || id:ukb-b-16489
## 2 Qualifications: College or University degree || id:ukb-b-16489
## 3 Qualifications: College or University degree || id:ukb-b-16489
## 4 Qualifications: College or University degree || id:ukb-b-16489
## 5 Qualifications: College or University degree || id:ukb-b-16489
##                      method nsnp          b         se         pval
## 1                  MR Egger  261 -0.7659734 0.18580223 5.050002e-05
## 2           Weighted median  261 -0.4994530 0.05089399 9.839880e-23
## 3 Inverse variance weighted  261 -0.4621858 0.04578305 5.805403e-24
## 4               Simple mode  261 -0.5777969 0.18803392 2.345810e-03
## 5             Weighted mode  261 -0.6060249 0.15667922 1.387907e-04
mr_scatter_plot(d_mr,d)
## $`ukb-b-16489.ukb-b-1209`

## 
## attr(,"split_type")
## [1] "data.frame"
## attr(,"split_labels")
##   id.exposure id.outcome
## 1 ukb-b-16489 ukb-b-1209

MVMR for both intelligence and degree on number of live births

d <- mv_extract_exposures(c("ebi-a-GCST006250", "ukb-b-16489"))
## Please look at vignettes for options on running this locally if you need to run many instances of this command.
## Clumping 1, 421 variants, using EUR population reference
## Removing 129 of 421 variants due to LD with other variants or absence from LD reference panel
## Extracting data for 292 SNP(s) from 2 GWAS(s)
## Finding proxies for 16 SNPs in outcome ebi-a-GCST006250
## Extracting data for 16 SNP(s) from 1 GWAS(s)
## Harmonising Intelligence || id:ebi-a-GCST006250 (ebi-a-GCST006250) and Qualifications: College or University degree || id:ukb-b-16489 (ukb-b-16489)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs1020875, rs10931821, rs12421006, rs12534506, rs13018621, rs1340799, rs13425585, rs17128425, rs175325, rs1913145, rs1968526, rs2299098, rs2420551, rs2478286, rs2923431, rs2987390, rs31768, rs34320898, rs35623690, rs3747631, rs3751661, rs38853, rs422115, rs4457062, rs4484297, rs4887925, rs57985238, rs62477728, rs6440053, rs67482514, rs6867851, rs7047015, rs72748120, rs73068339, rs7573001, rs7624274, rs76577427, rs8054299, rs9363731, rs938964, rs9517313
o <- extract_outcome_data(d$SNP, "ukb-b-1209")
## Extracting data for 286 SNP(s) from 1 GWAS(s)
d <- mv_harmonise_data(d, o)
## Harmonising Intelligence || id:ebi-a-GCST006250 (ebi-a-GCST006250) and Number of live births || id:ukb-b-1209 (ukb-b-1209)
## Removing the following SNPs for being palindromic with intermediate allele frequencies:
## rs1020875, rs10931821, rs12421006, rs12534506, rs13018621, rs1340799, rs13425585, rs17128425, rs175325, rs1913145, rs1968526, rs2299098, rs2420551, rs2478286, rs2923431, rs2987390, rs31768, rs34320898, rs35623690, rs3747631, rs3751661, rs38853, rs422115, rs4457062, rs4484297, rs4887925, rs57985238, rs62477728, rs6440053, rs67482514, rs6867851, rs7047015, rs72748120, rs73068339, rs7573001, rs7624274, rs76577427, rs8054299, rs9363731, rs938964, rs9517313
mv_multiple(d)
## $result
##        id.exposure
## 1 ebi-a-GCST006250
## 2      ukb-b-16489
##                                                         exposure id.outcome
## 1                            Intelligence || id:ebi-a-GCST006250 ukb-b-1209
## 2 Qualifications: College or University degree || id:ukb-b-16489 ukb-b-1209
##                                  outcome nsnp           b         se
## 1 Number of live births || id:ukb-b-1209   88  0.01677664 0.03858006
## 2 Number of live births || id:ukb-b-1209  185 -0.49538037 0.08549629
##           pval
## 1 6.636695e-01
## 2 6.865843e-09

Having a degree removes the effect of intelligence.