# The HLA_typing_LIS dataset contains a table as might be found in a clinical laboratory
# information system:
print(HLA_typing_LIS)
# The `HLA_columns_to_GLString` function can be used to coerce typing spread across
# multiple columns into a GL string:
library(dplyr)
HLA_typing_LIS %>%
mutate(
GL_string = HLA_columns_to_GLstring(
., # Note that if this function is used inside a `mutate` call "." will have to be
# used as the first argument to extract data from the working data frame.
HLA_typing_columns = mA1Cd.recipient:mDPB12cd.recipient,
prefix_to_remove = "m",
suffix_to_remove = "Cd.recipient"
),
.after = patient
) %>%
select(patient, GL_string)
# Using the base pipe:
HLA_typing_LIS |>
mutate(
GL_string = HLA_columns_to_GLstring(
HLA_typing_LIS, # If using the base pipe, the first argument will have to be
# the working data frame.
HLA_typing_columns = mA1Cd.recipient:mDPB12cd.recipient,
prefix_to_remove = "m",
suffix_to_remove = "Cd.recipient"
),
.after = patient
) |>
select(patient, GL_string)
Run the code above in your browser using DataLab