Skip to content

Commit

Permalink
Merge branch 'release-1.0.0' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
wleoncio committed Apr 17, 2024
2 parents f05b622 + 33d0cbb commit 1f599e0
Show file tree
Hide file tree
Showing 12 changed files with 167 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check-standard.yaml
Expand Up @@ -2,9 +2,9 @@
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [develop, release]
branches: [develop, release*]
pull_request:
branches: [develop, release]
branches: [develop, release*]

name: R-CMD-check

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yaml
Expand Up @@ -2,9 +2,9 @@
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [develop, release, fix-linter]
branches: [develop, release*, fix-linter]
pull_request:
branches: [develop, release]
branches: [develop, release*]

name: lint

Expand Down
95 changes: 95 additions & 0 deletions .github/workflows/rhub.yaml
@@ -0,0 +1,95 @@
# R-hub's generic GitHub Actions workflow file. It's canonical location is at
# https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml
# You can update this file to a newer version using the rhub2 package:
#
# rhub::rhub_setup()
#
# It is unlikely that you need to modify this file manually.

name: R-hub
run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}"

on:
workflow_dispatch:
inputs:
config:
description: 'A comma separated list of R-hub platforms to use.'
type: string
default: 'linux,windows,macos'
name:
description: 'Run name. You can leave this empty now.'
type: string
id:
description: 'Unique ID. You can leave this empty now.'
type: string

jobs:

setup:
runs-on: ubuntu-latest
outputs:
containers: ${{ steps.rhub-setup.outputs.containers }}
platforms: ${{ steps.rhub-setup.outputs.platforms }}

steps:
# NO NEED TO CHECKOUT HERE
- uses: r-hub/actions/setup@v1
with:
config: ${{ github.event.inputs.config }}
id: rhub-setup

linux-containers:
needs: setup
if: ${{ needs.setup.outputs.containers != '[]' }}
runs-on: ubuntu-latest
name: ${{ matrix.config.label }}
strategy:
fail-fast: false
matrix:
config: ${{ fromJson(needs.setup.outputs.containers) }}
container:
image: ${{ matrix.config.container }}

steps:
- uses: r-hub/actions/checkout@v1
- uses: r-hub/actions/platform-info@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/setup-deps@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/run-check@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}

other-platforms:
needs: setup
if: ${{ needs.setup.outputs.platforms != '[]' }}
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.label }}
strategy:
fail-fast: false
matrix:
config: ${{ fromJson(needs.setup.outputs.platforms) }}

steps:
- uses: r-hub/actions/checkout@v1
- uses: r-hub/actions/setup-r@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
- uses: r-hub/actions/platform-info@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/setup-deps@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
- uses: r-hub/actions/run-check@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
6 changes: 3 additions & 3 deletions CRAN-SUBMISSION
@@ -1,3 +1,3 @@
Version: 0.2.0
Date: 2023-11-07 08:27:25 UTC
SHA: 543f1ca2fb82489effd0178f2be3f9fec5e9f68b
Version: 1.0.0
Date: 2024-04-17 09:04:51 UTC
SHA: 6a30f4384d9d15cb292b9d25e45a868477d30606
6 changes: 3 additions & 3 deletions DESCRIPTION
@@ -1,7 +1,7 @@
Package: permChacko
Title: Chacko Test for Order-Restriction with Permutation
Version: 0.2.0
Date: 2023-11-07
Version: 1.0.0
Date: 2024-04-17
Authors@R:
c(
person(
Expand All @@ -25,7 +25,7 @@ Description: Implements an extension of the Chacko chi-square test for
License: GPL (>= 3)
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Suggests:
knitr,
rmarkdown,
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
@@ -1,3 +1,8 @@
# permChacko 1.0.0

* 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)).

# permChacko 0.2.0

* Replaced `verbose` with `verbosity` in functions to allow for more control over the output ([issue #3](https://github.com/ocbe-uio/permChacko/issues/3)).
Expand Down
7 changes: 6 additions & 1 deletion R/permChacko.R
Expand Up @@ -52,7 +52,11 @@ permChacko <- function(x, n_perm = 1000L, verbosity = 0) {

# The p-value is simply the fraction of such permutations that yield a test
# statistic equal to or greater than the one we originally observed.
perm_p_value <- sum(perm_chisq_bar >= chisq_bar) / n_perm
sum_eq <- sum(perm_chisq_bar == chisq_bar)
sum_gt <- sum(perm_chisq_bar > chisq_bar)
sum_gte <- sum(perm_chisq_bar >= chisq_bar)
perm_p_value <- sum_gte / n_perm
perm_mid_p_value <- (sum_gt + 0.5 * sum_eq) / n_perm
m <- nrow(x_t)
anal_p_value <- ifelse(
test = m > 1L,
Expand All @@ -70,6 +74,7 @@ permChacko <- function(x, n_perm = 1000L, verbosity = 0) {
p_values <- c(
"analytic" = anal_p_value,
"numeric" = perm_p_value,
"numeric_mid" = perm_mid_p_value,
"tabular" = table_p_value
)
out <- list(
Expand Down
25 changes: 21 additions & 4 deletions R/print.R
Expand Up @@ -11,12 +11,16 @@ print.chacko_test <- function(x, ...) {
"p-values:\n",
" Analytic p-value : %f\n",
" Numeric p-value : %f (%d permutations)\n",
" Numeric mid-p value : %f (%d permutations)\n",
" Tabular p-value : %f\n"
),
paste0("p", seq_along(x$observed_data), collapse = " == "),
paste0("p", seq_along(x$observed_data), collapse = " <= "),
x[["statistic"]], p_values[["analytic"]],
p_values[["numeric"]], x[["n_perm"]], p_values[["tabular"]]
printHypothesis("p", seq_along(x$observed_data), "=="),
printHypothesis("p", seq_along(x$observed_data), "<="),
x[["statistic"]],
p_values[["analytic"]],
p_values[["numeric"]], x[["n_perm"]],
p_values[["numeric_mid"]], x[["n_perm"]],
p_values[["tabular"]]
)
)
}
Expand All @@ -35,3 +39,16 @@ print.reduced_vector <- function(x, details = TRUE, ...) {
)
)
}

printHypothesis <- function(x_name, x_indices, operator = "==") {
operator <- paste0(" ", operator, " ")
if (length(x_indices) < 6) {
return(paste0(x_name, x_indices, collapse = operator))
} else {
first_idx <- 1:2
last_idx <- seq(length(x_indices) - 1, length(x_indices))
first_x <- paste0(x_name, x_indices[first_idx], collapse = operator)
last_x <- paste0(x_name, x_indices[last_idx], collapse = operator)
paste0(first_x, operator, "...", operator, last_x)
}
}
11 changes: 8 additions & 3 deletions README.md
@@ -1,7 +1,6 @@

# permChacko

permChacko is an R package that implements a modified version of the Chacko (1966) algorithm for order restriction.
permChacko is an R package that implements a modified version of the [Chacko (1966)](https://www.jstor.org/stable/25051572) algorithm for order restriction.

## Installation

Expand Down Expand Up @@ -32,10 +31,16 @@ library(permChacko)
permChacko(chacko66_sec3) # example 5 from Chacko (1966)
```

## References

Chacko, V. J. "Testing homogeneity against ordered alternatives." The Annals of Mathematical Statistics (1963): 945-956. https://www.jstor.org/stable/2238476

Chacko, V. J. (1966). Modified Chi-Square Test for Ordered Alternatives. Sankhyā: The Indian Journal of Statistics, Series B (1960-2002), 28(3/4), 185–190. http://www.jstor.org/stable/25051572

## Badges

<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
[![CodeFactor](https://www.codefactor.io/repository/github/ocbe-uio/permChacko/badge)](https://www.codefactor.io/repository/github/ocbe-uio/permChacko)
[![R build status](https://github.com/ocbe-uio/permChacko/workflows/R-CMD-check/badge.svg)](https://github.com/ocbe-uio/permChacko/actions)
[![Codecov](https://codecov.io/gh/ocbe-uio/permChacko/branch/develop/graph/badge.svg)](https://codecov.io/gh/ocbe-uio/permChacko)
Expand Down
20 changes: 17 additions & 3 deletions cran-comments.md
@@ -1,5 +1,19 @@
## R CMD check results
Dear CRAN Team,
this is a resubmission of package 'permChacko'. I have added the following changes:

0 errors | 0 warnings | 1 note
* 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)).

* This is a new release.
Please upload to CRAN.
Best, Waldir

# Package permChacko 1.0.0

Reporting is done by packager version 1.15.2

## Test environments
- R version 4.3.1 (2023-06-16)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 23.10
ERROR: No check log found!
- win-builder (devel)
1 change: 0 additions & 1 deletion man/permChacko-package.Rd

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

6 changes: 5 additions & 1 deletion tests/testthat/test-print-and-summary.R
Expand Up @@ -13,9 +13,13 @@ test_that("print.chacko_test() works as expected", {
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\\s+: 0\\.400000 \\(30 permutation")
expect_output(print(y), "Numeric p-value.+: 0\\.400000 \\(30 permutation")
expect_output(print(y), "Tabular p-value\\s+: 0\\.369550")
})
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")
})

0 comments on commit 1f599e0

Please sign in to comment.