Skip to contents

Estimates a marker-based kinship matrix, independent of pedigree, using the "between-family" KING-robust estimator of Manichaikul et al. (2010), Equation 11 – the estimator KING, PLINK2, SNPRelate::snpgdsIBDKING, and GENESIS::kingToMatrix all implement under the name "KING-robust". Unlike kinship (which is purely pedigree-derived), this function never looks at parentage – it is a genotype-only check, matching the issue's own framing of an independent relatedness estimate.

Usage

markerKinship(genotypeMatrix)

Arguments

genotypeMatrix

a character matrix as returned by buildMarkerGenotypeMatrix: rows are individual ids, columns are loci, and each cell is that individual's two alleles at that locus, sorted and joined by "/" (or NA if not genotyped at that locus).

Value

A numeric id x id matrix (symmetric, diagonal 0.5), the same shape kinship returns.

Details

For a pair of individuals \(i, j\), over the loci genotyped in both: $$\hat\phi_{ij} = 0.5 + \frac{2 N_{AaAa} - 4 N_{AAaa} - N_{Aa}^{(i)} - N_{Aa}^{(j)}}{4 \min(N_{Aa}^{(i)}, N_{Aa}^{(j)})}$$ where \(N_{AaAa}\) counts loci at which both individuals are heterozygous, \(N_{AAaa}\) counts loci at which they have opposite homozygous genotypes (identity-by-state 0), and \(N_{Aa}^{(i)}\)/ \(N_{Aa}^{(j)}\) count each individual's own heterozygous loci (all restricted to the shared, jointly-non-missing locus set). The estimator requires biallelic markers (see checkMarkerGenotypeFile) and is not bounded below by zero – a negative estimate is informative (more divergent ancestry than the reference sample), not an error, and is not clipped.

The diagonal is set to 0.5 by definition (self-kinship), matching kinship's convention, rather than evaluated from the formula above – which divides by zero whenever an individual has no heterozygous loci at all.

When neither individual in a pair has a shared heterozygous locus (the formula's denominator is zero), the pair's kinship is undefined; that pair's entry is NA and a warning names the pair.

References

Manichaikul, A., Mychaleckyj, J. C., Rich, S. S., Daly, K., Sale, M., & Chen, W.-M. (2010). Robust relationship inference in genome-wide association studies. Bioinformatics, 26(22), 2867-2873. doi:10.1093/bioinformatics/btq559

Examples

library(nprcgenekeepr)
markerGenotype <- data.frame(
  id = c("A", "A", "B", "B"),
  locus = c("L1", "L2", "L1", "L2"),
  allele1 = c("A", "A", "A", "A"),
  allele2 = c("A", "B", "B", "B"),
  stringsAsFactors = FALSE
)
genotypeMatrix <- buildMarkerGenotypeMatrix(markerGenotype)
markerKinship(genotypeMatrix)
#>      A    B
#> A 0.50 0.25
#> B 0.25 0.50