diff --git a/DESCRIPTION b/DESCRIPTION index db4ea7c..2ef2c21 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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) @@ -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 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/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" 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}) } 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.