Skip to contents

Shrink Pedigree object to specified bit size with priority placed on trimming uninformative subjects. The algorithm is useful for getting a Pedigree condensed to a minimally informative size for algorithms or testing that are limited by size of the Pedigree.

If avail or affected are NULL, they are extracted with their corresponding accessors from the Ped object.

Usage

# S4 method for class 'Pedigree'
shrink(obj, avail = NULL, affected = NULL, max_bits = 16)

# S4 method for class 'Ped'
shrink(obj, avail = NULL, affected = NULL, max_bits = 16)

Arguments

obj

A Pedigree or Ped object.

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

max_bits

Optional, the bit size for which to shrink the Pedigree

Value

A list containing the following elements:

  • pedObj: Pedigree object after trimming

  • id_trim: Vector of ids trimmed from Pedigree

  • id_lst: List of ids trimmed by category

  • bit_size: Vector of bit sizes after each trimming step

  • avail: Vector of availability status after trimming

  • pedSizeOriginal: Number of subjects in original Pedigree

  • pedSizeIntermed: Number of subjects after initial trimming

  • pedSizeFinal: Number of subjects after final trimming

Details

Iteratively remove subjects from the Pedigree. The random removal of members was previously controlled by a seed argument, but we remove this, forcing users to control randomness outside the function. First remove uninformative subjects, i.e., unavailable (not genotyped) with no available descendants. Next, available terminal subjects with unknown phenotype if both parents available. Last, iteratively shrinks Pedigrees by preferentially removing individuals (chosen at random if there are multiple of the same status):

  1. Subjects with unknown affected status

  2. Subjects with unaffected affected status

  3. Affected subjects.

Author

Original by Dan Schaid, updated by Jason Sinnwell and Louis Le Nézet

Examples

data(sampleped)
ped1 <- Pedigree(sampleped[sampleped$famid == '1',])
shrink(ped1, max_bits = 12)
#> $pedObj
#> Pedigree object with: 
#> Ped object with 13 individuals and 13 metadata columns:
#>                    id       dadid       momid       sex       famid    steril
#> col_class <character> <character> <character> <ordered> <character> <logical>
#> 1_103           1_103        <NA>        <NA>      male           1      <NA>
#> 1_104           1_104        <NA>        <NA>    female           1      <NA>
#> 1_105           1_105        <NA>        <NA>      male           1      <NA>
#> 1_106           1_106        <NA>        <NA>    female           1      <NA>
#> 1_109           1_109        <NA>        <NA>    female           1      <NA>
#> ...               ...         ...         ...       ...         ...       ...
#> 1_118           1_118       1_105       1_106    female           1      <NA>
#> 1_119           1_119       1_105       1_106      male           1      <NA>
#> 1_124           1_124       1_110       1_109      male           1      <NA>
#> 1_127           1_127       1_114       1_115      male           1      <NA>
#> 1_128           1_128       1_114       1_115      male           1      <NA>
#>              status     avail  affected    useful       kin     isinf
#> col_class <logical> <logical> <logical> <logical> <numeric> <logical>
#> 1_103          <NA>     FALSE      TRUE      <NA>      <NA>      <NA>
#> 1_104          <NA>     FALSE     FALSE      <NA>      <NA>      <NA>
#> 1_105          <NA>     FALSE      <NA>      <NA>      <NA>      <NA>
#> 1_106          <NA>     FALSE      <NA>      <NA>      <NA>      <NA>
#> 1_109          <NA>      TRUE     FALSE      <NA>      <NA>      <NA>
#> ...             ...       ...       ...       ...       ...       ...
#> 1_118          <NA>      TRUE      TRUE      <NA>      <NA>      <NA>
#> 1_119          <NA>      TRUE      TRUE      <NA>      <NA>      <NA>
#> 1_124          <NA>      TRUE      TRUE      <NA>      <NA>      <NA>
#> 1_127          <NA>      TRUE      TRUE      <NA>      <NA>      <NA>
#> 1_128          <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_103                 2             2             0             1         103
#> 1_104                 2             2             0             1         104
#> 1_105                 3             3             0             1         105
#> 1_106                 3             3             0             1         106
#> 1_109                 1             1             0             1         109
#> ...                 ...           ...           ...           ...         ...
#> 1_118                 0             0             0             1         118
#> 1_119                 0             0             0             1         119
#> 1_124                 0             0             0             1         124
#> 1_127                 0             0             0             1         127
#> 1_128                 0             0             0             1         128
#>              fatherId    motherId      gender   affection   available
#> col_class <character> <character> <character> <character> <character>
#> 1_103             135         136           1           1           0
#> 1_104            <NA>        <NA>           2           0           0
#> 1_105            <NA>        <NA>           1        <NA>           0
#> 1_106            <NA>        <NA>           2        <NA>           0
#> 1_109             101         102           2           0           1
#> ...               ...         ...         ...         ...         ...
#> 1_118             105         106           2           1           1
#> 1_119             105         106           1           1           1
#> 1_124             110         109           1           1           1
#> 1_127             114         115           1           1           1
#> 1_128             114         115           1           1           1
#>                   num       error sterilisation vitalStatus affection_mods
#> col_class <character> <character>   <character> <character>    <character>
#> 1_103               2        <NA>          <NA>        <NA>              1
#> 1_104               4        <NA>          <NA>        <NA>              0
#> 1_105               6        <NA>          <NA>        <NA>             NA
#> 1_106               1        <NA>          <NA>        <NA>             NA
#> 1_109               3        <NA>          <NA>        <NA>              0
#> ...               ...         ...           ...         ...            ...
#> 1_118               2        <NA>          <NA>        <NA>              1
#> 1_119               6        <NA>          <NA>        <NA>              1
#> 1_124            <NA>        <NA>          <NA>        <NA>              1
#> 1_127               5        <NA>          <NA>        <NA>              1
#> 1_128               3        <NA>          <NA>        <NA>              1
#>            avail_mods
#> col_class <character>
#> 1_103               0
#> 1_104               0
#> 1_105               0
#> 1_106               0
#> 1_109               1
#> ...               ...
#> 1_118               1
#> 1_119               1
#> 1_124               1
#> 1_127               1
#> 1_128               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>
#> 
#> $id_trim
#>                                                                                 
#> "1_101" "1_102" "1_107" "1_108" "1_111" "1_113" "1_121" "1_122" "1_123" "1_131" 
#>                                                                              id 
#> "1_132" "1_134" "1_139" "1_141" "1_140" "1_130" "1_126" "1_125" "1_129" "1_133" 
#>         
#> "1_116" 
#> 
#> $id_lst
#> $id_lst$unavail
#>  [1] "1_101" "1_102" "1_107" "1_108" "1_111" "1_113" "1_121" "1_122" "1_123"
#> [10] "1_131" "1_132" "1_134" "1_139"
#> 
#> $id_lst$affect
#>                                                      id         
#> "1_141" "1_140" "1_130" "1_126" "1_125" "1_129" "1_133" "1_116" 
#> 
#> 
#> $bit_size
#>  [1] 46 29 27 23 21 19 15 14 13 11
#> 
#> $avail
#>  [1] FALSE FALSE FALSE FALSE  TRUE  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE
#> [13]  TRUE
#> 
#> $pedSizeOriginal
#> [1] 41
#> 
#> $pedSizeIntermed
#> [1] 28
#> 
#> $pedSizeFinal
#> [1] 13
#>