build_pedigree: Build pedigree

Description Usage Arguments Details Value Methods (by generic) See Also Examples

View source: R/pedigree.R

Description

Builds a full pedigree out of observed data with sorting and recoding.

Usage

1
2
3
4
build_pedigree(x, self = x[[1]], sire = x[[2]], dam = x[[3]], data)

## S3 method for class 'pedigree'
as.data.frame(x, ...)

Arguments

x

if given, a vector of length 3 with indices or names of columns in data corresponding to self, sire and dam codes

self

index or column name in data with codes of sires

sire

index or column name in data with codes of individuals

dam

index or column name in data with codes of dams

data

a dataframe or a list to take the individual codes from

...

Not used

Details

A full pedigree requires that all the individual codes for sires or dams are present as individuals themselves, possibly with unknown parents. Therefore, for using it in a statistical model, it is necessary to complete the pedigree by introducing new individuals with unknown parents.

Furthermore, the codes must be sorted in ascending and consecutive order beginning from 1, and the offspring must follow parents. All this is checked, and the pedigree is reordered and recoded if needed.

If recoding is needed, the function issues a warning and an attribute 'map' is attached to the pedigree, such that map[i] = j means that code i was renumbered as j. Therefore, if x is a vector with original codes, map[x] gives the new codes. Conversely, match(y, map) back-transforms to original codes.

Value

A well-formed 'pedigree'-class object. Possibly sorted and recoded.

Methods (by generic)

See Also

check_pedigree

Examples

1
2
3
4
5
6
# Founders are missing in the globulus dataset
data(globulus)
check_pedigree(globulus[,c('self', 'dad', 'mum')])
# build_pedigree completes the missing information
ped <- build_pedigree(c('self', 'dad', 'mum'), data = globulus)
check_pedigree(ped)

famuvie/breedR documentation built on Sept. 6, 2021, 4:50 a.m.