Skip to content

Commit

Permalink
allow assignment with only genus or only species binomial
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanf committed Oct 18, 2023
1 parent 539401b commit c5f5986
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
It also works with a locally cached database.
* `funguild_assign()` now accepts Sintax ("`k:`", "`p:`"...) or Unite ("`k__`,
"`p__`", ...) style taxonomy strings.
* `funguild_assign()` now works in many cases when the *Taxonomy* column
contains only genus or species names. The most complete results will still be
achieved when the whole taxonomy string is included.

# FUNGuildR 0.2.0

Expand Down
5 changes: 1 addition & 4 deletions R/funguildr.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,7 @@ funguild_assign <- function(otu_table, db = get_funguild_db(),
}
assertthat::assert_that(is.data.frame(otu_table),
tax_col %in% colnames(otu_table))
otu_table$taxkey <-
stringr::str_replace_all(otu_table[[tax_col]], "\\b[kpcofgs](:|__)", "") %>%
stringr::str_replace_all("[_ ;,:]", "@") %>%
paste0("@")
otu_table$taxkey <- make_taxkey(otu_table[[tax_col]])
all_taxkey <- unique(otu_table$taxkey) %>% na.omit()
`.` <- taxon <- taxkey <- searchkey <- taxonomicLevel <- NULL # to pass R CMD check
db <- dplyr::mutate(
Expand Down
6 changes: 6 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@ check_is_json <- function(response) {
)
response
}

make_taxkey <- function(x) {
out <- gsub("\\b[kpcofgs](:|__)", "", x)
out <- gsub("[_ ;,:]", "@", out)
paste0("@", out, "@")
}

0 comments on commit c5f5986

Please sign in to comment.