Skip to content

Commit

Permalink
Merge commit 'fe63fe14' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
wleoncio committed Sep 18, 2024
2 parents 1f599e0 + fe63fe1 commit b7c23a7
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-standard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
Expand Down
6 changes: 3 additions & 3 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: 1.0.0
Date: 2024-04-17 09:04:51 UTC
SHA: 6a30f4384d9d15cb292b9d25e45a868477d30606
Version: 1.0.1
Date: 2024-09-18 06:43:47 UTC
SHA: b1a16105f7008089bce6302cb9c54c41f40eb088
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: permChacko
Title: Chacko Test for Order-Restriction with Permutation
Version: 1.0.0
Date: 2024-04-17
Version: 1.0.1
Date: 2024-09-18
Authors@R:
c(
person(
Expand All @@ -25,7 +25,8 @@ Description: Implements an extension of the Chacko chi-square test for
License: GPL (>= 3)
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
Imports: methods
Suggests:
knitr,
rmarkdown,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ export(chacko66_sec5)
export(permChacko)
export(reduceVector)
export(ruxton221207)
importFrom(methods,is)
importFrom(stats,pchisq)
importFrom(stats,weighted.mean)
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# permChacko 1.0.1

* 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

* Improved printing of hypothesis ([issue #11](https://github.com/ocbe-uio/permChacko/issues/11)).
Expand Down
16 changes: 7 additions & 9 deletions R/chackoStatistic.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
chackoStatistic <- function(x_t, n, k) {
x_bar <- x_t[, "x"]
t <- x_t[, "t"]
m <- length(unique(x_bar))
power_sum <- 0
for (j in seq_len(m)) {
power_sum <- power_sum + t[[j]] * (x_bar[[j]] - n / k) ^ 2
}
return(k / n * power_sum)
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], # legacy code (hidden)
x_t[!duplicated(x_t[, "x"]), , drop = FALSE], # current implementation
)
k / n * sum(x_t_unique[, "t"] * (x_t_unique[, "x"] - n / k) ^ 2)
}
5 changes: 1 addition & 4 deletions R/permChacko-package.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#' @keywords internal
#' @aliases permChacko-package
#' @importFrom methods is
"_PACKAGE"

## usethis namespace: start
## usethis namespace: end
NULL
2 changes: 1 addition & 1 deletion R/permChacko.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#' permChacko(chacko66_sec5)
#' @export
permChacko <- function(x, n_perm = 1000L, verbosity = 0) {
if (!is.null(dim(x))) stop("Input must be a vector")
if (!is(x, "numeric")) stop("Input must be a vector")
if (verbosity >= 1L) message("Reducing original vector")
# Ordering and reducing vector
x_t <- reduceVector(x, verbosity)[["x_t"]]
Expand Down
2 changes: 1 addition & 1 deletion R/reduceVector.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#' reduceVector(chacko66_sec5)
#' reduceVector(chacko66_sec5, verbosity = 1)
reduceVector <- function(x, verbosity = 0L) {
if (!is.null(dim(x))) stop("Input must be a vector")
if (!is(x, "numeric")) stop("Input must be a vector")
x_t <- cbind("x" = unname(x), "t" = unname(x) ^ 0L)
reductions <- 0L
while (nrow(x_t) > 1L && isMonotoneIncreasing(x_t[, "x"])) {
Expand Down
16 changes: 11 additions & 5 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
Dear CRAN Team,
this is a resubmission of package 'permChacko'. I have added the following changes:

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

Please upload to CRAN.
Best, Waldir

# Package permChacko 1.0.0
# Package permChacko 1.0.1

Reporting is done by packager version 1.15.2


## Test environments
- R version 4.3.1 (2023-06-16)
- R version 4.3.3 (2024-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 23.10
Running under: Ubuntu 24.04.1 LTS
ERROR: No check log found!
- win-builder (devel)

## Local test results

## Local meta results
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 b7c23a7

Please sign in to comment.