file1=~/local/vc_asthma.sim rm $file1 seed=10001 while [ $seed -le 11000 ] do #1# for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22; do #2# # First: Runs Merlin on the real dat, ped and map files and creates replicate dataset # # (dat, ped and map files) with simulated genotypes under the null of no linkage # merlin -d asthma_chr${i}.dat -p asthma_chr${i}.ped -m asthma_chr${i}.map --simulate --save -r $seed # Second: runs linkage analysis identical to that used with real data but now on the replicate dat, ped and map files # merlin -d merlin-replicate.dat -p merlin-replicate.ped -m merlin-replicate.map --grid:2 --start:0 --vc --usecovariates > temp.dat # Third: Joins the output of all chromosomes and of all simulations # cat temp.dat | tail +`grep -n " Position H2 ChiSq LOD pvalue" < temp.dat | awk -F ':' '{ print $1 }'` | tail +2 | grep -v "^$" | awk '{ print $0, '"$i"' }' | awk '{ print $0, '"$seed"' }' >> $file1 done #2# seed=`expr $seed + 1` done #1#