This repository documents and assembles the RMSTpowerBoost Shiny application as an engineering system.
This README is for contributors and maintainers: architecture, module boundaries, data flow, and quality wiring.
- Audience: maintainers extending modeling methods, simulation logic, reporting, and QA/CI integration.
- Scope: internal system structure and component interactions.
- Out of scope: end-user operation and launch walkthroughs.
app.R: single-file Shiny shell, UI layout, server orchestration, validation, report hooks, and integration with method engines.R/: modeling and simulation engines (analytical engines and their shared estimation helpers, recipe simulator, recipe set generation/loading).data/: packaged datasets consumed by app methods and tests.data-raw/: source material and scripts used to regenerate bundled data assets.tests/testthat/: coverage harness and targeted simulation/branch correctness tests..github/workflows/: CI automation for coverage upload and package sync.coverage/: locally generated coverage artifacts; CI generates its own report for every commit.tools/: local engineering utilities (for example, coverage artifact generation/upload helper).codecov.yml: Codecov policy (thresholds, precision, rounding, ignore patterns).DESCRIPTIONandNAMESPACE: package metadata/imports and exported function surface.
app.R is a coordinator layer around method modules in R/:
- Package loading guard: validates all required UI/report/data packages before app object creation.
- Repo-root guard: verifies execution context is the repository root/workspace and resolves app-relative paths.
- Dynamic module loading: sources all
R/*.Rfiles at startup so method engines are available to the server layer. - Helper/validation layer: coercion and schema guards for time/status/arm inputs, formatting helpers, plotting adapters, and UI reset helpers.
- UI assembly: central fluid-page layout with method selection, data source controls, diagnostics, plots, tables, and report export controls.
- Server orchestration: state management (
reactiveValues), input/event handlers, method dispatch, diagnostics execution, and rendering. - Report generation hooks: inline report template construction and HTML/PDF export paths integrated with computed results.
Design note: app.R intentionally keeps orchestration in one file and delegates statistical computation/simulation to dedicated files under R/.
R/linear_ipcw_analytical_app.R- linear IPCW analytical power/sample-size functions.
R/additive_stratified_analytical_app.R- additive stratified analytical functions.
R/multiplicative_stratified_analytical_app.R- multiplicative stratified analytical method implementations.
R/dependent_censoring_analytical_app.R- dependent-censoring analytical estimation and power/sample-size functions.
R/estimation_helpers_app.R- shared machinery: data preparation, Cox censoring weights, the Wald power formula, the sample-size search, and plotting.
The estimators, censoring weights and power formulas are ported from the
RMSTpowerBoost package (R/estimation-helpers.R), so for the same pilot data the
app and the package give identical estimates, power and required sample sizes.
IPCW weights come from conditional Cox censoring models and are used as fitted,
with no cap or floor. The power functions take a test argument with the
package defaults: the weighted-least-squares t-test for the linear and
dependent-censoring models, and the sandwich Wald test for the multiplicative
model. The additive model has a single sandwich Wald test.
The Repeated calculation method resamples the pilot data inside app.R
(repeated_power_from_pilot) and reuses the .estimate_*_params helpers of
the selected model, so both methods share one estimator per model. Each
replicate applies the same test the Analytical method reports, so the two agree
within Monte Carlo error. The two-arm models resample per arm; the stratified
models resample per stratum with arms pooled, so N is per stratum in both
methods.
R/recipe_sim.R- recipe validation, covariate generation, treatment assignment, linear predictor construction, survival-time simulation, and convenience recipe constructors.
R/generate_sets.R- recipe grid/set expansion and metadata collection for reusable simulation suites.
R/load_sets.R- manifest loading and manifest rebuild utilities for recipe-set assets.
Exports (from NAMESPACE) are grouped as:
- Analytical power and sample-size methods:
linear.power.analytical.app,linear.ss.analytical.appadditive.power.analytical.app,additive.ss.analytical.appMS.power.analytical.app,MS.ss.analytical.appDC.power.analytical.app,DC.ss.analytical.app
- Simulation and recipe APIs:
simulate_from_recipe,validate_recipe,recipe_quick_aft,recipe_gridgenerate_recipe_sets,load_recipe_sets,rebuild_manifest
- Internal estimators exposed for package-level composition:
.estimate_*_params
- Source selection:
- server receives either uploaded pilot data or simulated data definitions.
- Schema and cleaning validation:
- type coercion/consistency checks are applied (time/status/arm and covariate structures).
- missingness and compatibility checks gate method execution.
- Model selection and parameter assembly:
- server builds method-specific parameter objects from UI + data context.
- covariate definitions and allocation settings are normalized for engines.
- Engine invocation:
app.Rdispatches toR/modules:- simulation path:
simulate_from_recipe(...) - method paths:
*.power.analytical.app/*.ss.analytical.appfunctions across linear/additive/multiplicative/dependent-censoring families, and the model-awarerepeated_power_from_pilotresampling method - diagnostics path: inline log-rank/KM summary in
app.R
- simulation path:
- Result materialization:
- tabular summaries, figures, diagnostics objects, and downloadable report payloads are created.
- Report export:
- report inputs are assembled, inline template is rendered, and HTML/PDF outputs are generated from computed state.
Recipe-set path:
- sets are generated with
generate_recipe_sets(...)/recipe_grid(...), persisted with metadata, then loaded withload_recipe_sets(...)for simulation execution.
tests/testthat/test-coverage-app.R- app harness and broad integration coverage paths.
tests/testthat/test-coverage-targeted.R- targeted branch and edge-condition coverage for high-risk logic.
tests/testthat/test-recipe-sim.R- recipe simulation correctness and invariants for synthetic data generation.
Coverage policy context (codecov.yml):
- project and patch status thresholds are enabled (
target: auto,threshold: 1%). - precision/rounding are configured (
precision: 2,round: down). - selected paths are excluded (for example
renv/**,rsconnect/**, and data-generation-specific files).
Artifacts generated in coverage/:
coverage/cobertura.xmlcoverage/coverage.rdscoverage/summary.txt
Local artifact generation/upload helper:
source("tools/run_codecov_local.R")Workflow behavior in .github/workflows/codecov_sync.yml:
- On every push to
mainand every pull request, CI installs the dependencies listed inDESCRIPTION, runscovr::package_coverage(), and writes a freshcoverage/cobertura.xml. - CI uploads that fresh report to Codecov using repository secret
CODECOV_TOKEN. - CI never uploads the committed
coverage/files. Codecov discards a report whose timestamp is more than 12 hours old, so re-uploading a committed report records 0% for the new commit. - The renv autoloader is disabled in CI (
RENV_CONFIG_AUTOLOADER_ENABLED=false), and.Rprofileskips itsgit pullwhen theCIvariable is set.
- Live application: https://arnab96.shinyapps.io/uthsc-app/
- RMSTpowerBoost package docs/source: https://uthsc-zhang.github.io/RMSTpowerBoost-Package/articles/RMSTpowerBoost-Main.html
- Project issues: https://github.com/UTHSC-Zhang/RMSTpowerBoost-Package/issues