Skip to content

Add mutational signature analysis (SigProfilerMatrixGenerator + SigProfilerAssignment, CHM13-aware) - #190

Draft
ljwharbers wants to merge 2 commits into
devfrom
feat/mutational-signatures
Draft

Add mutational signature analysis (SigProfilerMatrixGenerator + SigProfilerAssignment, CHM13-aware)#190
ljwharbers wants to merge 2 commits into
devfrom
feat/mutational-signatures

Conversation

@ljwharbers

Copy link
Copy Markdown
Collaborator

Summary

Adds an optional mutational-signature step to lrsomatic. For every sample, the PASS SNVs/MNVs/indels of the phased somatic VCF are turned into SBS/DBS/ID mutational matrices with SigProfilerMatrixGenerator and fitted against COSMIC v3.6 reference signatures with SigProfilerAssignment (SBS96, DBS78, ID83). Output lands under <outdir>/<sample>/signatures/{matrices,assignment}.

Pipeline changes

  • PREPARE_SIGNATURES subworkflow: validates --sigprofiler_genome_dir (a SigProfilerMatrixGenerator volume containing tsb/<genome>/) or installs the ~3 GB payload with --download_sigprofiler_genome (published to <outdir>/cache/sigprofiler/volume for reuse, checksum-verified).
  • SIGNATURES_BCFTOOLS_VIEW (nf-core bcftools/view) writes the plain-text, PASS-only VCF SigProfilerMatrixGenerator needs (it ignores FILTER and cannot read bgzip).
  • SIGPROFILER_MATRIXGENERATOR and SIGPROFILER_ASSIGNMENT local modules; DBS78/ID83 fits are skipped when a sample has no such variants.
  • igenomes attributes sigprofiler_genome (GRCh38 / CHM13-T2T) and sigprofiler_genome_url (CHM13 only; the archive is not on the AlexandrovLab FTP yet).
  • Params: --skip_signatures, --sigprofiler_genome_dir, --download_sigprofiler_genome, --sigprofiler_cosmic_version, --sigprofiler_exclude_signature_subgroups, --sigprofiler_matrix_args, --sigprofiler_assignment_args. The test profile sets skip_signatures = true.
  • Docs (usage.md, output.md), CITATIONS.md, CHANGELOG.md, tests/.nftignore.

Why a custom image

CHM13 support is not in any SigProfiler release: SigProfilerMatrixGenerator gets it from SigProfilerSuite/SigProfilerMatrixGenerator#250 (under review; upstream will rebuild the archive), and SigProfilerAssignment has no CHM13 COSMIC files and silently falls back to GRCh37. The modules therefore run from ghcr.io/ljwharbers/sigprofiler:1.3.6-chm13-28a9ce8 (SIF: oras://ghcr.io/ljwharbers/sigprofiler-sif:1.3.6-chm13-28a9ce8), built by GitHub Actions on ljwharbers/SigProfilerMatrixGenerator@container/chm13 from that PR branch plus ljwharbers/SigProfilerAssignment@chm13-t2t-support, which adds COSMIC SBS/DBS signatures renormalised to the CHM13 trinucleotide/dinucleotide composition with the same method that produces the other builds' files. Return to biocontainers once both land upstream. Conda is not supported for these processes.

Validation

  • nextflow lint, pre-commit, targeted nf-core pipelines lint (schema/config/modules.json) pass; nextflow run -profile test -preview with signatures enabled resolves the new wiring.
  • BL1 (ONT, CHM13, ClairS-TO): replaying the module commands inside the published SIF analyses 24,817 SNVs / 58 DBS / 1,377 indels with 0 errors and fits SBS1 ≈ 2.9k + SBS5 ≈ 21.9k, matching the earlier CHM13 validation.
  • Full pipeline run with the step enabled is still to be done on the cluster (needs -profile ...,apptainer and a genome volume).

🤖 Generated with Claude Code

…ofilerAssignment)

New optional step after phasing: the PASS SNVs/MNVs/indels of each sample's
phased somatic VCF are turned into SBS/DBS/ID mutational matrices with
SigProfilerMatrixGenerator and fitted per sample against COSMIC reference
signatures with SigProfilerAssignment (SBS96, DBS78 and ID83). Results are
published under <outdir>/<sample>/signatures/{matrices,assignment}.

Wiring: PREPARE_SIGNATURES validates a user-supplied SigProfilerMatrixGenerator
volume (--sigprofiler_genome_dir, must contain tsb/<genome>/) or installs the
~3 GB genome payload on the fly (--download_sigprofiler_genome, published to
<outdir>/cache/sigprofiler/volume for reuse), SIGNATURES_BCFTOOLS_VIEW
(nf-core bcftools/view) writes the plain-text PASS-only VCF the tool needs,
then SIGPROFILER_MATRIXGENERATOR and SIGPROFILER_ASSIGNMENT run. The genome
name and payload URL are igenomes attributes (sigprofiler_genome = GRCh38 or
CHM13-T2T; sigprofiler_genome_url for CHM13, whose archive is not on the
AlexandrovLab FTP yet). --skip_signatures disables the step; the test profile
skips it because of the payload size.

CHM13 support is not in a SigProfiler release, so the modules run from
ghcr.io/ljwharbers/sigprofiler:1.3.6-chm13-28a9ce8 (SIF via
oras://ghcr.io/ljwharbers/sigprofiler-sif), which installs
SigProfilerMatrixGenerator from the branch behind
SigProfilerSuite/SigProfilerMatrixGenerator#250 and SigProfilerAssignment from
ljwharbers/SigProfilerAssignment@chm13-t2t-support, where COSMIC SBS/DBS
signatures renormalised to the CHM13 trinucleotide/dinucleotide composition
were added (stock SigProfilerAssignment silently falls back to GRCh37 for
CHM13). Conda is not supported for these processes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 4, 2026 12:39
…aths, PR number

Replaying the module commands on BL1 inside the published SIF showed that
sigProfilerPlotting caches its plot templates in the package directory
(SigProfilerAssignment does not forward --volume to it), which fails in an
immutable container; both modules now export SIGPROFILERPLOTTING_VOLUME to a
task-local directory. SigProfilerMatrixGenerator writes its logs under
output/logs, so the module and docs point there. CHANGELOG references #190.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

nf-core pipelines lint overall result: Passed ✅ ⚠️

Posted for pipeline commit 5c42cde

+| ✅ 205 tests passed       |+
#| ❔  22 tests were ignored |#
!| ❗  39 tests had warnings |!
Details

❗ Test warnings:

  • nextflow_config - Config manifest.version should end in dev: 1.1.0
  • pipeline_todos - TODO string in lint_log.txt: Named file extensions MUST be emitted for ALL output channels
  • pipeline_todos - TODO string in lint_log.txt: List additional required output channels/values here
  • pipeline_todos - TODO string in lint_log.txt: Named file extensions MUST be emitted for ALL output channels
  • pipeline_todos - TODO string in lint_log.txt: List additional required output channels/values here
  • pipeline_todos - TODO string in lint_log.txt: Named file extensions MUST be emitted for ALL output channels
  • pipeline_todos - TODO string in lint_log.txt: List additional required output channels/values here
  • pipeline_todos - TODO string in lint_log.txt: Named file extensions MUST be emitted for ALL output channels
  • pipeline_todos - TODO string in lint_log.txt: List additional required output channels/values here
  • pipeline_todos - TODO string in lint_log.txt: Named file extensions MUST be emitted for ALL output channels
  • pipeline_todos - TODO string in lint_log.txt: List additional required output channels/values here
  • pipeline_todos - TODO string in lint_log.txt: Named file extensions MUST be emitted for ALL output channels
  • pipeline_todos - TODO string in lint_log.txt: List additional required output channels/values here
  • pipeline_todos - TODO string in lint_log.txt: Named file extensions MUST be emitted for ALL output channels
  • pipeline_todos - TODO string in lint_log.txt: List additional required output channels/values here
  • pipeline_todos - TODO string in lint_log.txt: Named file extensions MUST be emitted for ALL output channels
  • pipeline_todos - TODO string in lint_log.txt: List additional required output channels/values here
  • pipeline_todos - TODO string in README.md: Include a figure that guides the user through the major workflow steps. Many nf-core
  • pipeline_todos - TODO string in nextflow.config: Specify your pipeline's command line flags
  • pipeline_todos - TODO string in nextflow.config: Update the field with the details of the contributors to your pipeline. New with Nextflow version 24.10.0
  • pipeline_todos - TODO string in nextflow.config: Specify any additional parameters here
  • pipeline_todos - TODO string in CONTRIBUTING.md: Add any pipeline specific contribution guidelines here, such as coding styles, procedures, checklists etc.
  • pipeline_todos - TODO string in base.config: Check the defaults for all processes
  • pipeline_todos - TODO string in base.config: Customise requirements for specific processes.
  • pipeline_todos - TODO string in meta.yml: #Add a description of the module and list keywords
  • pipeline_todos - TODO string in methods_description_template.yml: #Update the HTML below to your preferred methods description, e.g. add publication citation for this pipeline
  • schema_description - Ungrouped param in schema: skip_modkit
  • schema_description - No description provided in schema for parameter: generate_gvcf
  • schema_description - No description provided in schema for parameter: autocorrelation
  • schema_description - No description provided in schema for parameter: vep_custom
  • schema_description - No description provided in schema for parameter: vep_custom_tbi
  • schema_description - No description provided in schema for parameter: severus_minsupport
  • schema_description - No description provided in schema for parameter: wakhan_chroms
  • local_component_structure - deepsomatic.nf in subworkflows/local should be moved to a SUBWORKFLOW_NAME/main.nf structure
  • local_component_structure - prepare_reference_files.nf in subworkflows/local should be moved to a SUBWORKFLOW_NAME/main.nf structure
  • local_component_structure - small_variant_consensus.nf in subworkflows/local should be moved to a SUBWORKFLOW_NAME/main.nf structure
  • local_component_structure - prepare_annotation.nf in subworkflows/local should be moved to a SUBWORKFLOW_NAME/main.nf structure
  • local_component_structure - prepare_signatures.nf in subworkflows/local should be moved to a SUBWORKFLOW_NAME/main.nf structure
  • local_component_structure - phasing_haplotyping.nf in subworkflows/local should be moved to a SUBWORKFLOW_NAME/main.nf structure

❔ Tests ignored:

  • files_exist - File is ignored: CODE_OF_CONDUCT.md
  • files_exist - File is ignored: assets/nf-core-lrsomatic_logo_light.png
  • files_exist - File is ignored: docs/images/nf-core-lrsomatic_logo_light.png
  • files_exist - File is ignored: docs/images/nf-core-lrsomatic_logo_dark.png
  • files_exist - File is ignored: .github/ISSUE_TEMPLATE/config.yml
  • files_exist - File is ignored: .github/workflows/awstest.yml
  • files_exist - File is ignored: .github/workflows/awsfulltest.yml
  • files_exist - File is ignored: .github/CONTRIBUTING.md
  • nextflow_config - Config variable ignored: manifest.name
  • nextflow_config - Config variable ignored: manifest.homePage
  • files_unchanged - File ignored due to lint config: CODE_OF_CONDUCT.md
  • files_unchanged - File ignored due to lint config: .github/ISSUE_TEMPLATE/bug_report.yml
  • files_unchanged - File ignored due to lint config: .github/PULL_REQUEST_TEMPLATE.md
  • files_unchanged - File ignored due to lint config: .github/workflows/branch.yml
  • files_unchanged - File ignored due to lint config: .github/workflows/linting_comment.yml
  • files_unchanged - File ignored due to lint config: .github/workflows/linting.yml
  • files_unchanged - File ignored due to lint config: assets/email_template.txt
  • files_unchanged - File ignored due to lint config: assets/nf-core-lrsomatic_logo_light.png
  • files_unchanged - File ignored due to lint config: docs/images/nf-core-lrsomatic_logo_light.png
  • files_unchanged - File ignored due to lint config: docs/images/nf-core-lrsomatic_logo_dark.png
  • files_unchanged - File ignored due to lint config: docs/README.md
  • actions_awstest - 'awstest.yml' workflow not found: /home/runner/work/lrsomatic/lrsomatic/.github/workflows/awstest.yml

✅ Tests passed:

Run details

  • nf-core/tools version 4.0.2
  • Run at 2026-09-04 12:43:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

There are a few concrete runtime/configuration issues (notably path collection/type, process selector matching, and missing volume directory creation) that should be fixed before the new signatures step can be considered reliable.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds an optional mutational-signature analysis stage to the lrsomatic Nextflow pipeline, generating SigProfiler mutational matrices (SBS/DBS/ID) from PASS variants and fitting COSMIC reference signatures with CHM13-T2T awareness.

Changes:

  • Introduces a PREPARE_SIGNATURES subworkflow plus local SIGPROFILER_* modules to install/validate SigProfiler genomes, generate matrices, and run COSMIC fitting.
  • Wires a PASS-only, plain-text VCF export via an nf-core bcftools/view module to satisfy SigProfilerMatrixGenerator input requirements.
  • Extends params, iGenomes config, docs, citations, and test ignore patterns to support the new outputs and CHM13-specific payload handling.
File summaries
File Description
workflows/lrsomatic.nf Wires the new signatures subworkflow and modules into the main pipeline.
tests/.nftignore Ignores signature outputs in nf-test comparisons.
subworkflows/local/prepare_signatures.nf New subworkflow to validate or install SigProfiler genome payloads.
nextflow.config Adds default params for signature analysis toggles and options.
nextflow_schema.json Adds schema entries for signature-related parameters and skip flag.
modules/nf-core/bcftools/view/tests/vcf_gz_index.config Adds nf-test config coverage for indexed gz outputs.
modules/nf-core/bcftools/view/tests/vcf_gz_index_tbi.config Adds nf-test config coverage for TBI index output.
modules/nf-core/bcftools/view/tests/vcf_gz_index_csi.config Adds nf-test config coverage for CSI index output.
modules/nf-core/bcftools/view/tests/nextflow.config Adds default test config for bcftools/view module tests.
modules/nf-core/bcftools/view/tests/main.nf.test.snap Adds snapshot expectations for bcftools/view module tests.
modules/nf-core/bcftools/view/tests/main.nf.test Adds nf-test suite for bcftools/view module.
modules/nf-core/bcftools/view/meta.yml Adds nf-core module metadata for bcftools/view.
modules/nf-core/bcftools/view/main.nf Adds the bcftools/view module implementation.
modules/nf-core/bcftools/view/environment.yml Adds conda environment for bcftools/view module.
modules/local/sigprofiler/matrixgenerator/meta.yml Adds metadata for SigProfilerMatrixGenerator local module.
modules/local/sigprofiler/matrixgenerator/main.nf Implements matrix generation module using custom SigProfiler image.
modules/local/sigprofiler/install/meta.yml Adds metadata for SigProfiler genome payload install module.
modules/local/sigprofiler/install/main.nf Implements genome payload download/install + verification module.
modules/local/sigprofiler/assignment/meta.yml Adds metadata for SigProfilerAssignment local module.
modules/local/sigprofiler/assignment/main.nf Implements COSMIC fitting module (SBS/DBS/ID).
modules.json Registers new nf-core module dependency (bcftools/view).
docs/usage.md Documents signature parameters, payload requirements, and CHM13 specifics.
docs/output.md Documents the new per-sample signatures/ output structure and contents.
conf/test.config Disables signatures by default in the test profile.
conf/modules.config Adds process-specific configuration/publishing for signature steps.
conf/igenomes.config Adds iGenomes attributes for SigProfiler genomes and CHM13 URL.
CITATIONS.md Adds citations for SigProfilerAssignment and SigProfilerMatrixGenerator.
CHANGELOG.md Adds changelog entry for the new signature analysis feature.
Review details
  • Files reviewed: 28/28 changed files
  • Comments generated: 9
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +63 to +64
mkdir -p ${prefix}
${fits}
if (n_chrom < 24) {
error("${tsb_dir} holds ${n_chrom} chromosome files; a complete SigProfilerMatrixGenerator install of ${genome} has 24 (1-22, X, Y).")
}
sigprofiler_volume = channel.fromPath(genome_dir, type: 'dir', checkIfExists: true).collect()
Comment thread conf/modules.config
///////////////////////////
// Mutational signatures //
///////////////////////////
withName: 'SIGPROFILER_INSTALL' {
Comment thread workflows/lrsomatic.nf
Comment on lines +104 to +105
params.sigprofiler_genome = getGenomeAttribute('sigprofiler_genome')
params.sigprofiler_genome_url = getGenomeAttribute('sigprofiler_genome_url')
Comment thread CHANGELOG.md Outdated

### `Added`

- [#XXX](https://github.com/IntGenomicsLab/lrsomatic/pull/XXX) - Added mutational signature analysis: SigProfilerMatrixGenerator matrices (SBS/DBS/ID) and per-sample COSMIC signature fitting with SigProfilerAssignment on the phased somatic VCF, with CHM13-T2T support via a purpose-built image (`ghcr.io/ljwharbers/sigprofiler`) and CHM13-renormalised COSMIC signatures; new `--sigprofiler_*` / `--download_sigprofiler_genome` / `--skip_signatures` parameters (@ljwharbers).
Comment on lines +9 to +11
container "${workflow.containerEngine == 'singularity' || workflow.containerEngine == 'apptainer'
? 'oras://ghcr.io/ljwharbers/sigprofiler-sif:1.3.6-chm13-28a9ce8'
: 'ghcr.io/ljwharbers/sigprofiler:1.3.6-chm13-28a9ce8'}"
Comment on lines +10 to +12
container "${workflow.containerEngine == 'singularity' || workflow.containerEngine == 'apptainer'
? 'oras://ghcr.io/ljwharbers/sigprofiler-sif:1.3.6-chm13-28a9ce8'
: 'ghcr.io/ljwharbers/sigprofiler:1.3.6-chm13-28a9ce8'}"
Comment on lines +9 to +11
container "${workflow.containerEngine == 'singularity' || workflow.containerEngine == 'apptainer'
? 'oras://ghcr.io/ljwharbers/sigprofiler-sif:1.3.6-chm13-28a9ce8'
: 'ghcr.io/ljwharbers/sigprofiler:1.3.6-chm13-28a9ce8'}"
Comment thread nextflow.config
Comment on lines +46 to +52
// Mutational signatures (SigProfiler)
sigprofiler_genome_dir = null
download_sigprofiler_genome = false
sigprofiler_cosmic_version = 3.6
sigprofiler_exclude_signature_subgroups = null
sigprofiler_matrix_args = '--plot'
sigprofiler_assignment_args = null
Copilot AI review requested due to automatic review settings September 4, 2026 12:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

A few correctness/convention issues around parameter override behavior and Singularity/Apptainer container selection need to be addressed to avoid unexpected runtime behavior across execution environments.

Review details

Suppressed comments (4)

workflows/lrsomatic.nf:105

  • These assignments always overwrite any user-supplied --sigprofiler_genome / --sigprofiler_genome_url values, which contradicts the docs’ claim that genome-derived attributes can be overridden for custom references. Prefer only populating from iGenomes when the param is unset.
    params.sigprofiler_genome = getGenomeAttribute('sigprofiler_genome')
    params.sigprofiler_genome_url = getGenomeAttribute('sigprofiler_genome_url')

modules/local/sigprofiler/install/main.nf:12

  • Container selection for Singularity/Apptainer should respect task.ext.singularity_pull_docker_container (repository convention) so users can force pulling the OCI image instead of the ORAS SIF when needed (e.g. older Apptainer without ORAS). See e.g. modules/nf-core/samtools/merge/main.nf:6-8.
    container "${workflow.containerEngine == 'singularity' || workflow.containerEngine == 'apptainer'
        ? 'oras://ghcr.io/ljwharbers/sigprofiler-sif:1.3.6-chm13-28a9ce8'
        : 'ghcr.io/ljwharbers/sigprofiler:1.3.6-chm13-28a9ce8'}"

modules/local/sigprofiler/matrixgenerator/main.nf:11

  • Container selection for Singularity/Apptainer should respect task.ext.singularity_pull_docker_container (repository convention) so users can force pulling the OCI image instead of the ORAS SIF when needed (e.g. older Apptainer without ORAS). See e.g. modules/nf-core/samtools/merge/main.nf:6-8.
    container "${workflow.containerEngine == 'singularity' || workflow.containerEngine == 'apptainer'
        ? 'oras://ghcr.io/ljwharbers/sigprofiler-sif:1.3.6-chm13-28a9ce8'
        : 'ghcr.io/ljwharbers/sigprofiler:1.3.6-chm13-28a9ce8'}"

modules/local/sigprofiler/assignment/main.nf:11

  • Container selection for Singularity/Apptainer should respect task.ext.singularity_pull_docker_container (repository convention) so users can force pulling the OCI image instead of the ORAS SIF when needed (e.g. older Apptainer without ORAS). See e.g. modules/nf-core/samtools/merge/main.nf:6-8.
    container "${workflow.containerEngine == 'singularity' || workflow.containerEngine == 'apptainer'
        ? 'oras://ghcr.io/ljwharbers/sigprofiler-sif:1.3.6-chm13-28a9ce8'
        : 'ghcr.io/ljwharbers/sigprofiler:1.3.6-chm13-28a9ce8'}"
  • Files reviewed: 28/28 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

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