pedstats: Pedigree Statistics

pedstatsR Documentation

Pedigree Statistics

Description

Calculates comprehensive statistics for a pedigree, including population structure, generation intervals, and ancestral depth.

Usage

pedstats(
  ped,
  timevar = NULL,
  unit = "year",
  cycle = NULL,
  ecg = TRUE,
  genint = TRUE,
  ...
)

Arguments

ped

A tidyped object.

timevar

Optional character. Name of the column containing the birth date (or hatch date) of each individual. Accepted column formats:

  • Date or POSIXct (recommended).

  • A date string parseable by as.POSIXct (e.g., "2020-06-15"). Use format via ... for non-ISO strings.

  • A numeric year (e.g., 2020). Automatically converted to Date ("YYYY-07-01") with a message.

If NULL, attempts auto-detection from common column names ("BirthYear", "Year", "BirthDate", etc.).

unit

Character. Time unit for reporting generation intervals: "year" (default), "month", "day", or "hour".

cycle

Numeric. Optional target generation cycle length in units. When provided, gen_intervals will include a GenEquiv column (observed Mean / cycle). See pedgenint for details.

ecg

Logical. Whether to compute equivalent complete generations for each individual via pedecg. Default TRUE.

genint

Logical. Whether to compute generation intervals via pedgenint. Requires a detectable timevar column. Default TRUE.

...

Additional arguments passed to pedgenint, e.g., format for custom date parsing or by for grouping.

Value

An object of class pedstats, which is a list containing:

  • summary: A data.table with one row summarising the whole pedigree. Columns:

    • N — total number of individuals.

    • NSire — number of unique sires.

    • NDam — number of unique dams.

    • NFounder — number of founder individuals (both parents unknown).

    • MaxGen — maximum generation number.

  • ecg: A data.table with one row per individual (NULL if ecg = FALSE). Columns:

    • Ind — individual identifier.

    • ECG — equivalent complete generations.

    • FullGen — number of fully known generations.

    • MaxGen — maximum traceable generation depth.

  • gen_intervals: A data.table of generation intervals (NULL if no timevar is detected or genint = FALSE). Columns:

    • Pathway — gametic pathway label. Seven values: "SS" (sire to son), "SD" (sire to daughter), "DS" (dam to son), "DD" (dam to daughter) — require offspring sex; "SO" (sire to offspring) and "DO" (dam to offspring) — sex-independent; and "Average" — all parent-offspring pairs combined.

    • N — number of parent-offspring pairs.

    • Mean — mean generation interval.

    • SD — standard deviation of the interval.

    • GenEquivMean / cycle (only present when cycle is supplied).

Examples


# ---- Without time variable ----
tp <- tidyped(simple_ped)
ps <- pedstats(tp)
ps$summary
ps$ecg

# ---- With annual Year column (big_family_size_ped) ----
tp2 <- tidyped(big_family_size_ped)
ps2 <- pedstats(tp2, timevar = "Year")
ps2$summary
ps2$gen_intervals



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