Skip to contents

A pedigree is a ensemble of individuals linked to each other into a family tree. A Pedigree object store the informations of the individuals and the special relationships between them. It also permit to store the informations needed to plot the pedigree (i.e. scales and hints).

Constructor :

Main constructor of the package. This constructor help to create a Pedigree object from different data.frame or a set of vectors.

If any errors are found in the data, the function will return the data.frame with the errors of the Ped object and the Rel object.

Usage

Pedigree(obj, ...)

# S4 method for class 'character_OR_integer'
Pedigree(
  obj,
  dadid,
  momid,
  sex,
  famid = NA,
  avail = NULL,
  affected = NULL,
  status = NULL,
  steril = NULL,
  rel_df = NULL,
  missid = NA_character_,
  col_aff = "affection",
  normalize = TRUE,
  ...
)

# S4 method for class 'data.frame'
Pedigree(
  obj = data.frame(indId = character(), fatherId = character(), motherId = character(),
    gender = numeric(), family = character(), available = numeric(), vitalStatus =
    numeric(), affection = numeric(), sterilisation = numeric()),
  rel_df = data.frame(id1 = character(), id2 = character(), code = numeric(), famid =
    character()),
  cols_ren_ped = list(indId = "id", fatherId = "dadid", motherId = "momid", family =
    "famid", gender = "sex", sterilisation = "steril", affection = "affected", available
    = "avail", vitalStatus = "status"),
  cols_ren_rel = list(id1 = "indId1", id2 = "indId2", famid = "family"),
  hints = list(horder = NULL, spouse = NULL),
  normalize = TRUE,
  missid = NA_character_,
  col_aff = "affection",
  na_strings = c("NA", "N/A", "None", "none", "null", "NULL"),
  ...
)

Arguments

obj

A vector of the individuals identifiers or a data.frame with the individuals informations. See Ped() for more informations.

...

Arguments passed on to generate_colors

dadid

A vector containing for each subject, the identifiers of the biologicals fathers.

momid

A vector containing for each subject, the identifiers of the biologicals mothers.

sex

A character, factor or numeric vector corresponding to the gender of the individuals. This will be transformed to an ordered factor with the following levels: male < female < unknown < terminated The following values are recognized:

  • character() or factor() : "f", "m", "woman", "man", "male", "female", "unknown", "terminated"

  • numeric() : 1 = "male", 2 = "female", 3 = "unknown", 4 = "terminated"

famid

A character vector with the family identifiers of the individuals. If provide, will be aggregated to the individuals identifiers separated by an underscore.

avail

A logical vector with the availability status of the individuals (i.e. FALSE = not available, TRUE = available, NA = unknown).

affected

A logical vector with the affection status of the individuals (i.e. FALSE = unaffected, TRUE = affected, NA = unknown). Can also be a data.frame with the same length as obj. If it is a matrix, it will be converted to a data.frame and the columns will be named after the col_aff argument.

status

A logical vector with the affection status of the individuals (i.e. FALSE = alive, TRUE = dead, NA = unknown).

steril

A logical vector with the sterilisation status of the individuals (i.e. FALSE = not sterilised, TRUE = sterilised, NA = unknown).

rel_df

A data.frame with the special relationships between individuals. See Rel() for more informations. The minimum columns required are id1, id2 and code. The famid column can also be used to specify the family of the individuals. If a matrix is given, the columns needs to be ordered as id1, id2, code and famid. The code values are:

  • 1 = Monozygotic twin

  • 2 = Dizygotic twin

  • 3 = twin of unknown zygosity

  • 4 = Spouse

The value relation code recognized by the function are the one defined by the rel_code_to_factor() function.

missid

A character vector with the missing values identifiers. All the id, dadid and momid corresponding to those values will be set to NA_character_.

col_aff

A character vector with the name of the column to be used for the affection status.

normalize

A logical to know if the data should be normalised.

cols_ren_ped

A named list with the columns to rename for the pedigree dataframe. This is useful if you want to use a dataframe with different column names. The names of the list should be the new column names and the values should be the old column names. The default values are to be used with normalize = TRUE.

cols_ren_rel

A named list with the columns to rename for the relationship matrix. This is useful if you want to use a dataframe with different column names. The names of the list should be the new column names and the values should be the old column names.

hints

A Hints object or a named list containing horder and spouse.

na_strings

Vector of strings to be considered as NA values.

Value

A Pedigree object.

Details

If the normalization is set to TRUE, then the data will be standardized using the function norm_ped() and norm_rel().

If a data.frame is given, the columns names needed will depend if the normalization is selected or not. If the normalization is selected, the columns names needed are as follow and if not the columns names needed are in parenthesis:

  • indID: the individual identifier (id)

  • fatherId: the identifier of the biological father (dadid)

  • motherId: the identifier of the biological mother (momid)

  • gender: the sex of the individual (sex)

  • family: the family identifier of the individual (famid)

  • sterilisation: the sterilisation status of the individual (steril)

  • available: the availability status of the individual (avail)

  • vitalStatus: the death status of the individual (status)

  • affection: the affection status of the individual (affected)

  • ...: other columns that will be stored in the elementMetadata slot

The minimum columns required are :

  • indID / id

  • fatherId / dadid

  • motherId / momid

  • gender / sex

The family / famid column can also be used to specify the family of the individuals and will be merge to the indId / id field separated by an underscore. The columns sterilisation, available, vitalStatus, affection will be transformed with the vect_to_binary() function when the normalisation is selected. If you do not use the normalisation, the columns will be checked to be 0 or 1.

If affected is a data.frame, col_aff will be overwritten by the column names of the data.frame.

Slots

ped

A Ped object for the identity informations. See Ped() for more informations.

rel

A Rel object for the special relationships. See Rel() for more informations.

scales

A Scales object for the filling and bordering colors used in the plot. See Scales() for more informations.

hints

A Hints object for the ordering of the individuals in the plot. See Hints() for more informations.

Accessors

  • ped(x, slot) : Get the value of a specific slot of the Ped object

  • ped(x) : Get the Ped object

  • ped(x, slot) <- value : Set the value of a specific slot of the Ped object Wrapper of slot(ped(x)) <- value

  • ped(x) <- value : Set the Ped object

  • mcols(x) : Get the metadata of a Pedigree object. This function is a wrapper around mcols(ped(x)).

  • mcols(x) <- value : Set the metadata of a Pedigree object. This function is a wrapper around mcols(ped(x)) <- value.

  • rel(x, slot) : Get the value of a specific slot of the Rel object

  • rel(x) : Get the Rel object

  • rel(x, slot) <- value : Set the value of a specific slot of the Rel object Wrapper of slot(rel(x)) <- value

  • rel(x) <- value : Set the Rel object

  • scales(x) : Get the Scales object

  • scales(x) <- value : Set the Scales object

  • fill(x) : Get the fill data.frame from the Scales object. Wrapper of fill(scales(x))

  • fill(x) <- value : Set the fill data.frame from the Scales object. Wrapper of fill(scales(x)) <- value

  • border(x) : Get the border data.frame from the Scales object. Wrapper of border(scales(x))

  • border(x) <- value : Set the border data.frame from the Scales object. Wrapper of border(scales(x)) <- value

  • hints(x) : Get the Hints object

  • hints(x) <- value : Set the Hints object

  • horder(x) : Get the horder vector from the Hints object. Wrapper of horder(hints(x))

  • horder(x) <- value : Set the horder vector from the Hints object. Wrapper of horder(hints(x)) <- value

  • spouse(x) : Get the spouse data.frame from the Hints object. Wrapper of spouse(hints(x)).

  • spouse(x) <- value : Set the spouse data.frame from the Hints object. Wrapper of spouse(hints(x)) <- value.

Generics

  • length(x): Get the length of a Pedigree object. Wrapper of length(ped(x)).

  • show(x): Print the information of the Ped and Rel object inside the Pedigree object.

  • summary(x): Compute the summary of the Ped and Rel object inside the Pedigree object.

  • as.list(x): Convert a Pedigree object to a list

  • subset(x, i, keep = TRUE): Subset a Pedigree object based on the individuals identifiers given.

    • i : A vector of individuals identifiers to keep.

    • del_parents : A logical value indicating if the parents of the individuals should be deleted.

    • keep : A logical value indicating if the individuals should be kept or deleted.

  • x[i, del_parents, keep]: Subset a Pedigree object based on the individuals identifiers given.

Examples


Pedigree(
    obj = c("1", "2", "3", "4", "5", "6"),
    dadid = c("4", "4", "6", "0", "0", "0"),
    momid = c("5", "5", "5", "0", "0", "0"),
    sex = c(1, 2, 3, 1, 2, 1),
    avail = c(0, 1, 0, 1, 0, 1),
    affected = matrix(c(
        0, 1, 0, 1, 0, 1,
        1, 1, 1, 1, 1, 1
    ), ncol = 2),
    col_aff = c("aff1", "aff2"),
    missid = "0",
    rel_df = matrix(c(
        "1", "2", 2
    ), ncol = 3, byrow = TRUE),
)
#> Pedigree object with: 
#> Ped object with 6 individuals and 15 metadata columns:
#>                    id       dadid       momid       sex       famid    steril
#> col_class <character> <character> <character> <ordered> <character> <logical>
#> 1                   1           4           5      male        <NA>      <NA>
#> 2                   2           4           5    female        <NA>      <NA>
#> 3                   3           6           5   unknown        <NA>      <NA>
#> 4                   4        <NA>        <NA>      male        <NA>      <NA>
#> 5                   5        <NA>        <NA>    female        <NA>      <NA>
#> 6                   6        <NA>        <NA>      male        <NA>      <NA>
#>              status     avail  affected    useful       kin     isinf
#> col_class <logical> <logical> <logical> <logical> <numeric> <logical>
#> 1              <NA>     FALSE      TRUE      <NA>      <NA>      <NA>
#> 2              <NA>      TRUE      TRUE      <NA>      <NA>      <NA>
#> 3              <NA>     FALSE      TRUE      <NA>      <NA>      <NA>
#> 4              <NA>      TRUE      TRUE      <NA>      <NA>      <NA>
#> 5              <NA>     FALSE      TRUE      <NA>      <NA>      <NA>
#> 6              <NA>      TRUE      TRUE      <NA>      <NA>      <NA>
#>           num_child_tot num_child_dir num_child_ind |      family       indId
#> col_class     <numeric>     <numeric>     <numeric>   <character> <character>
#> 1                     0             0             0             0           1
#> 2                     0             0             0             0           2
#> 3                     0             0             0             0           3
#> 4                     3             2             1             0           4
#> 5                     3             3             0             0           5
#> 6                     3             1             2             0           6
#>              fatherId    motherId      gender          V1          V2
#> col_class <character> <character> <character> <character> <character>
#> 1                   4           5           1           0           1
#> 2                   4           5           2           1           1
#> 3                   6           5           3           0           1
#> 4                   0           0           1           1           1
#> 5                   0           0           2           0           1
#> 6                   0           0           1           1           1
#>             available       error sterilisation vitalStatus   affection
#> col_class <character> <character>   <character> <character> <character>
#> 1                   0        <NA>          <NA>        <NA>        <NA>
#> 2                   1        <NA>          <NA>        <NA>        <NA>
#> 3                   0        <NA>          <NA>        <NA>        <NA>
#> 4                   1        <NA>          <NA>        <NA>        <NA>
#> 5                   0        <NA>          <NA>        <NA>        <NA>
#> 6                   1        <NA>          <NA>        <NA>        <NA>
#>               V1_mods  avail_mods     V2_mods
#> col_class <character> <character> <character>
#> 1                   0           0           1
#> 2                   1           1           1
#> 3                   0           0           1
#> 4                   1           1           1
#> 5                   0           0           1
#> 6                   1           1           1
#> Rel object with 1 relationshipwith 0 MZ twin, 1 DZ twin, 0 UZ twin, 0 Spouse:
#>           id1         id2                     code       famid
#>   <character> <character> <c("ordered", "factor")> <character>
#> 1           1           2                  DZ twin        <NA>

data(sampleped)
Pedigree(sampleped)
#> Pedigree object with: 
#> Ped object with 55 individuals and 13 metadata columns:
#>                    id       dadid       momid       sex       famid    steril
#> col_class <character> <character> <character> <ordered> <character> <logical>
#> 1_101           1_101        <NA>        <NA>      male           1      <NA>
#> 1_102           1_102        <NA>        <NA>    female           1      <NA>
#> 1_103           1_103       1_135       1_136      male           1      <NA>
#> 1_104           1_104        <NA>        <NA>    female           1      <NA>
#> 1_105           1_105        <NA>        <NA>      male           1      <NA>
#> ...               ...         ...         ...       ...         ...       ...
#> 2_210           2_210       2_203       2_204      male           2      <NA>
#> 2_211           2_211       2_203       2_204      male           2      <NA>
#> 2_212           2_212       2_209       2_208    female           2      <NA>
#> 2_213           2_213       2_209       2_208      male           2      <NA>
#> 2_214           2_214       2_209       2_208      male           2      <NA>
#>              status     avail  affected    useful       kin     isinf
#> col_class <logical> <logical> <logical> <logical> <numeric> <logical>
#> 1_101          <NA>     FALSE     FALSE      <NA>      <NA>      <NA>
#> 1_102          <NA>     FALSE      TRUE      <NA>      <NA>      <NA>
#> 1_103          <NA>     FALSE      TRUE      <NA>      <NA>      <NA>
#> 1_104          <NA>     FALSE     FALSE      <NA>      <NA>      <NA>
#> 1_105          <NA>     FALSE      <NA>      <NA>      <NA>      <NA>
#> ...             ...       ...       ...       ...       ...       ...
#> 2_210          <NA>     FALSE     FALSE      <NA>      <NA>      <NA>
#> 2_211          <NA>      TRUE     FALSE      <NA>      <NA>      <NA>
#> 2_212          <NA>      TRUE     FALSE      <NA>      <NA>      <NA>
#> 2_213          <NA>     FALSE     FALSE      <NA>      <NA>      <NA>
#> 2_214          <NA>      TRUE      TRUE      <NA>      <NA>      <NA>
#>           num_child_tot num_child_dir num_child_ind |      family       indId
#> col_class     <numeric>     <numeric>     <numeric>   <character> <character>
#> 1_101                 1             1             0             1         101
#> 1_102                 1             1             0             1         102
#> 1_103                 4             4             0             1         103
#> 1_104                 4             4             0             1         104
#> 1_105                 4             4             0             1         105
#> ...                 ...           ...           ...           ...         ...
#> 2_210                 0             0             0             2         210
#> 2_211                 0             0             0             2         211
#> 2_212                 0             0             0             2         212
#> 2_213                 0             0             0             2         213
#> 2_214                 0             0             0             2         214
#>              fatherId    motherId      gender   affection   available
#> col_class <character> <character> <character> <character> <character>
#> 1_101            <NA>        <NA>           1           0           0
#> 1_102            <NA>        <NA>           2           1           0
#> 1_103             135         136           1           1           0
#> 1_104            <NA>        <NA>           2           0           0
#> 1_105            <NA>        <NA>           1        <NA>           0
#> ...               ...         ...         ...         ...         ...
#> 2_210             203         204           1           0           0
#> 2_211             203         204           1           0           1
#> 2_212             209         208           2           0           1
#> 2_213             209         208           1           0           0
#> 2_214             209         208           1           1           1
#>                   num       error sterilisation vitalStatus affection_mods
#> col_class <character> <character>   <character> <character>    <character>
#> 1_101               2        <NA>          <NA>        <NA>              0
#> 1_102               3        <NA>          <NA>        <NA>              1
#> 1_103               2        <NA>          <NA>        <NA>              1
#> 1_104               4        <NA>          <NA>        <NA>              0
#> 1_105               6        <NA>          <NA>        <NA>             NA
#> ...               ...         ...           ...         ...            ...
#> 2_210               2        <NA>          <NA>        <NA>              0
#> 2_211               1        <NA>          <NA>        <NA>              0
#> 2_212               3        <NA>          <NA>        <NA>              0
#> 2_213               2        <NA>          <NA>        <NA>              0
#> 2_214               0        <NA>          <NA>        <NA>              1
#>            avail_mods
#> col_class <character>
#> 1_101               0
#> 1_102               0
#> 1_103               0
#> 1_104               0
#> 1_105               0
#> ...               ...
#> 2_210               0
#> 2_211               1
#> 2_212               1
#> 2_213               0
#> 2_214               1
#> Rel object with 0 relationshipswith 0 MZ twin, 0 DZ twin, 0 UZ twin, 0 Spouse:
#>          id1         id2                     code       famid
#>  <character> <character> <c("ordered", "factor")> <character>