splitped: Split Pedigree into Disconnected Groups

View source: R/splitped.R

splitpedR Documentation

Split Pedigree into Disconnected Groups

Description

Detects and splits a tidyped object into disconnected groups (connected components). Uses igraph to efficiently find groups of individuals that have no genetic relationships with each other. Isolated individuals (Gen = 0, those with no parents and no offspring) are excluded from group splitting and stored separately.

Usage

splitped(ped)

Arguments

ped

A tidyped object created by tidyped.

Details

This function identifies connected components in the pedigree graph where edges represent parent-offspring relationships. Two individuals are in the same group if they share any ancestry (direct or indirect).

Isolated individuals (Gen = 0 in tidyped output) are those who:

  • Have no known parents (Sire and Dam are both NA)

  • Are not parents of any other individual in the pedigree

These isolated individuals are excluded from splitting and stored in the isolated attribute. Each resulting group contains at least 2 individuals (at least one parent-offspring relationship).

The function always returns a list, even if there is only one group (i.e., the pedigree is fully connected). Groups are sorted by size in descending order.

Each group in the result is a valid tidyped object with:

  • Renumbered IndNum (1 to n for each group)

  • Updated SireNum and DamNum referencing the new IndNum

  • Recalculated Gen (generation) based on the group's structure

Value

A list of class "splitped" containing:

GP1, GP2, ...

tidyped objects for each disconnected group (with at least 2 individuals), with renumbered IndNum, SireNum, DamNum

The returned object has the following attributes:

n_groups

Number of disconnected groups found (excluding isolated individuals)

sizes

Named vector of group sizes

total

Total number of individuals in groups (excluding isolated)

isolated

Character vector of isolated individual IDs (Gen = 0)

n_isolated

Number of isolated individuals

See Also

tidyped for pedigree tidying

Examples

# Load example data
library(visPedigree)
data(small_ped)

# First tidy the pedigree
tped <- tidyped(small_ped)

# Split into groups
result <- splitped(tped)
print(result)

# Access individual groups (each is a tidyped object)
result$GP1

# Check isolated individuals
attr(result, "isolated")


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