Repository navigation
fix(nomogram): build survival models on the full cohort (unblocks main deploy) - #429
Merged
Merged
Conversation
Main's quarto-publish has been failing since the #417 renv refresh: regplot's model.frame re-evaluation on Clinics/Nomogram.qmd errored with "factor stage has new levels Stage IVA" under newer survival releases. Root cause: the cohort's time column used only days_to_death, so every censored patient (Alive, time = NA) was silently dropped by coxph/psm. The single Stage IVA patient is censored, so the level disappeared from the fitted model's xlevels; when regplot re-evaluates model.frame against the full LIHC frame, the stricter survival check rejects the unseen level. Fix the data preparation instead of the symptom: analysis time is days_to_death for dead patients and days_to_last_follow_up for censored patients, then drop rows without a usable positive time. This restores all 259 censored patients to the Cox/AFT fits (the models were previously fit on the 172 dead patients only), keeps every stage level in the model, and makes regplot render again. Verified end-to-end locally: all 8 chunks of the patched tutorial execute under R 4.5.2 / survival 3.8.6 / regplot master.
Contributor
✅ QMD Format Check✅ All 1 checked QMD file(s) pass format validation!
|
regplot's added.obs() calls model.frame(fit, data=app). Newer survival (>=3.8.x in renv.lock) evaluates the coxph call in environment(fit$terms) — set by rms::datadist — where the appended data frame does not exist, raising "object 'app' not found". Storing the model frame via model=TRUE lets model.frame.coxph short-circuit on fit$model.
survival 3.8's model.frame.coxph evaluates the rebuilt model.frame call in environment(fit$terms) whose parent is the global env, so the data symbol it receives must exist there verbatim. regplot's added.obs() only creates app inside its own scope, hence 'object app not found'. Pre-binding app <- rbind(observation, LIHC) in the chunk works around it. Verified locally with survival 3.8-12 + regplot@3ee4817.
Contributor
✅ QMD Format Check✅ All 1 checked QMD file(s) pass format validation!
|
Contributor
📊 Quarto Render PreviewThe new or modified Quarto files have been rendered and are available as artifacts. 🔗 View and Download Rendered Files Click the link above, scroll to the "Artifacts" section at the bottom of the page, and download Modified files: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
main's quarto-publish has been failing since #417 (renv refresh) atClinics/Nomogram.qmd:Root cause: the tutorial's
timecolumn used onlydays_to_death, so every censored patient (Alive,time = NA) was silently dropped bycoxph/psm. The single Stage IVA patient is censored, so that level vanished from the fitted model'sxlevels; whenregplotre-evaluatesmodel.frameagainst the full LIHC frame, the strictersurvivalcheck rejects the unseen level.Fix: derive analysis time properly —
days_to_deathfor dead patients,days_to_last_follow_upfor censored ones — and drop rows without a positive time. This:Verification
Nomogram.qmdexecuted end-to-end locally (R 4.5.2, survival 3.8.6, regplot master), including the previously failingfig-2.2BeautifyNomogram.Why this PR first
This same failure aborts the full site render for any PR touching
.qmdfiles, including #426/#428. Merging this first unblocks main's deployments and those PRs.