pedigree: Pedigree Constructor

Description Usage Arguments Value References See Also Examples

View source: R/pedigree.R

Description

Construct an object of class "pedigree", more conveniently than by new("pedigree", ....).

Usage

1
pedigree(sire, dam, label)

Arguments

sire

numeric vector (with some NA entries) of integer IDs, denoting a previous entry in the pedigree corresponding to the current entry's “father”.

dam

similarly as sire for the “mother” of each entry.

label

a vector coercable to "character" of the same length as sire and dam giving a unique ID for the corresponding entry.

Value

an object of formal class "pedigree".

References

2010. A.I. Vazquez, D.M. Bates, G.J.M. Rosa, D. Gianola and K.A. Weigel. Technical Note: An R package for fitting generalized linear mixed models in animal breeding. Journal of Animal Science, 88:497-504.

See Also

the pedigree class.

Examples

1
2
3
4
5
6
7
example("pedigree-class") ## 'p1' pedigree object `the hard way'

ped <- pedigree(sire = c(NA,NA,1, 1,4,5),
                dam  = c(NA,NA,2,NA,3,2), label= 1:6)
## note that 'label' is coerced to character automatically
ped
stopifnot(identical(ped, p1))

Example output

Loading required package: lme4
Loading required package: Matrix

pdgr-c> ## Rather use, pedigree()!   The following is "raw code":
pdgr-c> ## Example from chapter 2 of Mrode (2005)
pdgr-c> p1 <- new("pedigree",
pdgr-c+           sire = as.integer(c(NA,NA,1, 1,4,5)),
pdgr-c+           dam  = as.integer(c(NA,NA,2,NA,3,2)),
pdgr-c+           label = as.character(1:6))

pdgr-c> p1
  sire  dam
1 <NA> <NA>
2 <NA> <NA>
3    1    2
4    1 <NA>
5    4    3
6    5    2

pdgr-c> (dtc <- as(p1, "sparseMatrix"))   # T-inverse in Mrode's notation
6 x 6 sparse Matrix of class "dtCMatrix" (unitriangular)
                            
1  I    .    .    .    .   .
2  .    I    .    .    .   .
3 -0.5 -0.5  I    .    .   .
4 -0.5  .    .    I    .   .
5  .    .   -0.5 -0.5  I   .
6  .   -0.5  .    .   -0.5 I

pdgr-c> solve(dtc)
6 x 6 sparse Matrix of class "dtCMatrix"
                               
[1,] 1.00 .     .    .    .   .
[2,] .    1.000 .    .    .   .
[3,] 0.50 0.500 1.00 .    .   .
[4,] 0.50 .     .    1.00 .   .
[5,] 0.50 0.250 0.50 0.50 1.0 .
[6,] 0.25 0.625 0.25 0.25 0.5 1

pdgr-c> inbreeding(p1)
[1] 0.000 0.000 0.000 0.000 0.125 0.125
  sire  dam
1 <NA> <NA>
2 <NA> <NA>
3    1    2
4    1 <NA>
5    4    3
6    5    2

pedigreemm documentation built on May 30, 2017, 4:14 a.m.