Runnable example for the protocol manuscript "Profiling signatures of mutational processes using the SigProfiler suite".
The protocol is demonstrated in the paper on 37 lung adenocarcinomas from the PCAWG cohort. Those mutation calls are under controlled access, so this repository ships a synthetic dataset derived from them, together with the scripts for every step of the protocol and the output they produce. The point is to let you run the workflow end to end, check that your installation behaves, and compare your output.
input_example/somatic_mutation/LUAD_sim_data.maf holds 1,338,192 single-base substitutions across
37 samples.
It was produced with SigProfilerSimulator from the original tumours, simulating in the SBS-6144 context. The simulator randomises the genomic position of every mutation while preserving its mutational profile. Two consequences, and they matter:
- The mutational matrices are preserved. The SBS-96, SBS-288 and SBS-1536 matrices derived from this dataset are identical to those of the original tumours. Signature extraction, decomposition and assignment therefore reproduce the published results.
- The spatial distribution is destroyed. The dataset is a simulated null background, so it cannot demonstrate any method that looks at where mutations fall in the genome. That rules out clustered-mutation detection (SigProfilerClusters) and topographical analysis (SigProfilerTopography).
The MAF contains substitutions only. The ID-83, DBS-78, CNV-48 and SV-32 matrices used for plotting
are supplied ready-made in input_example/matrices/, and input_example/refitting/ holds a small
SBS-96 matrix for two samples used by the refitting step.
- Linux or macOS, with Conda or Mamba
- ~30 CPU cores. The extraction steps are the reason this is not a laptop workload
- ~15 GB of free disk: the GRCh37 reference installed by
step5.pytakes ~6 GB inside the environment, and the outputs take a few GB more - Network access on the first run, to download the reference genome and the COSMIC catalogue
./setup.shThat creates a Conda environment named sigprofiler with Python 3.10 and installs the seven
SigProfiler packages at the versions the paper was written against:
| Package | Version |
|---|---|
| SigProfilerMatrixGenerator | 1.3.6 |
| SigProfilerSimulator | 1.2.2 |
| SigProfilerClusters | 1.2.2 |
| SigProfilerExtractor | 1.4.1 |
| SigProfilerAssignment | 1.1.5 |
| SigProfilerTopography | 1.0.113 |
| SigProfilerPlotting | 1.4.3 |
./run_example.shRun it from anywhere: the script changes into the repository root itself. It executes every step
through conda run, so the environment does not need to be activated and it works from a batch job
on a cluster. It stops at the first error.
These are the steps it runs — the ones the synthetic data support:
| Step | Script | What it does |
|---|---|---|
| 5 | step5.py |
install GRCh37 and generate the mutational matrices |
| 8 | step8_288.py, step8_1536.py |
de novo extraction, SBS-288 and SBS-1536 |
| 10 | step10.py |
decomposition into COSMIC reference signatures |
| 11 | step11.py |
decomposition excluding signature subgroups |
| 12 | step12.py |
assignment of the de novo and of the decomposed signatures to samples |
| 13 | step13.py |
refitting the full COSMIC catalogue to two samples |
| 14 | step14.py |
assignment of signatures to individual mutations |
| 17 | step17.py |
SBS, ID, DBS, CN and SV profile plots |
Step 9, choosing the number of signatures, has no script: it is done by inspecting the selection plot and the solution statistics written by Step 8.
To run a single step instead:
conda run --name sigprofiler --no-capture-output python step5.pyScripts use paths relative to the repository root, so run them from there.
The example is whole-genome data, so every call that accepts an exome parameter sets
exome = False explicitly. For whole-exome data, set exome = True in all of them, and keep the same
setting across dependent steps.
Box1.py is an optional extra: the multimodal SBS+ID extraction described in Box 1 of the paper. It
needs step5.py to have run first, and it is not part of run_example.sh because it adds a second
full extraction. It writes LUAD_res/LUAD_US.SBS96_ID83.all and LUAD_US_extraction_multimodal/.
The SBS-96 and ID-83 components it produces can be decomposed into COSMIC reference signatures as in
step10.py, using LUAD_res/SBS/LUAD_US.SBS96.all and input_example/matrices/LUAD.ID83.all as the
samples matrices.
step6.py, step7.py, step15.py and step16.py are included for reference and run_example.sh
does not call them. SigProfilerClusters and SigProfilerTopography both compare the observed genomic
distribution of mutations against a simulated null background, and this dataset is that background:
there is no clustering to detect and no departure from the background to measure. These branches need
real somatic mutation data that retains its native spatial distribution.
Every directory below is created by the run and is excluded from version control.
LUAD_res/ step5 mutational matrices + GRCh37 install
LUAD_US_extraction_288/ step8 de novo extraction, SBS-288
LUAD_US_extraction_1536/ step8 de novo extraction, SBS-1536
LUAD_US_decomposition/ step10 decomposition into COSMIC signatures
LUAD_US_optimized_decomposition/ step11 decomposition excluding subgroups
LUAD_de_novo_decomposition/ step12 de novo signatures assigned to samples
LUAD_decomposed_assignment/ step12 decomposed signatures assigned to samples
LUAD_cosmic_refitting/ step13 COSMIC catalogue refitted to 2 samples
LUAD_decomposed_assignment_to_mutations/ step14 per-mutation signature probabilities
LUAD_plots/ step17 mutational profile plots
step14.py also creates input_example/somatic_mutation/input/ and
input_example/somatic_mutation/output/. These are intermediate files, not results.
Reference results are archived in expected_output.zip. They were produced by run_example.sh
followed by Box1.py, with the seed file described under Random seeds.
The figures in the paper come from the original PCAWG tumours, not from this example. Figure 2 cannot be reproduced from this dataset at all, because it depends on where mutations fall in the genome. The extraction and assignment results behind Figure 4 are reproduced in substance, but not to the last decimal — see below.
The scripts fix the random seed of the de novo extraction (see below), so repeated runs on the same computer give the same results. On a different computer exact values may still not reproduce. Signature counts, extracted profiles and assigned exposures should be very close; signature labels, their order, per-signature stability scores and the last decimal places of the activities may differ. Treat a different number of selected signatures as a result worth investigating, and small numerical differences as expected.
The three extraction scripts (step8_288.py, step8_1536.py and Box1.py) pass
seeds = "Seeds.txt" to SigProfilerExtractor, so every run starts from the same random seed instead
of a new random one. Seeds.txt is in the repository root, and all the archived extractions in
expected_output.zip were run with it. SigProfilerExtractor also copies the seed it used to
Seeds.txt inside each extraction output directory.
Warning. The fixed seed makes reruns on the same computer identical, but results can still change on a different computer (hardware, numerical libraries, number of CPU cores). Even with the same
Seeds.txt, the extracted signatures can then differ in the fifth decimal place, and such small differences can be enough to change which reference signatures are selected when a de novo signature is decomposed. For example, two runs of the SBS-288 extraction with the same seed decomposed SBS288B as SBS4 + SBS5 in one case and SBS4 + SBS5 + SBS92 in the other. Compare decompositions by their main components and their cosine similarity, not by an exact list of signatures.
conda: command not found — Conda is not on PATH. Install Miniconda, or load the module that
provides it on your cluster.
A step cannot find its input — the scripts use relative paths. Run them from the repository root,
or use run_example.sh, which changes into it.
Results differ from expected_output.zip — see Comparing your results with the archived
output. Check the package versions first: different SigProfiler releases default to different
COSMIC catalogue versions. On a different computer, a decomposition can gain or lose a reference
signature even with the fixed seed, when two similar reference signatures explain the de novo
signature almost equally well (see the warning under Random seeds).
A rerun behaves differently from the first run — delete the generated directories listed under
What the run produces, including input_example/somatic_mutation/input/ and
input_example/somatic_mutation/output/.