Skip to content

Commit

Permalink
Merge branch 'issue-16' into develop (close #16)
Browse files Browse the repository at this point in the history
* issue-16:
  Increment version number to 1.0.0.9002
  Updated NEWS.md (#16)
  Adjusted unit tests affected by #16
  Defaulting to new agreement regarding #16
  • Loading branch information
wleoncio committed Sep 18, 2024
2 parents 2852721 + ec1c0cc commit 2b1da05
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: permChacko
Title: Chacko Test for Order-Restriction with Permutation
Version: 1.0.0.9001
Version: 1.0.0.9002
Date: 2024-04-17
Authors@R:
c(
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* Improved validation
* Optimized `chackoStatistic()`
* Revised calculation of unique values in `chackoStatistic()` ([issue #16](https://github.com/ocbe-uio/permChacko/issues/16)).

# permChacko 1.0.0

Expand Down
4 changes: 2 additions & 2 deletions R/chackoStatistic.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
chackoStatistic <- function(x_t, n, k, uniqueness_method = 1) {
m <- length(unique(x_t[, "x"])) # TODO: check what Chacko really means by m
chackoStatistic <- function(x_t, n, k, uniqueness_method = 2) {
m <- length(x_t[, "x"])
x_t_unique <- switch(uniqueness_method,
x_t[seq_len(m), , drop = FALSE], # current implementation
x_t[!duplicated(x_t[, "x"]), , drop = FALSE], # new idea (hidden)
Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/test-customExamples.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,12 @@ test_that("Verbosity works as expected", {
"Comparing 3.5 and 1.5. Replacing."
)
})

test_that("m is properly calculated on reduced vectors with duplicates", {
x <- c(12, 12, 16, 17, 13)
y <- reduceVector(x)
expect_equal(chackoStatistic(y$x_t, sum(x), length(x)), 2 / 3) # equiv to m=3
expect_equal(
chackoStatistic(y$x_t, sum(x), length(x), 1L), .95238095
) # equiv to m = 2
})
12 changes: 8 additions & 4 deletions tests/testthat/test-print-and-summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,21 @@ test_that("print.reduced_vector() works as expected", {
x <- reduceVector(rpois(6, 6))
expect_output(print(x), "Reduced vector : 4\\t4\\t4\\t5\\t8")
})

test_that("print.chacko_test() works as expected", {
expect_output(permChacko(rpois(8, 6), n_perm = 50L), NA)
y <- permChacko(rpois(3, 5), n_perm = 30L)
expect_output(print(y), "Test statistic \\(chisq_bar\\): 0\\.500000")
expect_output(print(y), "Analytic p-value\\s+: 0\\.778801")
expect_output(print(y), "Numeric p-value.+: 0\\.400000 \\(30 permutation")
expect_output(print(y), "Tabular p-value\\s+: 0\\.369550")
expect_output(print(y), "Test statistic \\(chisq_bar\\): 1\\.250000")
expect_output(print(y), "Analytic p-value\\s+: 0\\.535261")
expect_output(print(y), "Numeric p-value.+: 0\\.366667 \\(30 permutation")
expect_output(print(y), "Numeric mid-p value.+: 0\\.283333 \\(30 permutation")
expect_output(print(y), "Tabular p-value\\s+: 0\\.220987")
})

test_that("summary.reduced_vector() works as expected", {
expect_output(summary(reduceVector(rpois(7, 7))), "has been reduced 3 times")
})

test_that("Hypothesis suppression works as expected", {
expect_output(print(permChacko(4:1)), "p1 == p2 == p3 == p4")
expect_output(print(permChacko(6:1)), "p1 == p2 == ... == p5 == p6")
Expand Down

0 comments on commit 2b1da05

Please sign in to comment.