Skip to content

added gsub to remove <NA values which cause glue errors - #114

Open
jhawkey wants to merge 1 commit into
mainfrom
fix-import-pheno-glue-error
Open

added gsub to remove <NA values which cause glue errors#114
jhawkey wants to merge 1 commit into
mainfrom
fix-import-pheno-glue-error

Conversation

@jhawkey

@jhawkey jhawkey commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

I recently downloaded all AST data from the NCBI browser.

When I tried to import using this command

import_pheno("data/NCBI_asts_15-07-2026.tsv.gz", format="ncbi")

I got this error:

Error in `mutate()`:
ℹ In argument: `mic = as.mic(mic)`.
Caused by error in `glue()`:
! Expecting 'FCkNXbE-413>'

This was occurring here at the final step in this chunk:

AMRgen/R/import_pheno.R

Lines 533 to 542 in bbeac15

if ("MIC (mg/L)" %in% colnames(ast)) {
if ("Measurement sign" %in% colnames(ast)) {
ast <- ast %>%
mutate(mic = paste0(`Measurement sign`, `MIC (mg/L)`)) %>%
mutate(mic = gsub("==", "", mic))
} else {
ast <- ast %>% mutate(mic = `MIC (mg/L)`)
warning("Expected column 'Measurement sign' not found in input, be careful interpreting MIC")
}
ast <- ast %>% mutate(mic = as.mic(mic))

Because the function concatenates the measurement sign with the MIC, it was in some instances creating values that looked like <NA. This causes the weird error being thrown by glue(), which creates the warning message telling users what mic values couldn't be converted.

Have added an extra gsub command that turns "<NA" into simply "NA", so that the import can complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant