Skip to content

Fix NAFLD/NASH model + Shiny app errors and improve navbar contrast#7

Open
mingushin3 wants to merge 2 commits into
mainfrom
fix/nafld-shiny-mrgsolve-and-navbar
Open

Fix NAFLD/NASH model + Shiny app errors and improve navbar contrast#7
mingushin3 wants to merge 2 commits into
mainfrom
fix/nafld-shiny-mrgsolve-and-navbar

Conversation

@mingushin3

Copy link
Copy Markdown

Summary

Fixes a chain of errors that prevented the NAFLD/NASH mrgsolve model and Shiny app from running under current package versions (mrgsolve 2.0.1, bslib 0.11.0), and improves navbar readability.

Changes

nafld_mrgsolve_model.R

  • Remove compartment names from the $CAPTURE block. mrgsolve ≥1.0 rejects compartments in $CAPTURE (their amounts are already returned automatically). Derived $TABLE variables are kept.

nafld_shiny_app.R

  • Remove compartment names from $CAPTURE (same rule).
  • $TABLE: use TIME instead of lowercase time, which collided with the C library time() function and broke C++ compilation.
  • Remove apostrophes from an in-model comment that prematurely closed the single-quoted R model string (caused an unexpected symbol parse error).
  • Hoist valueBox_shiny() above the ui object, since the UI calls it at build time (was defined after ui, causing could not find function).
  • Replace deprecated page_navbar(bg=) with navbar_options(bg=, theme=) (bslib ≥0.9.0).
  • Navbar contrast redesign: deep-maroon bar with light, legible tab labels; the active tab renders as a white pill with maroon text; brand title set to white. Styling injected via bs_add_rules().

Verification

  • Both model strings parse, compile, and simulate against the installed mrgsolve 2.0.1; removed compartments confirmed still present in the simulation output.
  • Shiny ui object builds and renders to HTML (Sass compiles) with no errors and no warnings; server is a valid function.

🤖 Generated with Claude Code

mingushin3 and others added 2 commits June 17, 2026 16:10
…ontrast

mrgsolve model (nafld_mrgsolve_model.R):
- Remove compartments from CAPTURE block (mrgsolve >=1.0 rejects them;
  compartment amounts are returned automatically)

Shiny app (nafld_shiny_app.R):
- Remove compartments from CAPTURE block
- TABLE: use TIME instead of lowercase time (collided with C library time())
- Remove apostrophes from an in-model comment that prematurely closed the
  single-quoted R model string (caused "unexpected symbol")
- Hoist valueBox_shiny() above the ui object (UI called it at build time)
- Replace deprecated page_navbar bg= with navbar_options(bg=, theme=)
- High-contrast navbar: deep-maroon bar, light tab labels, white-pill
  active tab, white brand title (via bs_add_rules)

Verified: both models parse, compile, and simulate; Shiny UI builds with
no errors or warnings.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…el for stability

req() error (Scenario Comparison / Endpoint Summary tabs):
- mrgsolve exports a req() S3 generic that masks shiny::req() (loaded earlier),
  so req(input$compare_arms) hit mrgsolve's generic -> "no applicable method
  for req applied to character". Qualified all four server calls as shiny::req().

Model divergence (placebo grew ~10x/week to ~1e+85):
- Root cause: disease pools were not initialized at their own steady state
  (absolute production terms) and the steatosis->Kupffer->TNFa->IR->DNL->fat
  positive-feedback loop was unbounded.
- Re-calibrated BOTH nafld_mrgsolve_model.R and nafld_shiny_app.R to
  steady-state-consistent indirect-response (turnover) form (kin = KOUT*baseline)
  with fold-change-normalized, saturable drivers and loop gain << 1
  (Dayneka 1993; Jusko & Ko 1994; Woo 2009; Angeli-Ferrell-Sontag 2004; Maldonado 2022).
- LIVER_FAT influx split into DNL + adipose-NEFA(weight); Kupffer drive saturable;
  ALT injury is now a sum (not product) of normalized drivers; collagen made the
  slowest pool. INS_RES/BODY_WT/ADIPONECTIN already correct (set-point form).
- Remapped the Fibrosis-tab sliders/param() to the new sensitivity names
  (GTGF_HSC, GHSC_COL, GLIP_KUP, GKUP_TGF) and adjusted ranges.
- Added nafld_model_design_brief.md documenting the literature basis.

Verified (R, mrgsolve 2.0.1): placebo flat to machine precision for all 11
states over 72 wk; perturbation recovers to baseline; no divergence in any arm;
drug directions clinically correct (resmetirom -40% liver fat ~ MAESTRO,
semaglutide lowers fat/HOMA-IR/weight & raises adiponectin, OCA lowers fibrosis,
triple best); fibrosis-tab live-param path works.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@shanmdphd

Copy link
Copy Markdown
Member

Thank you for your review and update.

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