This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set.seed(42) | |
options(digits=3) | |
# --- Parameters | |
# sibling pairs | |
N = 100e3 | |
# unadmixed individuals (for population estimate) | |
N_unadmixed = 10e3 | |
# number of variants | |
M = 100 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("RColorBrewer") | |
# --- | |
# Parameters | |
# --- | |
# Samples | |
N = 2e3 | |
# Epistatic heritability : | |
hsq_epistatic = 0.5 | |
# Allele frequencies to use |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clr = c("#d53e4f","#fc8d59","#99d594") | |
n=500e3 | |
hsq = 0.5 | |
seeds = 10 | |
par(mfrow=c(1,4)) | |
for ( maf in c(0,0.05,0.2,0.5) ) { | |
plot(0,0,xaxt="n",las=1,type="n",pch=19,ylab="Phenotype",xlab="Genotype",ylim=c(-1,30),xlim=c(0,2),bty="n",main="") | |
axis(side=1,at=c(0,1,2),labels = c("AA","Aa","aa")) | |
hsq_add = rep(NA,seeds) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(survival) | |
# --- | |
# Parameters | |
# --- | |
# number of individuals | |
n = 50e3 | |
# desired hazard ratio | |
HR = 1.64 | |
beta = log(HR) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fixed parameters | |
N = 10e6 | |
AM_cor = 0.50 | |
for ( Cultural_cor in c(sqrt(0.15),0.51) ) { | |
cat("\nSimulating cultural transmission of" , Cultural_cor , '\n' ) | |
# Simulate two parental traits | |
y_mother = rnorm(N,0,1) | |
y_father = rnorm(N,0,1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set.seed(42) | |
### --- REML | |
# Original code: | |
# https://github.com/sashagusev/SKK-REML-sim/blob/master/func_reml.R | |
library('msm') | |
# Utility function for calculating log of determinant | |
`logdet` <- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simulations and visualization of a heritable liability threshold model across generations and in families | |
# --- | |
# Liability functions (from Baselmans et al.) | |
# See: https://github.com/BartBaselmans/CHARRGe | |
risk_from_liability = function( prev , h2 ) { | |
# Threshold | |
Tx = -qnorm(prev,0,1) | |
z = dnorm(Tx) | |
i = z/prev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set.seed(1) | |
# Library for GLMM computations | |
library(PQLseq2) | |
# Library for mixed model / Wald test | |
library("GMMAT") | |
# convenience function to suppress prints | |
quiet <- function(x) { | |
sink(tempfile()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set.seed(42) | |
# Library for GLMM computations | |
library(PQLseq2) | |
# Library for mixed model / Wald test | |
library("GMMAT") | |
# convenience function to suppress prints | |
quiet <- function(x) { | |
sink(tempfile()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set.seed(42) | |
# Library for GLMM computations | |
library(PQLseq2) | |
quiet <- function(x) { | |
sink(tempfile()) | |
on.exit(sink()) | |
invisible(force(x)) | |
} |
NewerOlder