Skip to contents

Candidates’ selection for a pool of donors

We can also simulate the selection of wait list candidates for a pool of donors, according to a given model (or algorithm). The function donor_recipient_pairs() allow us to compute all possible donor-recipient pairs according to any of the previously described kidney allocation algorithms.

Here an example where we use a pool of 70 donors (donors data frame available in the package) to select from a wait list of 500 transplant candidates (data frame is also available in the package)

# compute all possible donor-recipient pairs for each one of the donors according to ‘lima’ algorithm
all_pairs <- donor_recipient_pairs(df.donors = donors,
                      df.candidates = candidates,
                      df.abs = cabs,
                      algorithm = lima,
                      n = 0,
                      check.validity = FALSE)

# for loop to select 2 available candidates for a pool of donors
used.candidates <- NULL
result <- NULL
for(i in 1: length(all_pairs)){
  tmp <- all_pairs[[i]][!ID %in% used.candidates][1:2,]

  result <- data.table::rbindlist(list(result, tmp))
  used.candidates <- c(used.candidates, tmp$ID)
}

# as a result we have all the selected donor-recipient pairs for a given pool of donors
result
#>       ID bg A1 A2 B1 B2 DR1 DR2 mmA mmB mmDR mmHLA age donor_age dialysis cPRA
#>   1: 436  A 24 24 49 51  15   4   2   1    1     4  66        46       62   96
#>   2:  81  A  2 23 15 49  15   4   1   1    1     3  44        46       91    0
#>   3: 317  O  1 68 51 58  13   9   1   2    2     5  31        55      113    0
#>   4: 112  O  2 29 44 44   4  12   2   2    2     6  58        55      104    0
#>   5: 487  O  2 33 15 27  11   7   2   1    2     5  55        32      103    0
#>  ---                                                                          
#> 136: 234  O  3 29  7 51  11   4   2   1    0     3  54        53       65    0
#> 137: 184  O  2 30 27 58  13   8   1   1    1     3  56        44       68    0
#> 138: 447  O  2 24 15 35  11   7   0   2    1     3  33        44       48   50
#> 139: 388  A  2 24 15 44  13   4   0   0    0     0  53        58       33   14
#> 140:   1  A  2 24 15 44   1   4   0   0    1     1  53        58       59    0
#>         HI     cp SP urgent
#>   1:  TRUE Orange  0      0
#>   2: FALSE Yellow  0      0
#>   3: FALSE Orange  0      0
#>   4: FALSE Orange  0      0
#>   5: FALSE Orange  0      0
#>  ---                       
#> 136: FALSE Yellow  0      0
#> 137: FALSE Yellow  0      0
#> 138: FALSE Yellow  0      0
#> 139: FALSE  Green  0      0
#> 140: FALSE  Green  0      0

Now we can also compute a new column for the estimated 5-year event (mortality or graft failure) probability as described by Molnar et al.1 and available from the application TxScore, with the function txscore():

result[!is.na(ID),][ ,
                     txs := txscore(recipient.age = age,
                                    recipient.dialysis = dialysis,
                                    donor.age = donor_age,
                                    mmHLA_A = mmA,
                                    mmHLA_B = mmB,
                                    mmHLA_DR = mmDR)$prob5y,
                     by = 'ID'][] 
#>       ID bg A1 A2 B1 B2 DR1 DR2 mmA mmB mmDR mmHLA age donor_age dialysis cPRA
#>   1: 436  A 24 24 49 51  15   4   2   1    1     4  66        46       62   96
#>   2:  81  A  2 23 15 49  15   4   1   1    1     3  44        46       91    0
#>   3: 317  O  1 68 51 58  13   9   1   2    2     5  31        55      113    0
#>   4: 112  O  2 29 44 44   4  12   2   2    2     6  58        55      104    0
#>   5: 487  O  2 33 15 27  11   7   2   1    2     5  55        32      103    0
#>  ---                                                                          
#> 136: 234  O  3 29  7 51  11   4   2   1    0     3  54        53       65    0
#> 137: 184  O  2 30 27 58  13   8   1   1    1     3  56        44       68    0
#> 138: 447  O  2 24 15 35  11   7   0   2    1     3  33        44       48   50
#> 139: 388  A  2 24 15 44  13   4   0   0    0     0  53        58       33   14
#> 140:   1  A  2 24 15 44   1   4   0   0    1     1  53        58       59    0
#>         HI     cp SP urgent   txs
#>   1:  TRUE Orange  0      0 66.96
#>   2: FALSE Yellow  0      0 58.43
#>   3: FALSE Orange  0      0 65.77
#>   4: FALSE Orange  0      0 62.42
#>   5: FALSE Orange  0      0 57.87
#>  ---                             
#> 136: FALSE Yellow  0      0 62.45
#> 137: FALSE Yellow  0      0 60.66
#> 138: FALSE Yellow  0      0 56.24
#> 139: FALSE  Green  0      0 48.87
#> 140: FALSE  Green  0      0 55.69

Input data

Input data used with this package’s functions, regarding either candidates or donors information, when provided by the user must have the exact same format as the example data available. Moreover, {simK} package allows to generate synthetic data both for candidates and donors that can be used with {histoc}.