R code to calculate pairwise genetic relatedness