Skip to content

Add Dunnett-type 4-dose GSD vignette and bump version to 0.3.0#52

Merged
keaven merged 19 commits intomainfrom
46-s7-change-generate_corr-to-s7
May 8, 2026
Merged

Add Dunnett-type 4-dose GSD vignette and bump version to 0.3.0#52
keaven merged 19 commits intomainfrom
46-s7-change-generate_corr-to-s7

Conversation

@keaven
Copy link
Copy Markdown
Collaborator

@keaven keaven commented Apr 29, 2026

Summary

This PR adds a new vignette demonstrating the WPGSD methodology for a Dunnett-type dose-finding trial and bumps the package version to 0.3.0.

New Vignette: Dunnett-type dose-finding with group sequential design

Demonstrates the WPGSD approach for a trial with 4 experimental dose groups vs. a common control with:

  • Endpoint: Overall Survival (OS)
  • Multiplicity: Equal weights (1/4), equal transitions (1/3) among dose arms
  • Group sequential design: Interim analysis at ~40% information fraction
  • Futility: Common non-binding futility bound via gsDesign (HSD beta-spending)
  • Efficacy: WPGSD Type 3 (separate alpha spending) with Lan-DeMets O'Brien-Fleming, compared to Bonferroni
  • Closed testing: Full closed testing procedure with hypothetical observed p-values

Key results

  • Correlation matrix (8x8) verified against manual computation for all 5 cases
  • Correlations of ~0.50 between dose-vs-control comparisons at same analysis (shared control arm)
  • WPGSD bounds are meaningfully less conservative than Bonferroni bounds
  • generate_corr() handles 4+ hypotheses correctly with no code changes needed

Other changes

  • Version bump: 0.2.0 -> 0.3.0
  • Bibliography: Added Dunnett (1955) reference to wpgsd.bib

keaven and others added 13 commits August 29, 2025 17:19
- Add EventTable and CorrelationMatrix S7 classes with type safety and validation
- Implement generate_corr_s7() with EventTable input and proper column ordering
- Update vignettes with S7 examples and improved math typesetting
- Reorganize pkgdown reference documentation for better discoverability
- Maintain full backward compatibility with existing functions
- Add comprehensive test suite (105+ tests) covering all S7 functionality
- Update NEWS.md with detailed release notes for v0.2.0
…trix

- Add S7 class system for enhanced type safety and validation
- Implement EventTable S7 class with comprehensive data validation
- Implement CorrelationMatrix S7 class with mathematical constraints
- Add generate_corr_s7() function with EventTable input and proper column ordering
- Add S7 constructors, converters, and utility functions
- Update vignettes with S7 examples and improved math formatting
- Reorganize pkgdown reference documentation with logical groupings
- Maintain full backward compatibility with existing functions
- Add comprehensive test suite (105+ tests)
- Update NEWS.md with detailed release notes
- Fixed correlation matrix symmetry validation tolerance (1e-12 with check.attributes=FALSE)
- Removed non-ASCII character from print method (× to x)
- Renamed non-portable filename: s7 prompts.md -> s7_prompts.md
- Added missing @export for generate_event_table_cc function
- Added EventTable to package exports
- Simplified roxygen documentation to avoid parsing issues
- All 132 unit tests passing
- Package builds and installs successfully
- pkgdown documentation site updated
- Implement complete S7 class system with EventTable and CorrelationMatrix classes
- Add robust validation for correlation matrices and event data
- Fix correlation matrix validation tolerance issues (1e-12 precision)
- Resolve non-ASCII character issues in documentation
- Add missing @export tags for proper function exports
- Significantly improve adj-seq-p vignette with 80% code reduction
- Add systematic helper functions for better maintainability
- Enhanced mathematical notation and multiplicity strategy visualization
- Add comprehensive citations and improved explanations
- Update NEWS.md with detailed changelog for v0.2.0
- All 132 tests passing with enhanced test coverage
- Complete documentation and pkgdown site generation
Add blank line before bullet points for better readability in adj-seq-p vignette
…ring

- Remove redundant wrapper functions new_event_table() and new_correlation_matrix()
- Enhance S7 class documentation with comprehensive parameter descriptions
- Consolidate validation logic into validate_event_data_core() eliminating ~80% duplication
- Update all examples, tests, and documentation to use direct S7 constructors
- Relax Event validation to allow non-integer values while maintaining H1/H2/Analysis as integers
- Regenerate package documentation and fix NAMESPACE exports
- Update pkgdown configuration to reflect API changes
- Add comprehensive NEWS.md documentation for v0.2.0 changes

Improves code maintainability and follows S7 best practices for class documentation.
…ITLE in navigation

- Deleted empty vignettes/adj-seq-p-simplified.Rmd file (0 bytes)
- Removed corresponding docs/articles/adj-seq-p-simplified.html
- Rebuilt pkgdown site to fix navigation dropdown
- Resolves UNKNOWN TITLE issue in Articles menu
- Added structured reference sections to _pkgdown.yml:
  * S7 Classes and Constructors
  * Event Table Generation
  * Correlation Matrix Computation
  * Statistical Testing and Analysis
  * Data Manipulation and Subsetting
  * Data Validation
  * Utility Functions
  * Package Information
- Improves user experience by grouping related functions together
- Reference documentation now displays functions in logical categories
@keaven keaven linked an issue Apr 29, 2026 that may be closed by this pull request
keaven and others added 2 commits April 29, 2026 20:44
- Fix validator to allow single-analysis/hypothesis EventTables
- Guard floor() calls with is.numeric checks
- Fix paste/paste0 inconsistency in error messages
- Correct test expectations to match actual error messages
- Add NEWS.md entry for v0.3.0
@nanxstats
Copy link
Copy Markdown
Contributor

Here is a prompt you can use to clean things up:

1. Remove these committed files/directories and commit:

- ..Rcheck/
- wpgsd.Rcheck/
- wpgsd_0.1.0.tar.gz
- wpgsd_0.2.0.tar.gz
- vignettes/adj-seq-p.html

2. Then, add appropriate rules to .gitignore to prevent them from being accidentally committed in the future, for example:

```
# Output files from R CMD check
/*.Rcheck/

# Output files from R CMD build
/*.tar.gz

# produced vignettes
vignettes/*.html
vignettes/*.pdf
```

3. Find canonical format and locations (tests, vignettes, etc.) within R packages to place the content of these files and remove them from the current location:

- examples/*.R
- EventTable_README.md

4. Use hyphens `-` as separator in vignette file names consistently (tidyverse package convention) so the rendered HTML pages have canonical clean URLs.

keaven and others added 3 commits April 30, 2026 06:56
- Fix duplicate/merged roxygen blocks in s7_classes.R and compute_correlations.R
- Add @name tags for S7 class definitions (EventTable, CorrelationMatrix)
- Separate @importFrom block from EventTable roxygen with NULL
- Remove orphaned validate_event_data_core roxygen block from s7_classes.R
- Fix stray backtick in @param event in generate_event_table_.R and generate_event_ol.R
- Fix EventTable example data to be valid (complete event table)
- Regenerate all affected Rd files
@keaven keaven requested a review from Copilot April 30, 2026 14:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

@keaven keaven requested review from LittleBeannie and Copilot April 30, 2026 14:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

- Fix within-hypothesis and between-hypotheses correlation loops in
  generate_corr() to correctly enumerate all analysis pairs when K>2
- Add test for generate_corr() with 2 hypotheses and 3 analyses
- Rewrite Dunnett vignette: 2 doses / 3 analyses (2 interims + final)
  instead of 4 doses / 2 analyses, exercising full K>2 generality
- Update NEWS.md with bug fix and vignette changes
Comment thread ..Rcheck/00check.log
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we get rid of this log file and its ..Rcheck folder?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in #54

@@ -0,0 +1,71 @@
# Example integration of EventTable S7 class with existing wpgsd functions
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the following header at the begining of this file.

# Copyright (c) 2026 Merck & Co., Inc., Rahway, NJ, USA and its affiliates.
# All rights reserved.
#
# This file is part of the wpgsd program.
#
# wpgsd is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you like to keep this file when we submit to CRAN?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added inst/aiprompts/ to .Rbuildignore in #54

Comment thread R/compute_correlations.R

#' Compute correlations from event data
#'
#' @description
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please explain the difference between this new function compute_correlations() and the existing function generate_corr()?

Comment thread R/compute_correlations.R
}
}

#' Convert correlation data frame to correlation matrix
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a couple of questions about the correlation data frame (corr_df) that I hope you can clarify.

  • Meaning of H1 and H2 Columns: In the example, the corr_df has columns H1 = 2 and H2 = 1. After reviewing the code, my understanding is that this specifies the correlation between H2 and H1. Is this interpretation correct? If so, it might be beneficial for other users if the documentation for the @param corr_df could be updated to explain this relationship more explicitly.
  • Clarification on the Correlation column: I am also a bit confused about the Correlation column within corr_df. Could you please explain how the value in this column differs from the correlation matrix that is generated by the gen_corr function? Understanding the distinction would be very helpful.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we remove the entire wpgsd.Rcheck folder?

@LittleBeannie LittleBeannie self-requested a review May 7, 2026 21:00
@keaven keaven merged commit 2ee3089 into main May 8, 2026
8 checks passed
@jdblischak jdblischak mentioned this pull request May 8, 2026
Copy link
Copy Markdown

@jdblischak jdblischak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I addressed many of Nan's suggestions in #54

Comment thread ..Rcheck/00check.log
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in #54

Comment on lines +1 to +71
# Example integration of EventTable S7 class with existing wpgsd functions
# This shows how EventTable can work with generate_corr()

library(wpgsd)
library(tibble)

# Example 1: Using EventTable with generate_corr()
# Create event data using the EventTable class
event_data_raw <- tibble::tribble(
~H1, ~H2, ~Analysis, ~Event,
1, 1, 1, 155,
2, 2, 1, 160,
3, 3, 1, 165,
1, 2, 1, 85,
1, 3, 1, 85,
2, 3, 1, 85,
1, 1, 2, 305,
2, 2, 2, 320,
3, 3, 2, 335,
1, 2, 2, 170,
1, 3, 2, 170,
2, 3, 2, 170
)

# Create EventTable object
event_table <- EventTable(data = event_data_raw)
print("Created EventTable:")
print(event_table)

# Use with generate_corr (currently expects tibble/data.frame)
# The @data slot extracts the underlying tibble
correlation_matrix <- generate_corr(event_table@data)
print("Generated correlation matrix:")
print(correlation_matrix)

# Example 2: Data validation before processing
cat("\nExample 2: Data validation\n")
cat("==========================\n")

# Try to create EventTable with invalid data
tryCatch({
invalid_data <- tibble::tibble(
H1 = c(1, 2, -1), # Invalid: negative hypothesis index
H2 = c(1, 2, 3),
Analysis = c(1, 1, 1),
Event = c(100, 200, 150)
)

invalid_table <- EventTable(data = invalid_data)
}, error = function(e) {
cat("Validation caught error:", e$message, "\n")
})

# Example 3: Subsetting capabilities
cat("\nExample 3: Subsetting\n")
cat("=====================\n")

# Get only first analysis
analysis_1 <- subset_event_table(event_table, analysis = 1)
cat("Analysis 1 events:\n")
print(analysis_1@data)

# Get only H1-H2 hypothesis pairs
h1_h2_events <- subset_event_table(event_table, hypotheses = c(1, 2))
cat("\nH1-H2 hypothesis events:\n")
print(h1_h2_events@data)

# Example 4: Summary information
cat("\nExample 4: Summary\n")
cat("==================\n")
summary(event_table)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code fails when I run it locally:

summary(event_table)
## Error in check_subsettable(x, allow_env = TRUE) : 
##   S7 objects are not subsettable.

print(event_table)

# Get summary
summary(event_table)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code fails when I run it locally:

summary(event_table)
## Error in check_subsettable(x, allow_env = TRUE) : 
##   S7 objects are not subsettable.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added inst/aiprompts/ to .Rbuildignore in #54

Comment thread NAMESPACE
export(gen_corr)
export(generate_bounds)
export(generate_corr)
export(generate_corr_s7)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this PR did not replace the existing generate_corr() with an S7 version (#46). Instead, it created an additional function generate_corr_s7().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

s7: change generate_corr to s7

5 participants