This 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)

Arguments

pedigree

A data frame containing pedigree information with the following columns:

  • id: Unique identifier for each individual

  • mother: ID of the individual's mother (0 or NA for unknown/founder)

  • father: ID of the individual's father (0 or NA for unknown/founder)

Value

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

Examples

# 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)