Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@ Package: simulateGP
Title: Functions for Simulating Genotype-Phenotype Relationships
Version: 0.1.3
Authors@R: c(
person("Gibran", "Hemani", , "explodecomputer@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-0920-1055")),
person("Gibran", "Hemani", , "explodecomputer@gmail.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-0920-1055")),
person("John", "Ferguson", , "john.ferguson@nuigalway.ie", role = "aut"),
person("Rita", "Rasteiro", , "rita.rasteiro@bristol.ac.uk", role = c("aut"), comment = c(ORCID = "0000-0002-4217-3060"))
person("Rita", "Rasteiro", , "rita.rasteiro@bristol.ac.uk", role = "aut",
comment = c(ORCID = "0000-0002-4217-3060"))
)
Description: Functions for simulating SNP effects on phenotypes. Functions
for simulating disease risk on probability and liability scales.
Simulations to quickly obtain estimates of effect sizes for simulated
genotype-phenotypes.
License: MIT + file LICENSE
URL: https://explodecomputer.github.io/simulateGP/
URL: https://explodecomputer.github.io/simulateGP/,
https://github.com/explodecomputer/simulateGP,
https://mrcieu.r-universe.dev/simulateGP
BugReports: https://github.com/explodecomputer/simulateGP/issues
Depends:
R (>= 4.0.0)
Expand Down Expand Up @@ -48,7 +52,7 @@ Remotes:
mrcieu/gwasglue2,
mrcieu/ieugwasr,
mrcieu/TwoSampleMR
Config/roxygen2/markdown: TRUE
Config/roxygen2/version: 8.1.0
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
38 changes: 20 additions & 18 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,24 @@ export(y_to_binary)
importFrom(graphics,hist)
importFrom(magrittr,"%>%")
importFrom(rlang,.data)
importFrom(stats,anova)
importFrom(stats,cor)
importFrom(stats,cov)
importFrom(stats,glm)
importFrom(stats,lm)
importFrom(stats,na.exclude)
importFrom(stats,pf)
importFrom(stats,plogis)
importFrom(stats,pnorm)
importFrom(stats,pt)
importFrom(stats,qnorm)
importFrom(stats,quantile)
importFrom(stats,rbinom)
importFrom(stats,rnorm)
importFrom(stats,runif)
importFrom(stats,start)
importFrom(stats,uniroot)
importFrom(stats,var)
importFrom(stats,
anova,
cor,
cov,
glm,
lm,
na.exclude,
pf,
plogis,
pnorm,
pt,
qnorm,
quantile,
rbinom,
rnorm,
runif,
start,
uniroot,
var
)
importFrom(utils,write.table)
4 changes: 1 addition & 3 deletions R/simulateGP-package.r
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@
#'
#' **Full documentation available here:** [https://explodecomputer.github.io/simulateGP](https://explodecomputer.github.io/simulateGP)
#'
#' @name simulateGP-package
#' @aliases simulateGP simulategp
#' @docType package
NULL
"_PACKAGE"
1 change: 1 addition & 0 deletions man/simulateGP-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions vignettes/mr_dgp.rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ vignette: >
%\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
eval = FALSE
)
```

Background: [Deep IV](http://proceedings.mlr.press/v70/hartford17a.html) can infer causal effects in which the sample is stratified by one or many covariates, and there is a different causal effect within each stratum.

The covariates don't necessarily need to be directly measured, could have a large number of proxy variables for example.
Expand All @@ -26,14 +34,14 @@ bmi_hits <- ieugwasr::tophits("ukb-b-19953")
str(bmi_hits)
```

There are `r nrow(bmi_hits)` independent instruments for BMI. All the instruments have small effects:
This gives the independent instruments for BMI. All the instruments have small effects:

```{r}
bmi_hits$rsq <- 2 * bmi_hits$beta^2 * bmi_hits$eaf * (1 - bmi_hits$eaf)
hist(bmi_hits$rsq, breaks=100)
```

In total the `r nrow(bmi_hits)` BMI hits explain `r sum(bmi_hits$rsq) * 100`% of the variance in BMI.
In total the BMI hits explain `sum(bmi_hits$rsq) * 100`% of the variance in BMI.

What is the effect on coronary heart disease?

Expand Down Expand Up @@ -78,7 +86,7 @@ Problem with this model is that if we assume that all the instruments explain th
1. Choose a number of causal variants for the trait (large, e.g. >10000)
2. Sample the allele frequency distribution of all causal variants
3. Sample the effects for all causal variants
4. Retain only those that cumulatively explain some amount of variance. e.g. For BMI, the variance exlained is `r round(sum(bmi_hits$rsq, 2))`, so we just want the set of variants that are required to explain that much variance.
4. Retain only those that cumulatively explain some amount of variance. e.g. For BMI, the variance explained is `sum(bmi_hits$rsq)`, so we just want the set of variants that are required to explain that much variance.

Ultimately, we can draw allele frequencies from some distribution e.g.

Expand Down