Skip to content

Refactor Run_Mod.R, improve Chapter2.qmd: extract helper, fix style, and address review comments#186

Draft
Copilot wants to merge 5 commits intochapter2-qmdfrom
copilot/sub-pr-133
Draft

Refactor Run_Mod.R, improve Chapter2.qmd: extract helper, fix style, and address review comments#186
Copilot wants to merge 5 commits intochapter2-qmdfrom
copilot/sub-pr-133

Conversation

Copy link
Contributor

Copilot AI commented Jan 31, 2026

Addresses code review feedback on the Chapter 2 Kronecker model integration.

Refactoring

  • Extract build_kron_priors(): Encapsulates Kronecker prior assembly (clean base priors, add Wishart hyperparameters, inject n_blocks scalar)
  • Hoist common prep_priors() call: Moves shared logic outside the correlated if-else branch

Style fixes

  • Format long function calls per tidyverse guide (one argument per line)
  • Fix line length violations in error messages
  • Add proper @seealso cross-references with bracket notation

Cleanup

  • Fix typo: 'model.If' → 'model. If' in documentation
  • Remove obsolete examples-run_mod_kron.R (function was merged into run_mod())

Chapter2.qmd Documentation Improvements

  • Filled in missing sections: Added comprehensive list of helper functions now in the package (Step B), expanded E.3 with clear run_mod() usage explanation
  • Enhanced explanations: Rewrote Wishart hyperparameters section for better understanding, clarified distinction between independence and correlated models
  • Better code examples: Added side-by-side model comparison, examples for customizing hyperparameters, code for visualizing results
  • Structural improvements: Clear flow from simulation → baseline → theory → implementation → examples, clarified which functions are in package vs inline code
  • Mathematical precision: Specified conditions for Wishart expectation approximation, clarified conflicting fields in clean_priors()

Result

# Before: duplicated prep_priors() + manual assembly
if (!correlated) {
  priorspec <- prep_priors(max_antigens = ..., ...)
  ...
} else {
  base_priors <- prep_priors(max_antigens = ..., ...)
  base_priors <- clean_priors(base_priors)
  kron_priors <- prep_priors_multi_b(n_blocks = ...)
  B_scalar <- list(n_blocks = ...)
  priorspec <- c(base_priors, kron_priors, B_scalar)
  ...
}

# After: single prep_priors() + helper
base_priors <- prep_priors(max_antigens = ..., ...)

if (!correlated) {
  priorspec <- base_priors
  ...
} else {
  priorspec <- build_kron_priors(base_priors, n_blocks = ...)
  ...
}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 31, 2026 08:00
Co-authored-by: Kwan-Jenny <68584166+Kwan-Jenny@users.noreply.github.com>
Co-authored-by: Kwan-Jenny <68584166+Kwan-Jenny@users.noreply.github.com>
Copilot AI changed the title [WIP] Add chapter2.qmd for fake data simulation and model setup Refactor Run_Mod.R: extract helper, fix style, and address review comments Jan 31, 2026
Copilot AI requested a review from Kwan-Jenny January 31, 2026 08:04
@Kwan-Jenny
Copy link
Collaborator

@copilot,

Could you please review the Chapter2.qmd file once more and revise it to improve clarity and structure, ensuring that it aligns with d-morrison’s feedback?

Co-authored-by: Kwan-Jenny <68584166+Kwan-Jenny@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 31, 2026

@copilot,

Could you please review the Chapter2.qmd file once more and revise it to improve clarity and structure, ensuring that it aligns with d-morrison’s feedback?

I've revised Chapter2.qmd to improve clarity and structure. Changes in commit 888e930:

Major improvements:

  • Filled in empty "Step B" section with list of helper functions now in the package
  • Expanded "E.3" section with clear explanation of run_mod() unified interface
  • Rewrote Wishart hyperparameters section for better understanding
  • Improved "Putting it together" with side-by-side independence vs correlated model examples
  • Added code examples for customizing hyperparameters and comparing results
  • Clarified automatic vs explicit model file creation

Structure changes:

  • Made it clear which functions are now in the package (not inline)
  • Added better navigation between sections
  • Improved mathematical notation consistency
  • Added practical usage examples throughout

The document now flows more logically from simulation → independence model → correlated model theory → unified interface → complete examples.

Co-authored-by: Kwan-Jenny <68584166+Kwan-Jenny@users.noreply.github.com>
Copilot AI changed the title Refactor Run_Mod.R: extract helper, fix style, and address review comments Refactor Run_Mod.R, improve Chapter2.qmd: extract helper, fix style, and address review comments Jan 31, 2026
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