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
# --- admixture analysis | |
# sample size | |
N = 5e3 | |
# mate correlation | |
AM_cor = 0.75 | |
# variance in ancestry transmission | |
genetic_sd = 0.025 |
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
# number of samples in each study | |
N = 2e3 | |
# number of studies to run | |
seeds = 50 | |
# vectors for storing results | |
est_a = rep(NA,seeds) | |
est_c = rep(NA,seeds) | |
est_e = rep(NA,seeds) | |
est_y1 = 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
set.seed(42) | |
# sample size | |
N = 10e3 | |
# generate two groups | |
group = rbinom( N , 1 , 0.5 ) | |
# generate group-specific environments | |
shared_env = rnorm(N,group*-15,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
args = as.numeric(commandArgs(trailingOnly=TRUE)) | |
# N,M,var_direct,var_indirect | |
# code for implementation of REML: | |
# https://github.com/sashagusev/SKK-REML-sim/blob/master/func_reml.R | |
source("reml_func.R") | |
# Num individuals | |
N = 1e3 |
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
# Num individuals | |
N = 10e3 | |
# Num markers | |
M = 10 | |
# Assortative Mating | |
AM_cor = 0.75 | |
# Minor allele frequency | |
maf = 0.5 | |
# Heritability |
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) | |
# Num individuals | |
par( mfrow=c(1,4) ) | |
# Num markers | |
M = 500 | |
# Minor allele frequency | |
maf = 0.5 | |
LABEL = TRUE |
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
# Num individuals | |
N = 2e3 | |
# Num markers | |
M = 1e3 | |
# Affected cutoff | |
aff_thresh = 70 | |
# Minor allele frequency | |
maf = 0.5 | |
# simulate different parameter settings |
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
# reproducibility: | |
set.seed(42) | |
# number of causal variants: | |
M = 5e3 | |
# number of individuals | |
N = 10e3 | |
# heritability | |
hsq = 0.25 | |
# sample individuals with admixture |
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
get_correlated_trait = function(input,r) { | |
r * (input) + sqrt(1-r^2) * rnorm(length(input),0,1) | |
} | |
get_noisy_trait = function(input,noise) { | |
sqrt(1-noise) * (input) + sqrt(noise) * rnorm(length(input),0,1) | |
} | |
simulate_non_genetic = function(N,AM,ENV,err) { | |
set.seed(42) |
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
N = 50000 | |
get_correlated_trait = function(input,r) { | |
r * scale(input) + sqrt(1-r^2) * rnorm(length(input),0,1) | |
} | |
get_noisy_trait = function(input,noise) { | |
sqrt(1-noise) * scale(input) + sqrt(noise) * rnorm(length(input),0,1) | |
} | |
# good parameters from a 2-dof grid search |