encodePhenotype

encodePhenotype(
  df,
  susceptible_label = "Susceptible",
  resistant_label = "Resistant"
)

Arguments

df

A tibble with AMR column genome_drug.resistant_phenotype

susceptible_label

Label for "Susceptible" phenotype

resistant_label

Label for "Resistant" phenotype

Value

A list with:

  • df: the input data with AMR phenotype now encoded as integer

  • target: a binarized vector of the encoded AMR phenotypes

Examples

df <- tibble::tibble(
  genome_id = paste0("g", 1:6),
  genome_drug.resistant_phenotype = c(
    "Resistant", "Susceptible", "Resistant",
    "Susceptible", "Resistant", "Susceptible"
  ),
  gene_a = c(1L, 0L, 1L, 0L, 1L, 0L),
  gene_b = c(0L, 1L, 1L, 0L, 0L, 1L)
)
encoded <- encodePhenotype(df)
encoded$target
#> [1] 1 0 1 0 1 0