get_resolution()
takes in a string or character vector of HLA alleles, and
returns their resolution as either low, intermediate, or high.
Arguments
- allele
A string or character vector with (an) HLA allele(s).
- extended
When
TRUE
, the returned resolution also contains:for high resolution: the number of fields ("second field", "third field", "fourth field")
for low resolution: whether the allele is a serological/molecular split/broad or associated antigen
Value
A string or character vector of the same length as allele
,
with "low"
, "intermediate"
, or "high"
for each element.
Details
Resolution is defined as follows:
Low: a typing at the allele group level, such as
anything using the serological/antigen nomenclature, e.g
A2
an XX code representing an allele group, e.g.
A*02:XX
Intermediate: any typing with ambiguities, such as
a list using the forward slash notation, e.g.
HLA-A*23:26/HLA-A*23:39
a typing with multiple allele codes, e.g.
A*01:AABJE
High: any typing with more than 2 field codes, e.g.
A*24:09
(minimum)HLA-A*24:02:01:02L
(maximum)
Examples
get_resolution("A2") # low
#> [1] "low"
get_resolution("A2", extended = TRUE) # low - broad
#> [1] "serology - broad"
get_resolution("A*01:AABJE") # intermediate
#> [1] "intermediate"
get_resolution("A*24:09") # high
#> [1] "high"
get_resolution("A*24:09", extended = TRUE) # high - second field
#> [1] "high - second field"
# also works with character vectors, or in a data frame
allele_vec <- c("A2", "A*01:AABJE", "B*42:08")
get_resolution(allele_vec)
#> [1] "low" "intermediate" "high"
tidyr::tibble(alleles = allele_vec) |>
dplyr::mutate(resolution = get_resolution(allele_vec))
#> # A tibble: 3 × 2
#> alleles resolution
#> <chr> <chr>
#> 1 A2 low
#> 2 A*01:AABJE intermediate
#> 3 B*42:08 high