Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mschemmel committed Jun 30, 2024
1 parent 2417b07 commit bd5105c
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 10 deletions.
20 changes: 20 additions & 0 deletions man/assert.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/detect_reference.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions man/in_range.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/prepare.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions tests/testthat/test_backend.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,14 @@ test_that("prepare() works", {
df$efficiency <- 40
expect_equal(unique(prepare(df)$E), 1.4)
})

test_that("conflate works()", {
run <- get_reference_group(qpcR(dat, hkg = "HKG", reference = "control", groups = "dpi", aggregate = FALSE))
control_groups <- aggregate(rexpr ~ gene + dpi, data = run, FUN = mean)
expect_equal(unique(control_groups$rexpr), c(1, 1))

run2 <- get_reference_group(qpcR(dat, hkg = c("HKG", "HKG2"), reference = "control", groups = "dpi", aggregate = FALSE))
control_groups2 <- aggregate(rexpr ~ gene + dpi, data = run2, FUN = mean)
expect_equal(unique(control_groups2$rexpr), c(1, 1))

})
13 changes: 5 additions & 8 deletions tests/testthat/test_qpcr.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
dat <- read.table("example2.tsv", sep = "\t", head = TRUE)

test_that("qpcR() works", {
run <- get_reference_group(qpcR(dat, hkg = "HKG", reference = "control", groups = "dpi", aggregate = FALSE))
control_groups <- aggregate(rexpr ~ gene + dpi, data = run, FUN = mean)
expect_equal(unique(control_groups$rexpr), c(1, 1))

run2 <- get_reference_group(qpcR(dat, hkg = c("HKG", "HKG2"), reference = "control", groups = "dpi", aggregate = FALSE))
control_groups2 <- aggregate(rexpr ~ gene + dpi, data = run2, FUN = mean)
expect_equal(unique(control_groups2$rexpr), c(1, 1))

expect_no_error(qpcR(dat, hkg = "HKG", groups = "dpi", outlier.method = "interquartile"))
expect_no_error(qpcR(dat, hkg = "HKG", groups = "dpi", outlier.method = "z-score"))
expect_no_error(qpcR(dat, hkg = "HKG", groups = "dpi", outlier.method = "hampel"))
Expand All @@ -18,6 +10,11 @@ test_that("qpcR() works", {
expect_no_error(qpcR(dat, hkg = c("HKG", "HKG2"), groups = "dpi", outlier.method = "hampel"))
})

test_that("expression values of reference group equals 1", {
res <- qpcR(dat, hkg = "HKG", reference = "control", groups = "dpi", aggregate = TRUE)
expect_equal(unique(res[res == "control", ]$rexpr.mean, ), c(1, 1))
})

test_that("output equals data.frame", {
expect_type(qpcR(dat, hkg = "HKG", groups = "dpi"), "list")
expect_type(qpcR(dat, hkg = c("HKG", "HKG2"), groups = "dpi"), "list")
Expand Down

0 comments on commit bd5105c

Please sign in to comment.