Kinship Manipulation

LDAK can both add and subtract kinship matrices. The latter can be useful for Genomic Paritioning or Adaptive MultiBLUP; suppose that you wish to construct two kinship matrices, one corresponding to a small region 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 and using the same predictor weightings and (subset of) samples.
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

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

LDAK will add the kinship matrices specified in <kinstems>, and save to <output>.grm.id, <output>.grm.bin, <output>.grm.N.bin, with corresponding files <output>.grm.adjust and <output>.grm.details.
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

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

LDAK will read the first kinship matrix specified in <kinstems>, then subtract from it all remaining kinship matrices. The resulting kinships will be saved to <output>.grm.id, <output>.grm.bin, <output>.grm.N.bin, with corresponding files <output>.grm.adjust and <output>.grm.details.

Alternatively, it is possible to subtract regional kinship matrices without having first computed them. The command

–sub-grm <output> –grm <kinfile> –region-number X –region-prefix <input>

will remove (all instances of) SNPs in <input>1, …, <input>X from <kinfile>.
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

When a predictor is included in more than one kinship matrix, its mean and variance must be the same for all occurrences. In all cases, you can use the option –kinship-gz YES to save the kinship matrix in compressed form (with extension grm.gz), or –kinship-raw YES to save as a square matrix (with extension grm.raw).

If the original kinship matrices were not created from the same datafiles, you should use the option –same-data NO. If they were not created using LDAK, you will need to use –kinship-details NO (although this is not possible when subtracting regional SNPs).
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

In Get Kinships we computed three kinship matrices with prefixes partitions/kinship1, partitions/kinship2 and partitions/kinship3 using the Test Datasets. The file alist.txt contains
partitions/kinship1
partitions/kinship2
partitions/kinship3

./ldak.out –add-grm partitions/kinshipA –mgrm alist.txt

will add partitions/kinship1, partitions/kinship2 and partitions/kinship3, and the resulting files with prefix partitions/kinshipA.grm will correspond to kinships calculated across all three partitions (i.e. match the kinships saved with prefix partitions/kinshipALL).
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

The file slist.txt contains
partitions/kinshipA
partitions/kinship1
partitions/kinship2
then the command

./ldak.out –sub-grm partitions/kinshipB –mgrm slist.txt

will subtract partitions/kinship1 and partitions/kinship2 from partitions/kinshipA, so the resulting files with prefix partitions/kinshipB.grm will be the same as partitions/kinship3.

Note that this command will return an error if partitions/kinship1 and partitions/kinship2 contained predictors which were not used for creating partitions/kinshipA.
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

The predictors in list1 and list2 are subsets of those used for creating partitions/kinshipA, so we can remove their contribution using

./ldak.out –sub-grm partitions/kinshipC –grm partitions/kinshipA –region-number 2 –region-prefix list –bfile test

The new kinships will be stored with prefix partitions/kinshipC.