#!/bin/bash



### 1. Use GCTA to create phenotypes from those causal SNPs & their MAF-scaled effect sizes within your sample:
for ii in {1..3}
do
    gcta64 --bfile simulation_2/5K.unrel0.05 --simu-qt --simu-hsq 0.5 --simu-causal-loci simulation_3/common.rep"$ii".MAFscaled.txt --out simulation_3/pheno.common.rep"$ii"scaled.txt &
    gcta64 --bfile simulation_2/5K.unrel0.05 --simu-qt --simu-hsq 0.5 --simu-causal-loci simulation_3/rare.rep"$ii".MAFscaled.txt --out simulation_3/pheno.rare.rep"$ii"scaled.txt & 
done
wait


### 2. Use GCTA to test the influence of causal variant MAF (which you've simulated two different conditions) on SNP-heritability
ii=1 ### just do the first replicate right now
gcta64 --grm simulation_2/5K.unrel0.05 --pheno simulation_3/pheno.common.rep"$ii"scaled.txt.phen --reml --reml-no-lrt --out simulation_3/hsq.common.rep"$ii"scaled --thread-num 4
gcta64 --grm simulation_2/5K.unrel0.05 --pheno simulation_3/pheno.rare.rep"$ii"scaled.txt.phen --reml --reml-no-lrt --out simulation_3/hsq.rare.rep"$ii"scaled --thread-num 4
# how would you do this efficiently for every simulated phenotype or all the replicates?


grep -P 'V\(G\)\/Vp' simulation_3/*hsq  ### How could you test if there is a difference in hsq estimates based on MAF of the (simulated) causal variants?
