inbreed: Calculate inbreeding coefficients

View source: R/inbreed.R

inbreedR Documentation

Calculate inbreeding coefficients

Description

inbreed function calculates the inbreeding coefficients for all individuals in a tidied pedigree.

Usage

inbreed(ped, ...)

Arguments

ped

A tidyped object.

...

Additional arguments (currently ignored).

Details

This function takes a pedigree tidied by the tidyped function and calculates the inbreeding coefficients using an optimized C++ implementation of the Sargolzaei & Iwaisaki (2005) LAP (Longest Ancestral Path) bucket algorithm. This method is the fastest known direct algorithm for computing all inbreeding coefficients: it replaces the O(N^2) linear scan of Meuwissen & Luo (1992) with O(1) bucket pops and selective ancestor clearing, giving O(\sum m_i) total work where m_i is the number of distinct ancestors of individual i. At N = 1{,}000{,}000, the kernel completes in approximately 0.12 s — over 10\times faster than the previous Meuwissen & Luo (1992) implementation and on par with the pedigreemm reference C implementation of the same algorithm. It is the core engine used by both tidyped(..., inbreed = TRUE) and pedmat(..., method = "f"), ensuring consistent results across the package.

Value

A tidyped object with an additional column f.

Examples

library(visPedigree)
data(simple_ped)
ped <- tidyped(simple_ped)
ped_f <- inbreed(ped)
ped_f[f > 0, .(Ind, Sire, Dam, f)]

visPedigree documentation built on March 30, 2026, 9:07 a.m.