Manipulate Kinships

LDAK can both add and subtract kinship matrices. The latter can be useful for Adaptive MultiBLUP or mixed-model linear regression. Suppose that you wish to construct two kinship matrices, one corresponding to a region (subset of predictors) and one to the rest of the genome. Rather than calculate both from scratch, you can instead compute the regional kinship matrix, then obtain its complement by subtracting this from the genome-wide kinship matrix.

Ideally all kinship matrices involved have been derived from the same datafile, using the same predictor weightings and (subset of) samples. When a predictor is included in more than one kinship matrix, its mean must be the same for all occurrences.
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Add kinship matrices:

--add-grm <output> --mgrm <kinstems>

LDAK will add the kinship matrices specified in <kinstems> and save with stem <output>.
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Subtract kinship matrices:

There are three ways to subtract kinship matrices. The first takes the form

--sub-grm <output> --mgrm <kinstems>

Suppose the file <kinstems> provides the stems of K kinship matrices; LDAK will subtract kinship matrices 2, 3, ..., K from the first kinship matrix; the resulting kinship matrix will be saved with stem <output>.
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

An alternative way to do this would be to first create a file called <excludefile> which contains all the predictors used to create kinship matrices 2, 3, ..., K, then use the command

--sub-grm <output> --grm <kinfile> --exclude <excludefile>

For this it is necessary to use --bfile/--gen/--sp/--speed <prefix> to specify the1 datafiles used to make the first kinship matrix.
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

The third way is to create a file called <extractfile> which indicates which predictors used to make the first kinship matrix should remain after subtracting those used to make kinship matrices 2, 3, ..., K, then use the command

--sub-grm <output> --grm <kinfile> --extract <extractfile>

Again, it is necessary to use --bfile/--gen/--sp/--speed <prefix> to provide the datafiles used to make the first kinship matrix.
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Example:

Here we use the binary PLINK files human.bed, human.bim and human.fam, and the lists of SNPs part1 and part2 from the Test Datasets. First we must calculate a couple of kinship matrices; usually we would construct these assuming the LDAK-Thin Model, but for simplicity, we instead use the GCTA Model (see Heritability Models for more details).

./ldak.out --calc-kins-direct part1 --bfile human --ignore-weights YES --power -1 --extract part1
./ldak.out --calc-kins-direct part2 --bfile human --ignore-weights YES --power -1 --extract part2

These commands produce kinship matrices with stems part1 and part2.
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

To add the two kinship matrices, first make a file providing the two stems

echo "part1
part2" > list.txt

Next run the command

./ldak.out --add-grm part3 --mgrm list.txt

This produces the kinship matrix with stem part3.
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

To subtract the kinship matrix with stem part2 from that with stem part3, first make a file providing the two stems

echo "part3
part2" > list2.txt

Next run the command

./ldak.out --sub-grm part4 --mgrm list2.txt

This produces the kinship matrix with stem part4, which will be identical to that with stem part1.

You could perform exactly the same using either of the following two commands

./ldak.out --sub-grm part4b --grm part3 --exclude part2 --bfile human
./ldak.out --sub-grm part4c --grm part3 --extract part1 --bfile human

The kinship matrices with stems part4b and part4c will both match that with stem part4.