Kinship Formats

The format for storing kinships uses four files: the binary file with extension grm.bin contains the pairwise kinships, while the text files with extensions grm.id, grm.details and grm.adjust contain, respectively, the sample IDs, details for each predictor and some fun facts about the kinship matrix.

Previously (until about 2014), the pairwise kinships were saved in a gzipped file. If you have a kinship matrix stored in this format, you can convert to binary using

--convert-gz <output> --grm <kinfile>

This will search for the files <kinfile>.grm.gz and <kinfile>.grm.id. If you wish to save to this format, then add --kinship-gz YES whenever running an LDAK command which produces a kinship matrix.

Alternatively, if the pairwise kinships are saved in a text file (as a square matrix with no headers), you can convert these to binary format using

--convert-raw <output> --grm <kinfile>

This will search for the files <kinfile>.grm.raw and <kinfile>.grm.id. If you wish to save to this format, then add --kinship-raw YES whenever running an LDAK command which produces a kinship matrix.
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Example: for this we use the binary PLINK files test.bed, test.bim and test.fam available in the Test Datasets, and the weightings calculated in Get Weightings.

First, we will re-calculate the kinship matrix with stem kinships, but additionally saving the kinships in gzipped and raw format.

../ldak.out --calc-kins-direct kinships --bfile test --weights sections/weights.short --power -0.25 --kinship-gz YES --kinship-raw YES

This has generated the extra files kinships.grm.gz and kinships.grm.raw. To convert each of these back to binary format, we could use

cp kinships.grm.gz kin1.grm.gz
cp kinships.grm.id kin1.grm.id
../ldak.out --convert-gz kin1_conv --grm kin1

cp kinships.grm.raw kin2.grm.raw
cp kinships.grm.id kin2.grm.id
../ldak.out --convert-raw kin2_conv --grm kin2

The (binary format) kinship matrices are saved with stems kin1_conv and kin2_conv. Note that there was no need to first copy the files, this was just to show which files LDAK uses (either grm.gz & grm.id or grm.raw & grm.id).