diff --git a/man/assert.Rd b/man/assert.Rd new file mode 100644 index 0000000..bb5f212 --- /dev/null +++ b/man/assert.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/helper.r +\name{assert} +\alias{assert} +\title{Simple function to assert given conditions} +\usage{ +assert(statement, err_message = NULL) +} +\arguments{ +\item{statement}{vector of comparison to proof} + +\item{err_message}{string of error message when not all comparison are TRUE} +} +\value{ +character string used as error message or nothing if all TRUE +} +\description{ +Simple function to assert given conditions +} +\keyword{internal} diff --git a/man/detect_reference.Rd b/man/detect_reference.Rd index fb5de45..4a0b7d8 100644 --- a/man/detect_reference.Rd +++ b/man/detect_reference.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/helper.r +% Please edit documentation in R/backend.r \name{detect_reference} \alias{detect_reference} \title{Detect variable of input data used as 'reference'} diff --git a/man/in_range.Rd b/man/in_range.Rd new file mode 100644 index 0000000..fc78115 --- /dev/null +++ b/man/in_range.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/helper.r +\name{in_range} +\alias{in_range} +\title{Check if value(s) is in specific range} +\usage{ +in_range(x, min_, max_) +} +\arguments{ +\item{x}{single value or vector to test} + +\item{min_}{minimal allowed value} + +\item{max_}{maximal allowed value} +} +\value{ +boolean value of all values are in range +} +\description{ +Check if value(s) is in specific range +} +\keyword{internal} diff --git a/man/prepare.Rd b/man/prepare.Rd index 16cbfee..5c11fae 100644 --- a/man/prepare.Rd +++ b/man/prepare.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/helper.r +% Please edit documentation in R/backend.r \name{prepare} \alias{prepare} \title{Prepare input data} diff --git a/tests/testthat/test_backend.R b/tests/testthat/test_backend.R index 60678b4..7b00b2c 100644 --- a/tests/testthat/test_backend.R +++ b/tests/testthat/test_backend.R @@ -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)) + +}) \ No newline at end of file diff --git a/tests/testthat/test_qpcr.R b/tests/testthat/test_qpcr.R index 3b1f894..a1c256c 100644 --- a/tests/testthat/test_qpcr.R +++ b/tests/testthat/test_qpcr.R @@ -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")) @@ -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")