Skip to content

Fix crash from factor sample.class and sparse tmb tables (#11) - #12

Open
Arvindiyer wants to merge 1 commit into
mainfrom
fix/issue-11-factor-sample-class-and-sparse-tmb
Open

Fix crash from factor sample.class and sparse tmb tables (#11)#12
Arvindiyer wants to merge 1 commit into
mainfrom
fix/issue-11-factor-sample-class-and-sparse-tmb

Conversation

@Arvindiyer

Copy link
Copy Markdown
Member

Summary

  • get.blocks() lost sample names when sample.class/alteration.class was a factor, because which() drops names on a named-factor comparison but not a named-character one. The resulting unnamed blocks propagated into 0-column matrices in template.obj.gen()/generateW_block(), which crashed retrieveOutliers() with "replacement has length zero" several steps downstream.
  • Separately, new.AL.general() summed am$tmb tables by raw vector position, so a tmb table covering only a subset of samples (e.g. only samples with >=1 mutation of a given type) got silently recycled instead of matched by sample identity, corrupting TMB totals without erroring.
  • Both are now handled at ingestion in new.AL.general(): factor covariates are auto-coerced to character, and every tmb table is aligned to the full sample set by name with missing samples zero-filled. Unknown sample ids or duplicate entries in a tmb table now raise a clear error instead of being silently mishandled.

Test plan

  • devtools::test() — 24/24 passing, including the existing golden LUAD regression test unchanged
  • devtools::check() — 0 errors, 0 warnings, 0 notes
  • New tests added in tests/testthat/test-new.AL.general-robustness.R covering factor sample.class, sparse tmb zero-filling, and the new unknown-sample-id error
  • Re-ran the reporter's original repro shape (factor sample.class + sparse tmb) — completes cleanly with no error/warning

Fixes #11

get.blocks() lost sample names when sample.class/alteration.class was
a factor, because which() drops names on a named-factor comparison but
not a named-character one. The resulting unnamed blocks propagated
into 0-column matrices in template.obj.gen()/generateW_block(), which
crashed retrieveOutliers() with "replacement has length zero" several
steps downstream.

Separately, new.AL.general() summed am$tmb tables by raw vector
position, so a tmb table covering only a subset of samples (e.g. only
samples with >=1 mutation of a given type) got silently recycled
instead of matched by sample identity, corrupting TMB totals without
erroring.

Both are now handled at ingestion in new.AL.general(): factor
covariates are auto-coerced to character, and every tmb table is
aligned to the full sample set by name with missing samples zero-filled.
Unknown sample ids or duplicate entries in a tmb table now raise a
clear error instead of being silently mishandled.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Arvindiyer Arvindiyer self-assigned this Sep 10, 2026
@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 4c00fa1e-b78d-474f-8b3e-3c48cf4d5d34


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

[BUG] Error in the simulation outlier step

1 participant