Skip to content

Commit

Permalink
Merge pull request #56 from waldronlab/bugfix_enforce_minsize
Browse files Browse the repository at this point in the history
fix min.size; apply unique first
  • Loading branch information
lgeistlinger authored Dec 26, 2023
2 parents fdfecee + 5ebac97 commit 71f7750
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 1 addition & 2 deletions R/getSignatures.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ getSignatures <- function(df,
snames <- .makeSigNames(df)
sigs <- .extractSigs(df, tax.id.type, tax.level, exact.tax.level)
names(sigs) <- paste(snames$id, snames$titles, sep = "_")
if (min.size)
sigs <- sigs[lengths(sigs) >= min.size]
sigs <- lapply(sigs, unique)
sigs <- sigs[lengths(sigs) >= min.size]
return(sigs)
}

Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-getSignatures.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ bsdb <- importBugSigDB()

checkSigs <- function(sigs, tax.id.type)
{
sigs <- getSignatures(bsdb)
expect_true(is.list(sigs))
expect_true(is.character(sigs[[1]]))
expect_true(grepl("^bsdb", names(sigs)[1]))
Expand Down Expand Up @@ -56,6 +57,7 @@ test_that("min.size", {
sigs <- getSignatures(bsdb, tax.level = "genus", min.size = 3)
expect_true(all(lengths(sigs) > 2))
expect_false(all(lengths(sigs) > 3))
expect_false(any(lengths(sigs) < 3))
})


0 comments on commit 71f7750

Please sign in to comment.