extend: Extend pedigree

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/extend.R

Description

extend finds ascendants, which do not appear as individuals in pedigree and assigns them as individuals with unknown ascendants in extended pedigree.

Usage

1
extend(x, ascendant=NULL, col=NULL, top=TRUE)

Arguments

x

pedigree object

ascendant

character, column names of ascendant(s), see details

col

character, column name(s) of attribute(s), see details

top

logical, add ascendants as individuals on the top or bottom of the pedigree

Details

Argument ascendant can be used to define, which ascendants will be extended. If ascendant=NULL, which is the default, all ascendant columns in the pedigree are used. The same approach is used with other pedigree attributes such as sex, generation, etc. with argument col. Use col=NA, if none of the pedigree attributes should be extended.

Sex of “new” individuals is infered from attribute ascendantSex as used in Pedigree function. Generation of “new” individuals is infered as minimal (generationOrder="increasing") or maximal (generationOrder="decreasing") generation value in descendants - 1. See Pedigree on this issue. Family values are extended with means of family.

Value

Extended pedigree, where all ascendants also appear as individuals with unknown ascendants and infered other attributes such as sex, generation, etc. if this attributes are in the pedigree.

Author(s)

Gregor Gorjanc

See Also

Pedigree, family, geneticGroups???

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
  # --- Toy example ---
  ped <- generatePedigree(nId=5, nGeneration=4, nFather=1, nMother=2)
  ped <- ped[10:20,]
  ped[5, "father"] <- NA # to test robustnes of extend on NA
  extend(ped)
  extend(ped, top=FALSE)

  ## Extend only ascendant and their generation
  extend(ped, col="generation")
  extend(ped, col=c("generation", "sex"))

  # --- Bigger example ---
  ped <- generatePedigree(nId=1000, nGeneration=10, nFather=100,
                          nMother=500)
  nrow(ped)
  # Now keep some random individuals
  ped <- ped[unique(sort(round(runif(n=nrow(ped)/2, min=1,
                                     max=nrow(ped))))), ]
  nrow(ped)
  nrow(extend(ped))

Example output

Loading required package: MASS

Attaching package: 'GeneticsPed'

The following object is masked from 'package:stats':

    family

    id father mother generation sex
1    4     NA     NA          1   2
2    9     NA     NA          2   2
3    8     NA     NA          2   2
110  1     NA     NA          1   1
21   6     NA     NA          2   1
10  10      1      4          2   1
11  11      6      9          3   1
12  12      6      8          3   1
13  13      6      9          3   2
14  14     NA      8          3   2
15  15      6      8          3   1
16  16     11     13          4   1
17  17     11     13          4   1
18  18     11     14          4   1
19  19     11     13          4   2
20  20     11     14          4   2
    id father mother generation sex
10  10      1      4          2   1
11  11      6      9          3   1
12  12      6      8          3   1
13  13      6      9          3   2
14  14     NA      8          3   2
15  15      6      8          3   1
16  16     11     13          4   1
17  17     11     13          4   1
18  18     11     14          4   1
19  19     11     13          4   2
20  20     11     14          4   2
110  1     NA     NA          1   1
21   6     NA     NA          2   1
1    4     NA     NA          1   2
2    9     NA     NA          2   2
3    8     NA     NA          2   2
    id father mother generation sex
1    4     NA     NA          1  NA
2    9     NA     NA          2  NA
3    8     NA     NA          2  NA
110  1     NA     NA          1  NA
21   6     NA     NA          2  NA
10  10      1      4          2   1
11  11      6      9          3   1
12  12      6      8          3   1
13  13      6      9          3   2
14  14     NA      8          3   2
15  15      6      8          3   1
16  16     11     13          4   1
17  17     11     13          4   1
18  18     11     14          4   1
19  19     11     13          4   2
20  20     11     14          4   2
    id father mother generation sex
1    4     NA     NA          1   2
2    9     NA     NA          2   2
3    8     NA     NA          2   2
110  1     NA     NA          1   1
21   6     NA     NA          2   1
10  10      1      4          2   1
11  11      6      9          3   1
12  12      6      8          3   1
13  13      6      9          3   2
14  14     NA      8          3   2
15  15      6      8          3   1
16  16     11     13          4   1
17  17     11     13          4   1
18  18     11     14          4   1
19  19     11     13          4   2
20  20     11     14          4   2
[1] 10000
[1] 3917
[1] 5959

GeneticsPed documentation built on Nov. 8, 2020, 5:54 p.m.