
Get the direct relatives of selected animals from a pedigree file
Source:R/getFileDirectRelatives.R
getFileDirectRelatives.RdFile-sourced sibling of getLkDirectRelatives: reads a pedigree
file through the internal getPedigreeSource() "file" provider
(via getPedigree), then delegates the pedigree walk to the
source-agnostic getPedDirectRelatives. The result is the full
connected pedigree component (ancestors, descendants, and collaterals such as
siblings and mates) reachable from the focal animals. It is fully offline and
deterministic.
Arguments
- ids
character vector with Ids.
- fileName
path to a pedigree file (CSV or Excel) read via
getPedigree; the file must provide at leastid,sire, anddamcolumns.- sep
column separator passed to the file reader for delimited text files (default
","); ignored for Excel files.logical vector when
FALSEthe unrelated parents of offspring do not get a record as an ego; whenTRUEa place holder record where parent (sire,dam) IDs are set toNA.
Value
A data.frame with pedigree structure containing all direct relatives – the full connected pedigree component (ancestors, descendants, and collaterals) – for the Ids provided.
Details
Unlike the LabKey source, which fails soft (returns NULL) when its
fetch fails, the file source errors loudly: a NULL or missing
fileName, a file that does not exist, or a file lacking the
id, sire, and dam columns each raises an error.
Examples
library(nprcgenekeepr)
## Build a tiny pedigree file, then pull the relatives of a focal animal.
ped <- data.frame(
id = c("A", "B", "C"), sire = c(NA, NA, "A"), dam = c(NA, NA, "B"),
stringsAsFactors = FALSE
)
pedFile <- tempfile(fileext = ".csv")
write.csv(ped, pedFile, row.names = FALSE)
getFileDirectRelatives(ids = "C", fileName = pedFile)
#> id sire dam
#> 1 A <NA> <NA>
#> 2 B <NA> <NA>
#> 3 C A B
unlink(pedFile)