check: Check consistency of data in pedigree

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

View source: R/check.pedigree.R

Description

check performs a series of checks on pedigree object to ensure consistency of data.

Usage

1
2
check(x, ...)
checkId(x)

Arguments

x

pedigree, object to be checked

...

arguments to other methods, none for now

Details

checkId performs various checks on individuals and their ascendants. These checks are:

checkAttributes is intended primarly for internal use and performs a series of checks on attribute values needed in various functions. It causes stop with error messages for all given attribute checks.

Value

List of more or less self-explanatory errors and "pointers" to these errors for ease of further work i.e. removing errors.

Author(s)

Gregor Gorjanc

See Also

Pedigree

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  ## EXAMPLES BELLOW ARE ONLY FOR TESTING PURPOSES AND ARE NOT INTENDED
  ## FOR USERS, BUT IT CAN NOT DO ANY HARM.

  ## --- checkAttributes ---
  tmp <- generatePedigree(5)
  attr(tmp, "sorted") <- FALSE
  attr(tmp, "coded") <- FALSE
  GeneticsPed:::checkAttributes(tmp)
  try(GeneticsPed:::checkAttributes(tmp, sorted=TRUE, coded=TRUE))

  ## --- idClass ---
  tmp <- generatePedigree(5)
  tmp$id <- factor(tmp$id)
  class(tmp$id)
  class(tmp$father)
  try(GeneticsPed:::idClass(tmp))

  ## --- idIsNA ---
  tmp <- generatePedigree(2)
  tmp[1, 1] <- NA
  GeneticsPed:::idIsNA(tmp)

  ## --- idNotUnique ---
  tmp <- generatePedigree(2)
  tmp[2, 1] <- 1
  GeneticsPed:::idNotUnique(tmp)

  ## --- idEqualAscendant ---
  tmp <- generatePedigree(2)
  tmp[3, 2] <- tmp[3, 1]
  GeneticsPed:::idEqualAscendant(tmp)

  ## --- ascendantEqualAscendant ---
  tmp <- generatePedigree(2)
  tmp[3, 2] <- tmp[3, 3]
  GeneticsPed:::ascendantEqualAscendant(tmp)

  ## --- ascendantInAscendant ---
  tmp <- generatePedigree(2)
  tmp[3, 2] <- tmp[5, 3]
  GeneticsPed:::ascendantInAscendant(tmp)
  ## Example with multiple parents
  tmp <- data.frame(id=c("A", "B", "C", "D"),
                    father1=c("E", NA, "F", "H"),
                    father2=c("F", "E", "E", "I"),
                    mother=c("G", NA, "H", "E"))
  tmp <- Pedigree(tmp, ascendant=c("father1", "father2", "mother"),
                  ascendantSex=c(1, 1, 2),
                  ascendantLevel=c(1, 1, 1))
  GeneticsPed:::ascendantInAscendant(tmp)

  ## --- unusedLevels ---
  tmp <- generatePedigree(2, colClass="factor")
  tmp[3:4, 2] <- NA
  GeneticsPed:::unusedLevels(tmp)

Example output

Loading required package: MASS

Attaching package:GeneticsPedThe following object is masked frompackage:stats:

    family

   id father mother generation sex
1   1     NA     NA          1   1
2   2     NA     NA          1   1
3   3     NA     NA          1   2
4   4     NA     NA          1   2
5   5     NA     NA          1   2
6   6      2      4          2   1
7   7      2      5          2   1
8   8      2      3          2   2
9   9      2      5          2   2
10 10      1      5          2   2
11 11      7      8          3   2
12 12      7     10          3   2
13 13      6     10          3   1
14 14      6      8          3   2
15 15      7      9          3   2
   id father mother generation sex
1   1     NA     NA          1   1
2   2     NA     NA          1   1
3   3     NA     NA          1   2
4   4     NA     NA          1   2
5   5     NA     NA          1   2
6   6      2      4          2   1
7   7      2      5          2   1
8   8      2      3          2   2
9   9      2      5          2   2
10 10      1      5          2   2
11 11      7      8          3   2
12 12      7     10          3   2
13 13      6     10          3   1
14 14      6      8          3   2
15 15      7      9          3   2
[1] "factor"
[1] "integer"
Error in GeneticsPed:::idClass(tmp) : 
  columnsid,father,mothermust have the same class
$idIsNA
$idIsNA$message
[1] "‘id’ id can not be NA"

$idIsNA$rowIndex
[1] 1


$idNotUnique
$idNotUnique$message
[1] "‘id’ must be unique"

$idNotUnique$rowIndex
[1] 1 2


[1] 0
$fatherEqualsmother
$fatherEqualsmother$message
[1] "‘father’ id can not be equal to id of ‘mother’"

$fatherEqualsmother$rowIndex
[1] 3


$fatherInmother
$fatherInmother$message
[1] "‘father’ id can not be in id of ‘mother’"

$fatherInmother$rowIndex
[1] 3


$`father1|father2Inmother`
$`father1|father2Inmother`$message
[1] "‘father1|father2’ id can not be in id of ‘mother’"

$`father1|father2Inmother`$rowIndex
[1] 1 2 3 4


$unusedLevelsInfather
$unusedLevelsInfather$message
[1] "unused levels in ‘father’"

$unusedLevelsInfather$levels
[1] "1"

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