gxe-mr

Author

Gibran Hemani

Published

December 21, 2025

Background


library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
library(simulateGP)

make_gxe <- function(g, e, b_add, b_int, b_e) {
    n <- length(g)
    stopifnot(length(g) != length(e))
    y <- g * b_add + e * b_e + g * e * b_int
    r <- rnorm(n, 0, sqrt(1 - var(y)))
    y <- y + r
    return(y)
}

sim <- function(nid, nsnp, b_add, b_e, b_int, pop_diff) {
    g1 <- rbinom(nid, 2, 0.5)
    g2 <- rbinom(nid, 2, sample(c(-1, 1), 1) * pop_diff + 0.5)

    mean_e <- 

    e1 <- rnorm(nid, 0, 1)
    e2 <- rnorm(nid, sample(c(-1, 1), 1) * pop_diff, 1)


}


params <- expand.grid(
    nid = 10000,
    nsnp = 100,
    b_add = 0.05,
    b_e = 0.05,
    b_int = c(0, 0.025, 0.05),
    pop_diff = seq(0, 0.5, by=0.1)
)
params
     nid nsnp b_add  b_e b_int pop_diff
1  10000  100  0.05 0.05 0.000      0.0
2  10000  100  0.05 0.05 0.025      0.0
3  10000  100  0.05 0.05 0.050      0.0
4  10000  100  0.05 0.05 0.000      0.1
5  10000  100  0.05 0.05 0.025      0.1
6  10000  100  0.05 0.05 0.050      0.1
7  10000  100  0.05 0.05 0.000      0.2
8  10000  100  0.05 0.05 0.025      0.2
9  10000  100  0.05 0.05 0.050      0.2
10 10000  100  0.05 0.05 0.000      0.3
11 10000  100  0.05 0.05 0.025      0.3
12 10000  100  0.05 0.05 0.050      0.3
13 10000  100  0.05 0.05 0.000      0.4
14 10000  100  0.05 0.05 0.025      0.4
15 10000  100  0.05 0.05 0.050      0.4
16 10000  100  0.05 0.05 0.000      0.5
17 10000  100  0.05 0.05 0.025      0.5
18 10000  100  0.05 0.05 0.050      0.5
sessionInfo()
R version 4.5.2 (2025-10-31)
Platform: aarch64-apple-darwin20
Running under: macOS Sequoia 15.2

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Europe/London
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] simulateGP_0.1.3 dplyr_1.1.4     

loaded via a namespace (and not attached):
 [1] digest_0.6.39     R6_2.6.1          fastmap_1.2.0     tidyselect_1.2.1 
 [5] xfun_0.54         magrittr_2.0.4    glue_1.8.0        tibble_3.3.0     
 [9] knitr_1.50        pkgconfig_2.0.3   htmltools_0.5.8.1 rmarkdown_2.30   
[13] generics_0.1.4    lifecycle_1.0.4   cli_3.6.5         vctrs_0.6.5      
[17] compiler_4.5.2    tools_4.5.2       pillar_1.11.1     evaluate_1.0.5   
[21] yaml_2.3.11       rlang_1.1.6       jsonlite_2.0.0    htmlwidgets_1.6.4