| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
set -exo pipefail |
| 4 |
|
| 5 |
plink --simulate simulate.txt --simulate-missing 0.01 --out tmp_data |
| 6 |
|
| 7 |
# Force last few variants to chrX. (chrY and chrM expected to be different.) |
| 8 |
# (Unfortunately, "head -n -2" doesn't work on macOS.) |
| 9 |
head -n 295 tmp_data.bim > tmp_data2.bim |
| 10 |
tail -n 2 tmp_data.bim > last_two.txt |
| 11 |
head -n 1 last_two.txt | sed 's/^1/X/g' >> tmp_data2.bim |
| 12 |
tail -n 1 last_two.txt | sed 's/^1/X/g' >> tmp_data2.bim |
| 13 |
cp tmp_data2.bim tmp_data.bim |
| 14 |
# Force some samples to male or no-sex. |
| 15 |
head -n 1234 tmp_data.fam > tmp_data2.fam |
| 16 |
head -n 1357 tmp_data.fam | tail -n +1235 | sed 's/2 1$/0 1/g' >> tmp_data2.fam |
| 17 |
tail -n +1358 tmp_data.fam | sed 's/2 1$/1 1/g' >> tmp_data2.fam |
| 18 |
cp tmp_data2.fam tmp_data.fam |
| 19 |
|
| 20 |
plink --bfile tmp_data --a2-allele tmp_data.bim 5 2 --freqx |
| 21 |
$1/plink2 $2 $3 --bfile tmp_data --output-chr 26 --geno-counts cols=-provref |
| 22 |
|
| 23 |
cat plink.frqx | tail -n +2 > plink.frqx.headerless |
| 24 |
|
| 25 |
cat plink2.gcount | tail -n +2 > plink2.gcount.headerless1 |
| 26 |
diff -q plink.frqx.headerless plink2.gcount.headerless1 |
| 27 |
$1/pgen_compress tmp_data.bed tmp_data.pgen 2000 |
| 28 |
$1/plink2 $2 $3 --bpfile tmp_data --output-chr 26 --geno-counts cols=-provref |
| 29 |
|
| 30 |
cat plink2.gcount | tail -n +2 > plink2.gcount.headerless2 |
| 31 |
diff -q plink.frqx.headerless plink2.gcount.headerless2 |
| 32 |
|
| 33 |
# Select a random subset of samples. |
| 34 |
$1/plink2 $2 $3 --bfile tmp_data --thin-indiv 0.5 --write-samples --out subset |
| 35 |
|
| 36 |
plink --bfile tmp_data --a2-allele tmp_data.bim 5 2 --keep subset.id --freqx --out plink_subset |
| 37 |
$1/plink2 $2 $3 --bfile tmp_data --output-chr 26 --keep subset.id --geno-counts cols=-provref --out plink2_subset |
| 38 |
cat plink_subset.frqx | tail -n +2 > plink_subset.frqx.headerless |
| 39 |
cat plink2_subset.gcount | tail -n +2 > plink2_subset.gcount.headerless1 |
| 40 |
diff -q plink_subset.frqx.headerless plink2_subset.gcount.headerless1 |