Skip to content

Commit

Permalink
getSignatures: fail when not specifiying tax.level with exact.tax.lev…
Browse files Browse the repository at this point in the history
…el=FALSE
  • Loading branch information
lgeistlinger committed Oct 14, 2024
1 parent 5b35f87 commit b973847
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: bugsigdbr
Version: 1.11.2
Version: 1.11.3
Title: R-side access to published microbial signatures from BugSigDB
Authors@R: c(
person(given = "Ludwig",
Expand Down
8 changes: 7 additions & 1 deletion R/getSignatures.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ getSignatures <- function(df,
tax.id.type = c("ncbi", "metaphlan", "taxname"),
tax.level = "mixed",
exact.tax.level = TRUE,
min.size = 1) {
min.size = 1)
{
stopifnot(is.data.frame(df))
tax.id.type <- match.arg(tax.id.type)

Expand All @@ -41,6 +42,11 @@ getSignatures <- function(df,
paste(TAX.LEVELS, collapse = ", "),
" }")

is.spec.tax.level <- length(tax.level) == 1 && tax.level != "mixed"
if(!exact.tax.level && !is.spec.tax.level)
stop("Using exact.tax.level = FALSE requires ",
"to select a specific taxonomic level")

# rm NA signatures
nna <- !is.na(df[["MetaPhlAn taxon names"]])
df <- df[nna,]
Expand Down

0 comments on commit b973847

Please sign in to comment.