R/simplify_haplotype_names.R

Defines functions simplify_haplotype_names

Documented in simplify_haplotype_names

#' Simplify haplotype names to numbers
#' Will be NA for unknown haplotypes
#' @inheritParams default_params_doc
#' @export
simplify_haplotype_names <- function(haplotype_names) {
  simple_haplotype_names <- rep(NA, length = length(haplotype_names))
  for (i in seq_along(haplotype_names)) {
    haplotype_name <- haplotype_names[i]
    simple_haplotype_name <- NA
    if (haplotype_name %in% bbbq::get_mhc1_haplotypes()) {
      simple_haplotype_name <- which(haplotype_name == bbbq::get_mhc1_haplotypes())
    }
    if (haplotype_name %in% bbbq::get_mhc2_haplotypes()) {
      simple_haplotype_name <- which(haplotype_name == bbbq::get_mhc2_haplotypes())
    }
    simple_haplotype_names[i] <- simple_haplotype_name
  }
  simple_haplotype_names
}
richelbilderbeek/bbbq documentation built on July 27, 2023, 2:15 a.m.