Skip to content

Instantly share code, notes, and snippets.

@explodecomputer
Created June 16, 2015 09:48
Show Gist options
  • Save explodecomputer/96a6f0569a6e20db1c59 to your computer and use it in GitHub Desktop.
Save explodecomputer/96a6f0569a6e20db1c59 to your computer and use it in GitHub Desktop.
Bivariate vs univariate SNP h2
# Use this code to extract HM3 SNPs https://github.com/explodecomputer/data_manipulation
plink1.90 --bfile alspac_hm3_kids --keep alspac_hm3_kids_unrelated_all.grm.id --make-bed --out ~/testdata --thread-num 16
shuf -n 1000 ~/testdata.bim | cut -f 2 > ~/snplist.txt
gcta64 --bfile ~/testdata --simu-qt --simu-causal-loci ~/snplist.txt --simu-hsq 0.8 --out trait1 --thread-num 16
gcta64 --bfile ~/testdata --simu-qt --simu-causal-loci ~/snplist.txt --simu-hsq 0.3 --out trait2
plink1.90 --bfile ~/testdata --make-grm-bin --out ~/testdata --maf 0.01
gcta64 --grm ~/repo/mQTL-partitioning/grm/alspac_hm3_kids_unrelated_all --reml --reml-no-lrt --pheno ~/trait1.phen --out ~/trait1 --thread-num 16
gcta64 --grm ~/repo/mQTL-partitioning/grm/alspac_hm3_kids_unrelated_all --reml --reml-no-lrt --pheno ~/trait2.phen --out ~/trait2 --thread-num 16
cut -d " " -f 3 ~/trait2.phen > temp
paste -d " " ~/trait1.phen temp > ~/traits.phen
rm temp
gcta64 --grm ~/repo/mQTL-partitioning/grm/alspac_hm3_kids_unrelated_all --reml-bivar 1 2 --pheno ~/traits.phen --out ~/trait12 --thread-num 16
# in R: to simulate bivariate h2
eff1 <- rnorm(1000)
eff2 <- eff1 + rnorm(1000)
dat1 <- data.frame(snplist, eff1)
write.table
dat2 <- data.frame(snplist, eff2)
write.table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment