# require package
require(TwoSampleMR)
## Loading required package: TwoSampleMR
## TwoSampleMR version 0.5.5 
## [>] 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
# set seed
set.seed(743187210)

# one million individuals
n<-1000000

# six snps
g1<-sample(c(0:2),n,TRUE)
g2<-sample(c(0:2),n,TRUE)
g3<-sample(c(0:2),n,TRUE)
g4<-sample(c(0:2),n,TRUE)
g5<-sample(c(0:2),n,TRUE)
g6<-sample(c(0:2),n,TRUE)

# phenotype increases by one unit for each mutation
p1<-g1+g2+g3+g4+g5+g6#+rnorm(n,0,1)

# fitness increases by 0.1 for each phenotypic unit
b<-0.1
fit<-1+b*p1#+rnorm(n,0,0.01)

# MR on fitness
mod1<-summary(lm(p1~g1+g2+g3+g4+g5+g6))
bgx<-mod1$coefficients[2,1]
segx<-mod1$coefficients[2,2]
mod2<-summary(lm(fit~g1+g2+g3+g4+g5+g6))
bgy<-mod2$coefficients[2,1]
segy<-mod2$coefficients[2,2]
mr_wald_ratio(bgx,bgy,segx,segy)
## $b
## [1] 0.1
## 
## $se
## [1] 2.535981e-14
## 
## $pval
## [1] 0
## 
## $nsnp
## [1] 1

I interpret this as fitness increases by 0.1 for every phenotypic unit.

# get number of children
child_parent_1 <- sample(1:n, n, replace=TRUE, prob=fit)
child_parent_2 <- sample(1:n, n, replace=TRUE, prob=fit)
parents_no_children<-rep(0,n)
tabParents<-table(c(child_parent_1,child_parent_2))
parents_no_children[as.numeric(unlist(dimnames(tabParents)))]<-tabParents

# MR on number of children
mod1<-summary(lm(p1~g1+g2+g3+g4+g5+g6))
bgx<-mod1$coefficients[2,1]
segx<-mod1$coefficients[2,2]
mod2<-summary(glm(parents_no_children~g1+g2+g3+g4+g5+g6,family=poisson("log")))
bgy<-mod2$coefficients[2,1]
segy<-mod2$coefficients[2,2]

cov<-vcov(mod2)[2,1]
biv<-exp(bgy/bgx)
se<-sqrt((segy^2/bgx^2) + (bgy^2/bgx^4)*segx^2 - 2*(bgy/bgx^3)*cov)
paste("b:",biv)
## [1] "b: 1.06337595355151"
paste("se:",se)
## [1] "se: 0.000920801307302518"

I interpret this as: for every phenotypic unit increase, number of children increases 1.06 fold.