Learn R Programming

immunogenetr (version 0.3.0)

HLA_prefix_add: HLA_prefix_add

Description

This function adds a specified prefix to the beginning of each HLA type, and works on a single allele or all alleles in a GL string. Useful for adding HLA or gene prefixes.

Usage

HLA_prefix_add(data, prefix = "HLA-")

Value

A vector with the specified prefix added to the values.

Arguments

data

A string with a single HLA allele, a GL string of HLA alleles, or a character vector containing either of the previous.

prefix

A character string to be added as a prefix to the alleles. Default is "HLA-".

Examples

Run this code
# The HLA_typing_LIS dataset contains a table as might be found in a clinical
# laboratory information system:
print(HLA_typing_LIS)

# The `HLA_prefix_add` function can be used to add the correct HLA prefixes to the table:
library(dplyr)
HLA_typing_LIS %>% mutate(
  across(
    mA1Cd.recipient:mA2Cd.recipient,
    ~ HLA_prefix_add(., "HLA-A*")
  )
)

Run the code above in your browser using DataLab