From ce5a37db09ad8b5db1aa5e06e47c844f55bc74bb Mon Sep 17 00:00:00 2001 From: Tom Palmer Date: Wed, 30 Sep 2026 14:51:31 +0100 Subject: [PATCH 1/6] =?UTF-8?q?Don=E2=80=99t=20evaluate=20mr=5Fdgp=20vigne?= =?UTF-8?q?tte=20so=20it=20builds=20without=20OpenGWAS=20credentials?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vignettes/mr_dgp.rmd | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/vignettes/mr_dgp.rmd b/vignettes/mr_dgp.rmd index f05e897..4ee5b86 100644 --- a/vignettes/mr_dgp.rmd +++ b/vignettes/mr_dgp.rmd @@ -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. @@ -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? @@ -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. From 17b2395b4d0d607f2bd4afe6395926795661c940 Mon Sep 17 00:00:00 2001 From: Tom Palmer Date: Wed, 30 Sep 2026 14:54:05 +0100 Subject: [PATCH 2/6] Bump roxygen2 --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index db4ea7c..bde2b25 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -50,5 +50,5 @@ Remotes: mrcieu/TwoSampleMR Encoding: UTF-8 LazyData: true -Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.1 +Config/roxygen2/markdown: TRUE +Config/roxygen2/version: 8.1.0 From 44f442cf33d28a301454e5c38f39f6e212a37aa8 Mon Sep 17 00:00:00 2001 From: Tom Palmer Date: Wed, 30 Sep 2026 14:54:37 +0100 Subject: [PATCH 3/6] Use _PACKAGE sentinel --- R/simulateGP-package.r | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/R/simulateGP-package.r b/R/simulateGP-package.r index 1f597cd..0a5718e 100644 --- a/R/simulateGP-package.r +++ b/R/simulateGP-package.r @@ -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" From 38f8ed7d4de42087cf9db79b756e0f3433317271 Mon Sep 17 00:00:00 2001 From: Tom Palmer Date: Wed, 30 Sep 2026 14:54:44 +0100 Subject: [PATCH 4/6] Document --- NAMESPACE | 38 ++++++++++++++++++++------------------ man/simulateGP-package.Rd | 1 + 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 2be5884..522c769 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) diff --git a/man/simulateGP-package.Rd b/man/simulateGP-package.Rd index 9d62d19..60e60b8 100644 --- a/man/simulateGP-package.Rd +++ b/man/simulateGP-package.Rd @@ -26,6 +26,7 @@ Useful links: Authors: \itemize{ + \item Gibran Hemani \email{explodecomputer@gmail.com} (\href{https://orcid.org/0000-0003-0920-1055}{ORCID}) \item John Ferguson \email{john.ferguson@nuigalway.ie} \item Rita Rasteiro \email{rita.rasteiro@bristol.ac.uk} (\href{https://orcid.org/0000-0002-4217-3060}{ORCID}) } From 8094e78b6e918bded1e5e6d74cce64323691896a Mon Sep 17 00:00:00 2001 From: Tom Palmer Date: Wed, 30 Sep 2026 14:55:13 +0100 Subject: [PATCH 5/6] usethis::use_tidy_description() --- DESCRIPTION | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index bde2b25..f487332 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,9 +2,11 @@ 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. @@ -48,7 +50,7 @@ Remotes: mrcieu/gwasglue2, mrcieu/ieugwasr, mrcieu/TwoSampleMR -Encoding: UTF-8 -LazyData: true Config/roxygen2/markdown: TRUE Config/roxygen2/version: 8.1.0 +Encoding: UTF-8 +LazyData: true From dd16b78fcb43dabd3d8a83baaec39f4f4faaec9f Mon Sep 17 00:00:00 2001 From: Tom Palmer Date: Thu, 1 Oct 2026 09:38:24 +0100 Subject: [PATCH 6/6] Add GitHub repo and mrcieu.r-universe.dev to URL --- DESCRIPTION | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index f487332..2ef2c21 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -13,7 +13,9 @@ Description: Functions for simulating SNP effects on phenotypes. Functions 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)