Skip to content

MNV handling — predefined_dbs_mbs flag + zero-variant safety - #14

Merged
qclayssen merged 27 commits into
mainfrom
mnv-handling
Jul 3, 2026
Merged

qclayssen merged 27 commits into
mainfrom
mnv-handling

Conversation

@qclayssen

@qclayssen qclayssen commented Oct 16, 2025 •

Copy link
Copy Markdown
Contributor

See sash issue #34

Changes

predefined_dbs_mbs flag

  • Add --predefined-dbs-mbs CLI flag and predefined_dbs_mbs parameter (default FALSE)
  • When TRUE, uses PAVE-annotated DBS directly instead of auto-merging adjacent SNVs
  • Handle MBS separately with dedicated plot and table output

Zero-variant safety (DBS/MBS)

  • sig_count_dbs: early-return zero matrix when no DBS variants present
  • sig_contribution: skip NNLS fitting on zero input
  • sig_plot_dbs: return blank placeholder PNGs ("No DBS variants found") so downstream readPNG always succeeds
  • Guard zero-variant edge cases throughout; move glue/tibble to Imports

Tests

  • Unit tests for zero-variant paths and sig_mbs_table

Fixes

  • Use bare cosmic_signatures_2015 inside package (not sigrap:: prefix)
  • Version bump to 0.3.0

Copilot AI left a comment

Copy link
Copy Markdown

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 adds support for handling multi-base substitutions (MBS) alongside existing DBS/SNV/INDEL workflows and adjusts DBS handling to use predefined variant annotations. It also updates SNV plotting defaults and integrates MBS plotting and JSON export into the workflow.

  • Add MBS counting, plotting, and JSON table export; integrate into sig_workflow_run
  • Use predefined_dbs_mbs = TRUE when extracting DBS (and MBS) from VCF
  • Update SNV rainfall default to FALSE and add logging for counting steps

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
man/sig_workflow_run.Rd Documents workflow function; adds predefined_dbs_mbs argument description but not reflected in usage/signature.
man/sig_plot_snv.Rd Updates function usage to include rainfall = FALSE and corrects default in docs.
man/sig_plot_mbs.Rd Adds docs for new sig_plot_mbs; output description appears inconsistent with code (list vs single plot).
man/sig_mbs_table.Rd Adds docs for new sig_mbs_table used for JSON export.
man/sig_count_mbs.Rd Adds docs for new sig_count_mbs; argument list/docs inconsistent with function signature/behavior.
R/mutationalpatterns.R Implements MBS count/plot/table; updates DBS counting to use predefined_dbs_mbs; integrates MBS into workflow and output; adds logging.
NAMESPACE Exports new MBS-related functions.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread R/mutationalpatterns.R Resolved
Comment thread R/mutationalpatterns.R Resolved
Comment thread R/mutationalpatterns.R Resolved
Comment thread R/mutationalpatterns.R Resolved
Comment thread man/sig_plot_mbs.Rd Resolved
Comment thread man/sig_count_mbs.Rd Resolved
Comment thread man/sig_count_mbs.Rd Resolved
Comment thread man/sig_workflow_run.Rd Resolved
Comment thread man/sig_count_mbs.Rd Resolved
@qclayssen qclayssen mentioned this pull request Jan 21, 2026
qclayssen added 4 commits May 22, 2026 11:46
sig_count_dbs: early-return all-zero matrix when no DBS variants found,
avoiding colnames<- crash inside get_dbs_context/count_dbs_contexts.

sig_contribution: skip fit_to_signatures on zero-sum input (degenerate
for NNLS), reuse existing No Signatures found! path and column transform.

Reproduces the SIGRAP_MUTPAT failure seen in sash 0.7.0 cohort runs
where filtered PASS VCF has no DBS variants (e.g. APGI GARV_0658).
Fixes sash#34.
Three changes in mutationalpatterns.R:

sig_count_dbs: early return all-zero matrix before get_dbs_context /
count_dbs_contexts are called, which crash with colnames<- error on
empty input. Matrix uses correct 78-context layout from get_known_signatures.

sig_plot_dbs: return blank 'No DBS variants found' plots when all counts
are zero, so gpgr can always find plot/dbs/*.png via readPNG.

sig_contribution: skip fit_to_signatures on zero-sum input (degenerate
for NNLS), reuse existing No Signatures found path and column transform.

Root cause: --predefined-dbs-mbs (added in sash 0.7.0) counts only
explicitly annotated DBS variants. Samples with no DBS annotations
(e.g. PDAC cohort GARV_0658) now correctly complete without crashing.
Fixes sash#34.
- sig_plot_mbs: return placeholder ggplot when sum(mbs_counts) == 0
- sig_contribution: guard RelFreq division by zero (NaN -> 0)
- sigrap::cosmic_signatures_2015 replaces fragile get() call
- Replace em-dash characters with -- in comments
- Move glue and tibble from Suggests to Imports (used unconditionally)
Covers sig_contribution (NaN guard), sig_plot_dbs, sig_plot_mbs (zero
placeholder), sig_mbs_table (empty + counts + matrix input).
@qclayssen qclayssen changed the title Mnv handling MNV handling — predefined_dbs_mbs flag + zero-variant safety May 22, 2026
@qclayssen
qclayssen merged commit b8125b6 into main Jul 3, 2026
1 check passed
@qclayssen
qclayssen deleted the mnv-handling branch July 3, 2026 06:02
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.

3 participants