calculate_kinship_slow.RdThis function calculates pairwise kinship coefficients for all individuals in a pedigree. The kinship coefficient between two individuals is the probability that a randomly chosen allele from one individual is identical by descent to a randomly chosen allele from the same locus in the other individual.
calculate_kinship_slow(pedigree)A symmetric matrix of kinship coefficients where:
Row and column names are individual IDs
i,i contains the inbreeding coefficient + 0.5 for individual i
i,j contains the kinship coefficient between individuals i and j
# Create a simple pedigree with 3 individuals
ped <- data.frame(
id = c(1, 2, 3),
mother = c(0, 0, 2),
father = c(0, 0, 1)
)
kinship_matrix <- calculate_kinship(ped)