Skip to contents

Donors dataset.

We can build from scratch a data frame with a pool of donors using functions from {simK} and defining it’s arguments as we pleased.

The minimum caracteristcs for potential deseaced donors are: blood group, HLA typing and age. So, we start with HLA typing and defining pool size (n) and it’s origin:

donors <- hla_sample(n = 100, replace = TRUE, origin = 'API')
#> New names:
#>  `api` -> `api...4`
#>  `afa` -> `afa...5`
#>  `cau` -> `cau...6`
#>  `his` -> `his...7`
#>  `api` -> `api...11`
#>  `afa` -> `afa...12`
#>  `cau` -> `cau...13`
#>  `his` -> `his...14`

# here we create a column with an unique identifier:
donors$ID <- paste0('D', rownames(donors))

donors
#> # A tibble: 100 × 7
#>    A1    A2    B1    B2    DR1   DR2   ID   
#>    <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#>  1 2     11    75    62    9     12    D1   
#>  2 2     1     62    51    4     10    D2   
#>  3 33    24    51    55    1     15    D3   
#>  4 24    2     75    75    1     12    D4   
#>  5 1     11    51    52    4     15    D5   
#>  6 24    11    13    51    12    14    D6   
#>  7 31    24    48    13    9     7     D7   
#>  8 11    24    13    35    15    14    D8   
#>  9 11    11    48    51    11    14    D9   
#> 10 2     24    38    46    16    8     D10  
#> # ℹ 90 more rows

A column with donors blood group can be added with function abo(), we just have to give donors pool size and a vector with ABO genotypic frequencies (probs):

donors$bg <- abo(n = nrow(donors), probs = c(0.46, 0.03, 0.08, 0.43))

donors
#> # A tibble: 100 × 8
#>    A1    A2    B1    B2    DR1   DR2   ID    bg   
#>    <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#>  1 2     11    75    62    9     12    D1    A    
#>  2 2     1     62    51    4     10    D2    O    
#>  3 33    24    51    55    1     15    D3    A    
#>  4 24    2     75    75    1     12    D4    O    
#>  5 1     11    51    52    4     15    D5    B    
#>  6 24    11    13    51    12    14    D6    A    
#>  7 31    24    48    13    9     7     D7    O    
#>  8 11    24    13    35    15    14    D8    B    
#>  9 11    11    48    51    11    14    D9    O    
#> 10 2     24    38    46    16    8     D10   A    
#> # ℹ 90 more rows

Vector on probs must be corresponde to A, AB, B and O probabilities (in that order).

And now we just have to add a vector with donors’ age with function ages():

donors$age <- ages(n = nrow(donors), lower = 18, upper = 80, mean = 55, sd = 25)

# and we can order 
donors |> dplyr::select(ID, bg, A1, A2, B1, B2, DR1, DR2, age)
#> # A tibble: 100 × 9
#>    ID    bg    A1    A2    B1    B2    DR1   DR2     age
#>    <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <dbl>
#>  1 D1    A     2     11    75    62    9     12       41
#>  2 D2    O     2     1     62    51    4     10       49
#>  3 D3    A     33    24    51    55    1     15       57
#>  4 D4    O     24    2     75    75    1     12       58
#>  5 D5    B     1     11    51    52    4     15       67
#>  6 D6    A     24    11    13    51    12    14       23
#>  7 D7    O     31    24    48    13    9     7        38
#>  8 D8    B     11    24    13    35    15    14       44
#>  9 D9    O     11    11    48    51    11    14       64
#> 10 D10   A     2     24    38    46    16    8        65
#> # ℹ 90 more rows