Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add function `cromulent_replen()` - add message handlers - add tests - update documentation (nancycats is buggy)
- Loading branch information
Showing
9 changed files
with
130 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
context("repeat length handling") | ||
|
||
data("nancycats", package = "adegenet") | ||
names(alleles(nancycats)) <- locNames(nancycats) | ||
nanrep <- rep(2, 9) | ||
named_nanrep <- setNames(nanrep, locNames(nancycats)) | ||
nantest <- test_replen(nancycats, nanrep) | ||
nanfix <- fix_replen(nancycats, nanrep) | ||
named_nantest <- test_replen(nancycats, named_nanrep) | ||
named_nanfix <- fix_replen(nancycats, named_nanrep) | ||
test_that("test_replen and fix_replen works as expected for conguent vectors", { | ||
expect_equal(sum(nantest), 5) | ||
expect_identical(nantest, named_nantest) | ||
expect_identical(nanfix, named_nanfix) | ||
expect_true(all(floor(nanfix)[!nantest] == 1)) | ||
}) | ||
|
||
test_that("test_replen and fix_replen work for larger length vectors", { | ||
nanrep10 <- c(nanrep, 5) | ||
named_nanrep11 <- c(named_nanrep, foo = 5, bar = 5) | ||
bad_named_nanrep11 <- named_nanrep11 | ||
names(bad_named_nanrep11)[1] <- "bob" | ||
expect_error(test_replen(nancycats, nanrep10), "length of repeats \\(10\\)") | ||
expect_error(fix_replen(nancycats, nanrep10), "length of repeats \\(10\\)") | ||
expect_warning(expect_error(test_replen(nancycats, bad_named_nanrep11), "repeat lengths... fca23"), "bob") | ||
expect_warning(nts <- test_replen(nancycats, named_nanrep11), "foo, bar") | ||
expect_warning(nfx <- fix_replen(nancycats, named_nanrep11), "foo, bar") | ||
expect_identical(nts, nantest) | ||
expect_identical(nfx, nanfix) | ||
}) | ||
|
||
test_that("test_replen and fix_replen will not work for short vectors", { | ||
expect_error(test_replen(nancycats, nanrep[1:7]), "length of repeats \\(7\\)") | ||
expect_error(test_replen(nancycats, named_nanrep[1:7]), "length of repeats \\(7\\)") | ||
}) | ||
|
||
test_that("fix_replen throws errors for weird replens", { | ||
skip_on_cran() | ||
data(partial_clone) | ||
expect_warning(fix_replen(partial_clone, rep(10, 10)), paste(locNames(partial_clone), collapse = ", ")) | ||
expect_warning(fix_replen(partial_clone, rep(10, 10), fix_some = FALSE), "Original repeat lengths are being returned") | ||
expect_warning(fix_replen(partial_clone, rep(2, 10)), "The repeat lengths for Locus_2, Locus_7, Locus_9 are not consistent.") | ||
expect_warning(fix_replen(partial_clone, rep(2, 10)), "Repeat lengths with some modification are being returned: Locus_3") | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters