Skip to content

936: complete combo fixed prior for now#942

Merged
danielinteractive merged 35 commits into
936-combo-devfrom
936-combo-fixed-prior
May 18, 2026
Merged

936: complete combo fixed prior for now#942
danielinteractive merged 35 commits into
936-combo-devfrom
936-combo-fixed-prior

Conversation

@danielinteractive
Copy link
Copy Markdown
Collaborator

progress for #936

danielinteractive and others added 30 commits April 7, 2026 17:49
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
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.

Pull request overview

This PR advances issue #936 by adding first-pass infrastructure for two-drug combination dose-escalation in crmPack, including a new DesignCombo workflow, combo-specific simulations output (ComboSimulations), and supporting rules/utilities (increments, next-best, stopping/backfill helpers), alongside substantial test and documentation updates.

Changes:

  • Introduces DesignCombo and simulate(DesignCombo) producing ComboSimulations, plus summary/show/plot support for combo simulations.
  • Adds combination-aware rules/utilities: nextBest(NextBestNCRM, ..., DataCombo), combo maxDose() increments, and singleDrugData(DataCombo, ...).
  • Regenerates/extends documentation, examples, and tests to cover the new combo workflow and revised behaviors.

Reviewed changes

Copilot reviewed 101 out of 103 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/testthat/test-Simulations-validity.R Adds validity tests for ComboSimulations objects.
tests/testthat/test-Simulations-methods.R Adds plot/summary/show tests for ComboSimulations and ComboSimulationsSummary.
tests/testthat/test-Simulations-class.R Adds class/constructor tests for ComboSimulations and ComboSimulationsSummary.
tests/testthat/test-Rules-methods.R Adds tests for combo next-best, combo maxDose increments, stopping/cohort size with DataCombo.
tests/testthat/test-Rules-class.R Adds class tests for new combo increment rule classes.
tests/testthat/test-helpers_rules.R Adds tests for h_dose_combo_below_limit().
tests/testthat/test-helpers_knitr_Design.R Adds knit-print test coverage for DesignCombo.
tests/testthat/test-helpers_backfill.R New tests for cohort/dose backfill helpers with DataCombo.
tests/testthat/test-Design-validity.R Adds validity tests for DesignCombo starting dose.
tests/testthat/test-Design-methods.R Adds simulation tests for DesignCombo.
tests/testthat/test-Design-class.R Adds class/constructor tests for DesignCombo.
tests/testthat/test-Data-methods.R Adds tests for singleDrugData(DataCombo, ...).
tests/testthat/test-Backfill-validity.R Updates tests for OpeningMinDose validity behavior.
tests/testthat/test-Backfill-methods.R Adds backfill opening tests with DataCombo.
tests/testthat/test-Backfill-class.R Adds constructor test for vector-valued OpeningMinDose.
R/Simulations-validity.R Implements v_combo_simulations() validity checks.
R/Simulations-methods.R Adds combo plots (incl. 2D trajectory), combo summary, and show/plot methods for combo simulations.
R/Simulations-class.R Defines ComboSimulations / ComboSimulationsSummary classes and constructors.
R/Rules-methods.R Adds nextBest() for DataCombo, combo maxDose() increments, and extends several stopping/cohort size behaviors for DataCombo.
R/Rules-class.R Adds IncrementsComboOneDrugOnly and IncrementsComboCartesian classes; adjusts StoppingSpecificDose to allow numeric vectors.
R/helpers_rules.R Adds h_dose_combo_below_limit() helper for filtering combo dose grids.
R/helpers_knitr_GeneralModel.R Adds knit-print support for LogisticLogNormalCombo.
R/helpers_knitr_GeneralData.R Adds knit-print support for DataCombo.
R/helpers_knitr_Design.R Adds knit-print support for DesignCombo including starting-dose section.
R/helpers_backfill.R Extends cohort/dose backfill helpers to handle matrix (combo) doses.
R/Design-validity.R Adds v_design_combo() validation for 2D starting dose and membership in dose grid.
R/Design-methods.R Adds simulate(DesignCombo) implementation producing ComboSimulations.
R/Design-class.R Adds DesignCombo class and default constructor.
R/Data-methods.R Adds singleDrugData generic + DataCombo method.
R/Backfill-validity.R Broadens OpeningMinDose@min_dose validation to numeric vectors.
R/Backfill-methods.R Extends openCohort() logic to handle vector/matrix doses.
R/Backfill-class.R Updates documentation for OpeningMinDose@min_dose to allow combo vectors.
NAMESPACE Exports new combo classes/methods and adds knit_print S3 registrations.
man/v_model_objects.Rd Documents combo model validity helper alias.
man/v_general_simulations.Rd Documents v_combo_simulations().
man/v_design.Rd Documents v_design_combo().
man/v_data_objects.Rd Documents combo data validator and helper alias.
man/update-DataCombo-method.Rd Minor formatting fix in Rd.
man/TITELogisticLogNormal-class.Rd Fixes Rd link formatting.
man/tidy.Rd Fixes tibble link formatting.
man/TDsamplesDesign-class.Rd Fixes RuleDesign link formatting; updates args section.
man/TDDesign-class.Rd Fixes RuleDesign link formatting; updates args section.
man/stopTrial.Rd Updates stopTrial method aliases/signatures for broader GeneralData usage.
man/StoppingSpecificDose-class.Rd Updates dose argument type documentation.
man/StoppingCohortsNearDose-class.Rd Clarifies interpretation for DataCombo in docs.
man/singleDrugData.Rd New documentation for singleDrugData().
man/simulate-DesignCombo-method.Rd New documentation for simulate(DesignCombo).
man/show-ComboSimulationsSummary-method.Rd New documentation for show(ComboSimulationsSummary).
man/show-ComboSimulations-method.Rd New documentation for show(ComboSimulations).
man/probFunction.Rd Cleans up aliases/sections in docs output.
man/prob.Rd Adds combo prob() method aliases and updates return-value wording.
man/prob-numeric-LogisticLogNormalOrdinal-Samples-method.Rd New Rd page for ordinal prob method.
man/plot-DataDual-missing-method.Rd Fixes ggplot2 link formatting.
man/plot-DataDA-missing-method.Rd Fixes ggplot2 link formatting.
man/plot-DataCombo-missing-method.Rd New documentation for plot(DataCombo).
man/plot-Data.Rd Fixes ggplot2 link formatting.
man/plot-ComboSimulationsSummary-missing-method.Rd New documentation for plotting combo simulation summaries.
man/plot-ComboSimulations-missing-method.Rd New documentation for plotting combo simulations.
man/OpeningMinDose-class.Rd Updates slot docs for vector min dose support.
man/nextBest.Rd Documents nextBest() overload for DataCombo + new example block.
man/McmcOptions-class.Rd Fixes rjags link formatting.
man/mcmc.Rd Documents combo mcmc(DataCombo, LogisticLogNormalCombo, ...) method.
man/maxDose.Rd Documents combo maxDose methods and adds examples.
man/LogisticLogNormalCombo-class.Rd New documentation for combo logistic log-normal model class.
man/knit_print.Rd Registers knit_print docs for DesignCombo, DataCombo, LogisticLogNormalCombo.
man/IncrementsRelativeParts-class.Rd Fixes link formatting.
man/IncrementsComboOneDrugOnly-class.Rd New documentation for one-drug-only combo increments rule.
man/IncrementsComboCartesian-class.Rd New documentation for cartesian combo increments rule.
man/h_test_named_numeric.Rd Fixes checkmate link formatting.
man/h_plot_combo_evolution.Rd New documentation for internal combo evolution plot helper.
man/h_eval_combo_truth.Rd New documentation for combo truth-evaluation helper.
man/h_dose_combo_below_limit.Rd New documentation for dose-limit filtering helper.
man/gain.Rd Cleans up aliases/sections in docs output.
man/FractionalCRM-class.Rd Fixes link formatting.
man/fit.Rd Documents combo fit method signature and behavior.
man/enable_logging.Rd Fixes futile.logger link formatting.
man/efficacyFunction.Rd Cleans up aliases/sections in docs output.
man/DualResponsesSamplesDesign-class.Rd Fixes link formatting.
man/DualResponsesDesign-class.Rd Fixes link formatting.
man/DualDesign-class.Rd Fixes link formatting.
man/doseFunction.Rd Cleans up aliases/sections in docs output.
man/DesignOrdinal-class.Rd Fixes link formatting.
man/DesignCombo-class.Rd New documentation for DesignCombo class.
man/Design-class.Rd Fixes RuleDesign link formatting; updates args section.
man/DataCombo-class.Rd New documentation for DataCombo class.
man/DALogisticLogNormal-class.Rd Fixes link formatting.
man/DADesign-class.Rd Fixes link formatting.
man/crmPack.Rd Adds author entry.
man/ComboSimulationsSummary-class.Rd New documentation for combo simulations summary class.
man/ComboSimulations-class.Rd New documentation for combo simulations class.
man/check_equal.Rd Removes duplicated “seealso” entry formatting.
man/biomarker.Rd Cleans up aliases/sections in docs output.
examples/Rules-method-nextBest-NextBestNCRM-DataCombo.R New example for combo nextBest() usage.
examples/Rules-method-maxDose-IncrementsMin-DataCombo.R New example for combo maxDose(IncrementsMin, DataCombo).
examples/Rules-method-maxDose-IncrementsComboOneDrugOnly.R New example for combo maxDose one-drug-only rule.
examples/Rules-method-maxDose-IncrementsComboCartesian.R New example for combo maxDose cartesian rule.
examples/Rules-class-IncrementsComboOneDrugOnly.R New class example for one-drug-only increments.
examples/Rules-class-IncrementsComboCartesian.R New class example for cartesian increments.
examples/design-method-simulate-DesignCombo.R New example for simulating a combo design.
examples/Design-class-DesignCombo.R New example for constructing a DesignCombo.
examples/Data-method-singleDrugData.R New example for extracting single-drug data from DataCombo.
DESCRIPTION Updates roxygen2 version metadata.
.vscode/settings.json Adds terminal auto-approval entry for R.
Files not reviewed (1)
  • man/ComboSimulations-class.Rd: Language not supported
Comments suppressed due to low confidence (4)

R/Rules-methods.R:3090

  • StoppingPatientsNearDose uses isTRUE(is.na(dose)) to detect missing doses. For combination doses is.na(dose) returns a vector and isTRUE() will be FALSE, so NA doses will fall through and produce NA bounds/counts. Use anyNA(dose) (or all(is.na(dose))) and ideally short-circuit before computing lower/upper when dose is missing.
    n_patients <- ifelse(
      isTRUE(is.na(dose)),
      0,
      sum(patients_within_bounds)
    )

R/Rules-methods.R:3234

  • StoppingTargetProb uses isTRUE(is.na(dose)) to guard the probability calculation. For DataCombo-style dose vectors, this guard won’t trigger when any component is NA, which can lead to invalid prob() calls/comparisons. Prefer anyNA(dose) (or all(is.na(dose))) for vector doses.
    # Compute probability to be in target interval.
    prob_target <- ifelse(
      isTRUE(is.na(dose)),
      0,
      mean(
        prob(dose = dose, model, samples, ...) >= stopping@target[1] &
          prob(dose = dose, model, samples, ...) <= stopping@target[2]

R/Rules-methods.R:3662

  • StoppingHighestDose checks isTRUE(is.na(dose)), which is not correct for vector doses (e.g., DataCombo). If any component is NA, the current code will evaluate the “highest dose” comparisons with missing values. Use anyNA(dose) (or all(is.na(dose))) to guard vector doses.
    is_data_or_ordinal <- is(data, "Data") || is(data, "DataOrdinal")
    is_combo_data <- is(data, "DataCombo")
    is_highest_dose <- ifelse(
      isTRUE(is.na(dose)),
      FALSE,
      if (is_data_or_ordinal) {
        dose == data@doseGrid[data@nGrid]
      } else if (is_combo_data) {

R/Rules-methods.R:2065

  • maxDose() for IncrementsComboCartesian calls singleDrugData(data, "drug1") / "drug2", which will error if data@drugNames differ from those literals. Use data@drugNames[1] / data@drugNames[2] (and likewise avoid data@doseGrid$drug1/$drug2) to support arbitrary combination drug names.
  definition = function(increments, data, ...) {
    data_drug1 <- singleDrugData(data, "drug1")
    data_drug2 <- singleDrugData(data, "drug2")


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread R/Rules-methods.R Outdated
Comment thread R/Rules-methods.R Outdated
Comment thread R/Design-methods.R
Comment thread R/Backfill-validity.R
@danielinteractive danielinteractive requested a review from Copilot May 13, 2026 09:40
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.

Pull request overview

Copilot reviewed 101 out of 103 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • man/ComboSimulations-class.Rd: Language not supported
Comments suppressed due to low confidence (2)

R/Rules-methods.R:3235

  • StoppingTargetProb uses isTRUE(is.na(dose)) to handle missing next dose, but for combination designs dose is a length-2 vector and this check will never be TRUE. This can cause prob() to be called with c(NA, NA) and produce errors/NA probabilities. Use all(is.na(dose)) (or equivalent) to guard the missing-dose case.
    prob_target <- ifelse(
      isTRUE(is.na(dose)),
      0,
      mean(
        prob(dose = dose, model, samples, ...) >= stopping@target[1] &
          prob(dose = dose, model, samples, ...) <= stopping@target[2]
      )

R/Rules-methods.R:3665

  • StoppingHighestDose uses isTRUE(is.na(dose)) to detect missing dose, but for DataCombo the dose is a length-2 vector. This check will not work and may treat c(NA, NA) as a real dose, resulting in incorrect is_highest_dose and messaging. Use all(is.na(dose)) (or an explicit length check) instead.
    is_highest_dose <- ifelse(
      isTRUE(is.na(dose)),
      FALSE,
      if (is_data_or_ordinal) {
        dose == data@doseGrid[data@nGrid]
      } else if (is_combo_data) {
        dose[1] == c(data@doseGrid[[1]][data@nGrid[1]]) &&
          dose[2] == c(data@doseGrid[[2]][data@nGrid[2]])
      } else {

Comment thread R/Rules-methods.R
Comment thread R/helpers_rules.R Outdated
Comment thread R/Simulations-methods.R Outdated
@danielinteractive danielinteractive merged commit b2bf482 into 936-combo-dev May 18, 2026
@danielinteractive danielinteractive deleted the 936-combo-fixed-prior branch May 18, 2026 13:04
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.

2 participants