check {GeneticsPed} | R Documentation

## Check consistency of data in pedigree

### Description

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

### Usage

    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:

- idClass: all ids must have the same class

- idIsNA: individual can not be `NA`

- idNotUnique: individual must be unique

- idEqualAscendant: individual can not be equal to its ascendant

- ascendantEqualAscendant: ascendant can not be equal to another ascendant

- ascendantInAscendant: ascendant can not appear again as asescendant of other sex i.e. father can not be a mother to someone else

- unusedLevels: in case factors are used for id presentation, there might be unused levels for some ids - some functions rely on number of levels and a check is provided for this

`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

      ## 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)

[Package GeneticsPed version 1.56.0 Index]