Add mutational signature analysis (SigProfilerMatrixGenerator + SigProfilerAssignment, CHM13-aware) - #190
Add mutational signature analysis (SigProfilerMatrixGenerator + SigProfilerAssignment, CHM13-aware)#190ljwharbers wants to merge 2 commits into
Conversation
…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>
…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>
|
There was a problem hiding this comment.
🟡 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_SIGNATURESsubworkflow plus localSIGPROFILER_*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/viewmodule 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.
| 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() |
| /////////////////////////// | ||
| // Mutational signatures // | ||
| /////////////////////////// | ||
| withName: 'SIGPROFILER_INSTALL' { |
| params.sigprofiler_genome = getGenomeAttribute('sigprofiler_genome') | ||
| params.sigprofiler_genome_url = getGenomeAttribute('sigprofiler_genome_url') |
|
|
||
| ### `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). |
| 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'}" |
| 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'}" |
| 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'}" |
| // 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 |
There was a problem hiding this comment.
🔵 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_urlvalues, 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
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_SIGNATURESsubworkflow: validates--sigprofiler_genome_dir(a SigProfilerMatrixGenerator volume containingtsb/<genome>/) or installs the ~3 GB payload with--download_sigprofiler_genome(published to<outdir>/cache/sigprofiler/volumefor reuse, checksum-verified).SIGNATURES_BCFTOOLS_VIEW(nf-corebcftools/view) writes the plain-text, PASS-only VCF SigProfilerMatrixGenerator needs (it ignores FILTER and cannot read bgzip).SIGPROFILER_MATRIXGENERATORandSIGPROFILER_ASSIGNMENTlocal modules; DBS78/ID83 fits are skipped when a sample has no such variants.sigprofiler_genome(GRCh38/CHM13-T2T) andsigprofiler_genome_url(CHM13 only; the archive is not on the AlexandrovLab FTP yet).--skip_signatures,--sigprofiler_genome_dir,--download_sigprofiler_genome,--sigprofiler_cosmic_version,--sigprofiler_exclude_signature_subgroups,--sigprofiler_matrix_args,--sigprofiler_assignment_args. The test profile setsskip_signatures = true.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 onljwharbers/SigProfilerMatrixGenerator@container/chm13from that PR branch plusljwharbers/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, targetednf-core pipelines lint(schema/config/modules.json) pass;nextflow run -profile test -previewwith signatures enabled resolves the new wiring.-profile ...,apptainerand a genome volume).🤖 Generated with Claude Code