Skip to contents

Construct a family identifier from pedigree information

Usage

# S4 method for class 'character'
make_famid(obj, dadid, momid)

# S4 method for class 'Pedigree'
make_famid(obj)

Arguments

obj

A character vector with the id of the individuals or a data.frame with all the informations in corresponding columns.

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.

Value

When used with a character vector

An integer vector giving family groupings

When used with a Pedigree object

An updated Pedigree object with the family id added and with all ids updated

Details

Create a vector of length n, giving the family 'tree' number of each subject. If the Pedigree is totally connected, then everyone will end up in tree 1, otherwise the tree numbers represent the disconnected subfamilies. Singleton subjects give a zero for family number.

See also

Examples


make_famid(
    c("A", "B", "C", "D", "E", "F"),
    c("C", "D", "0", "0", "0", "0"),
    c("E", "E", "0", "0", "0", "0")
)
#> [1] "1" "1" "1" "1" "1" NA 

data(sampleped)
ped1 <- Pedigree(sampleped[,-1])
make_famid(ped1)
#> 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 |       indId    fatherId
#> col_class     <numeric>     <numeric>     <numeric>   <character> <character>
#> 1_101                 1             1             0           101        <NA>
#> 1_102                 1             1             0           102        <NA>
#> 1_103                 4             4             0           103         135
#> 1_104                 4             4             0           104        <NA>
#> 1_105                 4             4             0           105        <NA>
#> ...                 ...           ...           ...           ...         ...
#> 2_210                 0             0             0           210         203
#> 2_211                 0             0             0           211         203
#> 2_212                 0             0             0           212         209
#> 2_213                 0             0             0           213         209
#> 2_214                 0             0             0           214         209
#>              motherId      gender   affection   available         num
#> col_class <character> <character> <character> <character> <character>
#> 1_101            <NA>           1           0           0           2
#> 1_102            <NA>           2           1           0           3
#> 1_103             136           1           1           0           2
#> 1_104            <NA>           2           0           0           4
#> 1_105            <NA>           1        <NA>           0           6
#> ...               ...         ...         ...         ...         ...
#> 2_210             204           1           0           0           2
#> 2_211             204           1           0           1           1
#> 2_212             208           2           0           1           3
#> 2_213             208           1           0           0           2
#> 2_214             208           1           1           1           0
#>                 error      family sterilisation vitalStatus affection_mods
#> col_class <character> <character>   <character> <character>    <character>
#> 1_101            <NA>        <NA>          <NA>        <NA>              0
#> 1_102            <NA>        <NA>          <NA>        <NA>              1
#> 1_103            <NA>        <NA>          <NA>        <NA>              1
#> 1_104            <NA>        <NA>          <NA>        <NA>              0
#> 1_105            <NA>        <NA>          <NA>        <NA>             NA
#> ...               ...         ...           ...         ...            ...
#> 2_210            <NA>        <NA>          <NA>        <NA>              0
#> 2_211            <NA>        <NA>          <NA>        <NA>              0
#> 2_212            <NA>        <NA>          <NA>        <NA>              0
#> 2_213            <NA>        <NA>          <NA>        <NA>              0
#> 2_214            <NA>        <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>