nf-core/deepmutscan
nf-core/deepmutscan is a reproducible, scalable, and community-curated pipeline for analyzing deep mutational scanning (DMS) data using shotgun DNA sequencing.
Introduction
nf-core/deepmutscan is a workflow for the analysis of deep mutational scanning (DMS) data. It takes short-read next-generation DNA sequencing data of a site-saturation mutagenesis library – typically before (input) and after (output) a variant selection experiment – and turns them into quality-controlled, error-corrected variant frequencies and, optionally, relative variant fitness estimates.
The pipeline was mainly designed for shotgun sequencing of long open reading frames (ORFs), where the mutated gene is randomly fragmented before sequencing and where resulting variant count signals are sparse, but it processes amplicon (tile) sequencing data in the same way.
This page explains how to prepare the inputs, how to run the pipeline, and what each processing step does and why. It is intended both for new DMS users and for developers who want to understand the exact design choices.
Samplesheet input
You will need to create a samplesheet with information about the sequencing libraries you would like to analyse before running the pipeline. Use the --input parameter to specify its location. It has to be a comma-separated file with 5 columns and a header row, as shown in the example below.
--input '[path to samplesheet file]'sample,type,replicate,file1,file2ORF1,input,1,/reads/input1_R1.fastq.gz,/reads/input1_R2.fastq.gzORF1,input,2,/reads/input2_R1.fastq.gz,/reads/input2_R2.fastq.gzORF1,output,1,/reads/output1_R1.fastq.gz,/reads/output1_R2.fastq.gzORF1,output,2,/reads/output2_R1.fastq.gz,/reads/output2_R2.fastq.gz| Column | Description |
|---|---|
sample |
Name of the biological sample or experiment (e.g. the gene or condition). Must not contain spaces or /. As of v1.0.0, all rows of a samplesheet must have the same sample; analyse several samples in separate runs. |
type |
Role of the library: input (before selection), output (after selection) or wildtype (deep sequencing of the unmutated template, used by --error_correction wildtype). |
replicate |
Replicate number (positive integer). For fitness estimation, input and output libraries are paired by replicate number, so both need the same replicate numbers (e.g. 1, 2, 3). |
file1 |
Full path to the FASTQ file for read 1, with extension .fastq.gz, .fq.gz, .fastq or .fq. |
file2 |
Full path to the FASTQ file for read 2, with extension .fastq.gz, .fq.gz, .fastq or .fq. As of v1.0.0, paired-end reads are required. |
Each combination of sample, type and replicate may appear only once. Each library gets an internal identifier <sample>_<type>_<replicate>_pe, which is used to name its output files and folders.
The samplesheet is checked when the pipeline starts, and the run stops with an error message naming the problem if, for example, a file is missing, a row is duplicated or the replicate numbers of input and output libraries do not match.
The FASTQ files themselves are checked in two steps, before any reads are processed. Problems are collected across all libraries and reported together, so that all faulty files can be replaced at once.
- At start-up, from the first read of each file: a file is empty, is named
.gzbut is not gzip-compressed, or is not in FASTQ format;file1andfile2are the same file, start with the same read, or start with reads of different names; a file is used by more than one library. - As the first step of the workflow (fq lint), on the complete files: a compressed file is truncated or corrupted (e.g. by an interrupted download or copy), a FASTQ record is malformed,
file1andfile2have different numbers of reads, or the read names offile1andfile2do not match record by record (mates not in the same order). All other steps wait until every library has passed.
Mates must be in the same order in file1 and file2, because vsearch pairs reads by position: out-of-order mates would not merge, or merge into chimeric reads that look like double mutants. If both files contain the same reads in a different order (for example, lanes concatenated in a different order), re-pair them before running the pipeline with seqkit pair or BBTools repair.sh.
Reference and reading frame
As of v1.0.0, all libraries in one run of nf-core/deepmutscan must stem from the same gene. Provide its wildtype sequence as a FASTA file via --fasta. We recommend that the reference contains N- and C-terminal flanking sequences of approximately one read length (e.g. from surrounding vector regions amplified during the sequencing library preparation), which helps to align reads more uniformly at the ends of the ORF. Lower-case (soft-masked) bases are allowed: the pipeline converts the reference to upper case before any step reads it.
Use --reading_frame to give the position of the mutagenised ORF within that sequence, as 1-based, inclusive nucleotide coordinates in the format start-stop: start is the first nucleotide of the first codon and stop the last nucleotide of the last codon to be analysed, so the length of the range must be divisible by three. For example, --reading_frame 151-450 analyses exactly 100 codons of the reference FASTA.
Use --mutagenesis_type to define which codons were programmed at each position (default nnk). This determines which observed variants count as library variants for filtering, QC and fitness estimation:
nnk,nns,nnh,nnn: degenerate codons, as used e.g. in nicking mutagenesisnnk_nns,nnk_nns_nnh: position-dependent degenerate codons, chosen by the third base of the wildtype codon: NNS where it is T, NNH where it is G (nnk_nns_nnhonly), and NNK otherwisecustom: a user-defined codon library, provided with--custom_codon_libraryas a.csvfile. Either give one global comma-separated list of codons without a header (e.g.AAA,AAC,AAG), or a position-wise list: a header line containing the wordPosition, followed by one row per codon position with the position and its allowed codons (e.g.1,ACG,AAA,ACA).
Shotgun sequencing cannot distinguish reads from unmutated plasmids from wildtype-matching fragments of mutated plasmids, so exact wildtype reads are not used as the fitness reference. Instead, the pipeline uses a synonymous variant as a wildtype proxy. We therefore highly recommend that your library design choice includes at least some synonymous wildtype amino acid codons – degenerate NNK/NNS codons do so at almost every position.
Tiled amplicon libraries (--sequencing tiled)
The default, --sequencing shotgun, is for libraries sequenced as fragments from anywhere along the mutagenised gene. Use --sequencing tiled when every library is a PCR amplicon of one tile of the gene and --fasta is that tile. All reads of such an amplicon start and end at the same place: past the tile, through the constant sequences the amplicon was amplified with (primer sites, adapters), and often through a few variable bases (a spacer or stagger) beyond them. With the shotgun settings, bwa-mem3 aligns the bases that run past the end of the reference as an insertion, and the counter skips every read with an indel: on three tiled libraries of 1 M read pairs each, 89-99.5 % of the reads were lost this way.
With --sequencing tiled:
- the merged reads are aligned with bwa-mem3’s default clipping penalty (
-L 5, plus-y 20, the third seeding round that--fastturns off and without which BWA-MEM misses the exact match of a read that contains the whole reference), so whatever runs past the reference is soft-clipped; - the constant flanks must be part of the reference, so that this clip never reaches a codon of the tile. Give them with
--flank_5primeand--flank_3prime(the sequences the reads carry before and after the tile, in the orientation of the reference), or leave them out: each library’s flanks are then found from its first 20,000 read pairs, as the sequence beyond each end of the reference that at least 90 % of the reads share. A flank the reference does not already start or end with is added to it for the alignment and the counting; positions in the count tables and every later output stay those of--fasta. The flanks used are written tointermediate_files/merged_reads/<library>.tiled_flanks.tsv.
If your reference already contains the constant flanks (as recommended above), nothing is added and only the clipping changes. On the three tiled libraries, the tiled settings counted 88-91 % of the read pairs, as many as trimming the flanks off the reads with cutadapt (within 2 %) at about a third less CPU time, and found every flank exactly when it was left out of the reference. Do not use --sequencing tiled for shotgun libraries: there, the end-to-end alignment of the default keeps codon changes at the read ends (see Alignment).
In a tiled amplicon the two mates usually overlap only in the middle of the tile, so the bases near its ends are read once and keep the instrument’s quality. On instruments whose highest quality score is below --base_qual (Illumina’s binned scores top out at Q37 on a NovaSeq 6000 and at Q40 on a NovaSeq X), lower --base_qual to that maximum, or the codons at both ends of the tile are not counted (see Variant counting). For libraries of a synthesised tile (no nicking primers) also set --min_FDdist 0.
Running the pipeline
The typical command for running the pipeline (here on a hypothetical gene of exactly 100 codons) is as follows:
nextflow run nf-core/deepmutscan \ -profile <docker/singularity/.../institute> \ --input ./samplesheet.csv \ --fasta ./ref.fa \ --reading_frame 151-450 \ --outdir ./resultsThis will launch the pipeline with the docker configuration profile (or the profile of your choice, see below). It performs the default read QC, read merging, alignment, filtering, variant counting, sequencing-error correction and library QC for every library in the samplesheet. Add --fitness to also estimate variant fitness from matched input and output libraries, and --dimsum and/or --mutscan for the additional fitness estimators.
Note that the pipeline will create the following files in your working directory:
work # Directory containing the nextflow working files<OUTDIR> # Finished results in specified location (defined with --outdir).nextflow.log # Log file from Nextflow# Other nextflow hidden files, eg. history of pipeline runs and old logs.If you wish to repeatedly use the same parameters for multiple runs, rather than specifying each flag in the command, you can specify these in a params file.
Pipeline settings can be provided in a yaml or json file via -params-file <file>.
Do not use -c <file> to specify parameters as this will result in errors. Custom config files specified with -c must only be used for tuning process resource specifications, other infrastructural tweaks (such as output directories), or module arguments (args).
The above pipeline run specified with a params file in yaml format:
nextflow run nf-core/deepmutscan -profile docker -params-file params.yamlwith:
input: './samplesheet.csv'outdir: './results/'fasta: './ref.fa'reading_frame: '151-450'fitness: true<...>You can also generate such YAML/JSON files via nf-core/launch.
Pipeline steps in detail
1. Read merging
All paired-end raw reads are first quality-checked: fq lint confirms that both files of every library are complete and consistent, and Falco writes the FastQC report of every file (FastQC’s analyses, reimplemented in C++ at a fraction of its time and memory), in one task per library.
Even the highest-quality sequencing platforms do not have perfect base accuracy. To minimise the effect of base errors, which would otherwise be counted as false mutations, nf-core/deepmutscan uses the overlap of each read pair. As base errors on the forward and reverse read are largely independent, vsearch –fastq_mergepairs converts each raw read pair into a single consensus read with adjusted base qualities. Read pairs that cannot be merged (overlap shorter than 10 bp) are discarded. The merging statistics of every library are saved in intermediate_files/merged_reads/.
2. Alignment
The merged reads are aligned to the reference with bwa-mem3, a maintained derivative of bwa-mem2 that implements the BWA-MEM algorithm. For a gene-sized reference its alignments are identical to those of BWA 0.7.19 with the same scoring, at a fraction of the CPU time; the pipeline runs it with its --fast preset, which trades byte-for-byte reproducibility across bwa-mem3 versions for a further 2× (on the test libraries it changes a single read in one library).
Substitutions are aligned end-to-end (-L 100 -O 12,12 -B 3, with --fast the module’s ext.args3). With BWA-MEM’s default local alignment, a read end that carries two or three adjacent mismatches (a full codon change) costs more than clipping it off, so a 2-base codon change within 3 bp, or a 3-base change within 7 bp, of a read end was removed from the alignment together with its coverage contribution; on 150 bp merged reads this under-counted full-codon substitutions by about 13% relative to single-base changes, and made the recovery of read-linked double mutants depend on their distance. A clipping penalty of 100 keeps every base in the alignment, the higher gap-open penalty stops three mismatches from being realigned as an indel (indel-containing reads are discarded in the next step), and the mismatch penalty is lowered for the same reason. Reads with genuine adapter remnants or chimeric ends now show up as runs of low-quality mismatches, which the base-quality filter of the variant counter removes. For alignments byte-identical to BWA 0.7.19, set ext.args3 = '-L 100 -O 12,12 -B 3' (without --fast) in a custom config.
3. Filtering
Alignments are filtered with samtools view: only primary alignments (no unmapped, secondary or supplementary records) with a mapping quality ≥ 30 are kept. The filtered alignments go straight to variant counting; reads whose alignment contains an insertion, deletion or splice gap pass the filter but are ignored by the counter, as indel-containing reads are most likely artefacts in substitution libraries.
For long ORF site-saturation mutagenesis libraries, most aligned shotgun sequencing reads match the reference exactly. These wildtype reads are retained: they are ignored by the variant counter but contribute to the overall sequencing coverage and sequencing-error estimation.
Merging, alignment, filtering and variant counting run as one streamed, multi-threaded task per library (MERGE_ALIGN_COUNT). vsearch and bwa-mem3 each use the task’s task.cpus and run concurrently; give the task at least two CPUs, because with one bwa-mem3 reads and aligns in turns and the stream runs at half speed. The counter reads the alignments as they arrive and needs no BAM, so none is written by default. --save_bam also coordinate-sorts and indexes them into intermediate_files/bam_files/sorted/ for inspection (with --sequencing tiled, against the reference with any added flanks). The vsearch options (ext.args), the bwa-mem3 options (ext.args3), the samtools filter flags (ext.args2) and extra counter options (ext.args4) can be changed in a custom config.
The merging benefit is largest if the average DNA fragment size matches the read length. For example, libraries sequenced with 150 bp paired-end reads should ideally also be sheared or tagmented to a mean size of about 150 bp.
4. Variant counting
Merged reads are screened for base-level mismatches against the reference. nf-core/deepmutscan uses a single-pass counter written in C on htslib (dms_count) that counts all single, double, triple and higher-order nucleotide changes per read from the alignment’s CIGAR and MD strings, together with the sequencing coverage of every position. It produces the same, byte-identical table as the Python counter of v1.0.0 in about 2% of its CPU time and 14 MB of memory. This replaces the GATK AnalyzeSaturationMutagenesis tool used in earlier versions; a description of every column is written next to each count table (variant_counts_columns.tsv).
Two parameters tune the counter:
--base_qual(default40): minimum Phred base quality for a mismatch to be counted, and for a base to contribute to coverage. Note what this threshold implies:vsearchrecalculates qualities only where the two mates overlap, so a base in the overlap that both mates agree on can exceed the instrument’s own maximum, while bases outside the overlap keep their instrument quality. On quality-binned instrument data (NovaSeq bins at Q37 or below) the default of40therefore restricts counting to the overlapping, double-observed part of each merged read. Lower it (e.g.--base_qual 30) to count the full read length.--min_flank(default2): minimum distance (in nucleotides) of a mismatch or covered base from the read end. Set to0to disable.
5. Library annotation and filtering
Variant counts are annotated with their codon and amino acid changes within --reading_frame, and filtered for the variants that were programmed by the chosen --mutagenesis_type. In addition, a library-completed table lists every programmed variant, including those that were not observed (with a near-zero placeholder count), for the count distribution plots.
6. Single-nucleotide variant error correction
Sequencing errors occur at typically low, but position- and substitution-specific rates. With very deep sequencing, they inflate the counts of variants that differ from the wildtype by only a single nucleotide. Variants with two or three nucleotide changes in one codon, however, are hardly affected. Select a correction strategy with --error_correction:
false_doubles(default): the library only contains single-codon changes, so reads carrying a programmed multi-nucleotide codon variant plus an unprogrammed single-nucleotide change in a nearby codon (“false double mutants”) reveal the sequencing error rate of that single-nucleotide change. For every single-nucleotide variant, the pipeline counts these false-double reads (F) and the reads carrying a programmed multi-nucleotide variant within--max_FDdistcodons (default40) that could have revealed such an error (the exposure, M). Their ratio estimates the variant’s error rate, and the expected number of erroneous counts (error rate × coverage) is subtracted. No extra data are required. The model is the R package fdmcorrect (bioconda::dms-fdmcorrect), which also runs on its own, outside the pipeline.- Estimator (
--false_doubles_method):eb(default) is a Gamma-Poisson empirical-Bayes estimate that shrinks each variant’s rate towards the mean of its class, more strongly the less evidence the variant has. With--false_doubles_prior trinucleotide_context(default) the classes are the 96 trinucleotide contexts (substitution type and both flanking bases), themselves shrunk towards the six substitution types;substitution_typeuses the six types only.mleis the plain per-variant ratio F/M; it is zero for every variant without an observed false double, so it depends on sequencing depth and is mainly useful for comparison. - Pooling (
--false_doubles_pooling):all(default) pools the false-double evidence of every non-wildtypelibrary of asample, estimates the error rates once and corrects every library with the same rates at its own coverage.replicatespools only the replicates of eachsampleandtype, andnoneestimates each library on its own. Pooling assumes that the pooled libraries share one error process, i.e. were prepared, processed and sequenced together, as in a typical input-versus-output experiment; there, replicate-to-replicate differences in error rate are sampling noise, and pooling all libraries gives the most precise rates. Usereplicatesif conditions or sorting bins were amplified or sequenced separately: pooling libraries with different error rates gives every library a confidently wrong common rate rather than a noisier own one. Whatever the pooling, the error-correction report sets each library’s own estimate against the pooled rate. - Variants are corrected even when no false double was observed for them (F = 0): their rate is then estimated from their class. Variants without any programmed multi-nucleotide variant within the window (M = 0) get the mean rate of their class (
eb) or are left uncorrected (mle). If a pool contains fewer than 100 false-double reads in total witheb, or fewer than 1,000 withmle(e.g. very small or shallow libraries), no correction is applied and a message is written to the log. On pools thinned to a fraction of their reads, theebrates were closer to those of the full-depth pool than no correction at every depth tested, while the per-variantmleratio was worse than no correction below about 500-1,000 false-double reads. Libraries oftypewildtypecontain no programmed variants and are never false-doubles corrected. - Anchor distance (
--min_FDdist, default13, and--max_FDdist, default40): an anchor is used whenmin_FDdist< distance <=max_FDdist, in codons. The lower bound removes the mutagenesis primer’s own footprint: anchors closer than this many codons to the variant are not used. Within one mutagenesis primer’s footprint the false doubles are dominated by that primer’s own recurrent synthesis or sequencing errors, which travel with the anchor by construction rather than being the per-site error of the variant; a genuine second primer integration is near-impossible there, because the two footprints would clash. This replaces an earlier filter on the highest false-double counts, which removed the same reads but depended on sequencing depth. Set--min_FDdist 0for libraries made without nicking mutagenesis: a tile synthesis has no primer footprint, so there is nothing to exclude and the exclusion only costs evidence - on a Twist tile library it halves the false-double reads and costs 0.06 of agreement both between sorting bins and between replicates. The excluded region is still measured and shown in the error-correction report, together with the genuine double-mutant rate at every distance. The upper bound is set by the sequencing geometry: both changes must sit on one fragment, so joint coverage falls with distance - on ~250-300 bp fragments it is about a quarter of single-site coverage at 40 codons and near zero past 90. Far anchors are also biased, not merely thin: estimated from anchors 40-60 codons away, the error rate of the rarest quartile of variants runs about three times what matched wildtype-template sequencing measures, while abundant variants are unaffected, which is the shape of an additive background from PCR template switching rather than of per-site error. Swept from 15 to 120 codons on five libraries, 40 gives the best agreement with the wildtype template; below 25 the evidence collapses to a few reads per variant and the estimate falls back on the class prior. Lower it for shorter fragments, and raise it only to inspect the anchor profile itself. - Genuine double mutants (
--subtract_genuine_doubles, defaulttrue): two mutagenesis primers can integrate into the same molecule, so a read can carry a programmed anchor next to a variant without any sequencing error having occurred. Those reads are counted in F and are not error. Their rate relative to independent co-integration, kappa(d), is measured on reads carrying two programmed multi-nucleotide variants - which no sequencing error can create - pooled over the libraries of each pool and taken at each codon distance, smoothed over neighbouring distances. Each variant’s expected genuine-double reads are G = f x sum_p kappa(d) m_p, and the estimator splits F between error and genuine doubles by expectation-maximisation, so counts stay non-negative. Across four in-house libraries this removes 2-10 % of F and brings the fitted rates closer to matched wildtype-template sequencing (slope 0.78 to 0.91, median ratio 1.39 to 1.21). Set--subtract_genuine_doubles falseto estimate from the raw false-double reads. - Error spectrum and its signatures (reporting only;
--skip_error_signaturesto turn off): the 96-channel spectrum of every pool’s false-double error rates is fitted to a set of candidate mutational signatures – by default the COSMIC v3.4 signatures flagged as possible sequencing or library artefacts plus DNA-damage chemistry that can act on DNA in vitro (the unrepaired and repaired FFPE signatures of Guo et al. 2022, SBS30, SBS18); clock-like signatures are not candidates. If the sample also has awildtypelibrary, the wildtype-template error spectrum and the excess of the false-double rates over it are fitted too. Before the excess is formed, genuine double mutants (real library molecules with two programmed variants, e.g. from PCR chimeras) are removed from the false doubles: their rate is measured on reads carrying two programmed multi-nucleotide variants, which errors cannot create (--error_signatures_genuine_doubles). Each spectrum is fitted in two stages: a non-negative least-squares screen of all candidates over site bootstraps (--error_signatures_bootstraps, default200), then forward selection of the passing candidates, skipping any signature too similar to one already chosen (--error_signatures_max_cosine, default0.5), stopped at the elbow of the reconstruction cosine. A custom candidate set can be given with--error_signatures_candidates(CSV: achannelcolumn in COSMIC notation, e.g.A[C>A]A, and one column per signature on GRCh37 trinucleotide composition). The fit does not change the correction.
- Estimator (
wildtype: subtracts the variant-specific background measured by additional deep sequencing of the unmutated template from every library variant. Add these libraries to the samplesheet withtypeset towildtypeand the samesamplename as the libraries they should correct. The pipeline stops with an error if asamplehas nowildtypelibrary. In this mode, thewildtypelibraries themselves are not included in the library QC and fitness outputs.none: no correction; counts are used as observed.
Corrected counts are used for every count-dependent step downstream (count heatmaps, positional QC and fitness). The uncorrected tables are kept next to the corrected ones, and an interactive HTML report shows the effect of the correction across all libraries of the run.
7. DMS library quality control
Based on the library-filtered (and error-corrected) counts, nf-core/deepmutscan produces per-library visualisations to assess mutation efficiency, coverage and saturation along the ORF:
- heatmaps of variant counts and counts per coverage, per position and amino acid
- sorted, log-scale distributions of counts per coverage of all programmed variants, also stratified by the number of changed nucleotides, summarised by the log10 ratio of their 90th and 10th percentiles
- sliding-window profiles of coverage and counts along the ORF (window size set by
--sliding_window_size, default10codons), with a reference line for the coverage needed to observe every amino acid variant--aimed_covtimes (default100) - a sequencing-depth rarefaction curve that estimates the fraction of programmed variants recovered at lower sequencing depths (
--run_seqdepth, on by default)
8. Fitness estimation (optional)
With --fitness, libraries of each sample are grouped into a merged count table of all input and output replicates. Fitness is then estimated per replicate as the natural logarithm of each variant’s output-to-input count ratio, relative to that of a synonymous wildtype proxy variant. As the proxy, the pipeline picks the synonymous variant with two nucleotide changes in one codon (or, if there is none, one nucleotide change) with the highest mean input count. Non-synonymous variants encoding the same amino acid sequence are aggregated. Per-replicate fitness values are linearly rescaled so that the median of synonymous variants is 0 and the median of stop codon variants is -1 (if one of these anchors is missing, fitness values are only centred), and summarised as the mean and, with more than one replicate, the standard deviation across replicates.
Two parameters control which variants are scored, and how:
--min_counts(default10): minimum number of reads a variant needs in everyinputreplicate to receive a fitness estimate. Variants with fewer input reads are poorly measured and are excluded. The threshold applies to each codon variant before synonymous codon variants are merged, in the same way for the default estimator, DiMSum and mutscan.--output_pseudocount(default1): pseudocount added tooutputreplicates in which a variant observed in the input was not detected (“dropouts”), so that strongly depleted variants still receive a finite fitness value. Set it to0to disable; dropout variants then receive no fitness estimate in that replicate.
Two established statistical frameworks can be run on the same merged counts:
-
--dimsum: DiMSum fitness estimates (stages 4–5 of DiMSum, without its own read processing), on the same merged count table as the default estimator. The pipeline runs these two stages from DiMSum 1.4’s own R code, bundled asbin/dimsum_fitness.R(MIT, credited in the file) instead of through ther-dimsumpackage, whose Bioconda recipe pins R 4.0 and pulls in the read-processing tools of the stages the pipeline never runs; the outputs are the same files with the same content, and the step runs natively on ARM. The pipeline passes--min_countsas--fitnessMinInputCountAlland--output_pseudocountas--fitnessDropoutPseudocount, so DiMSum scores the same variants. By default, DiMSum also runs with:--mixedSubstitutions T: the synonymous wildtype proxy can differ from the reference by one codon. With DiMSum’s own default (F), single mutants relative to the proxy would be discarded as “mixed substitutions”. WithT, DiMSum also adds up synonymous codon variants before estimating fitness, as the default estimator does.--fitnessErrorModel T(from--dimsum_error_model, defaulttrue): DiMSum fits its error model. It estimates replicate-specific error terms and normalises fitness between replicates, by bootstrapping over the variants that are well covered in every input and output replicate. The fitness sigmas then combine count-based and replicate errors. The fit needs at least 30 such variants per replicate (90 for three replicates); sparse libraries may not have them, and DiMSum stops with “insufficent number of variants satisfying full fitness range”. In that case, run with--dimsum_error_model false: DiMSum then uses count-based errors only and no replicate normalisation. Thetestprofile does this, because its subsampled libraries are too sparse. The fit runs on one CPU, so that its bootstrap resamples, and hence its numbers, do not depend on the CPUs a task is given.--retainIntermediateFiles T.
These options are set with
ext.argsand can be changed in a custom config, for example:process {withName: 'RUN_DIMSUM' { ext.args = '--mixedSubstitutions T --fitnessErrorModel T --retainIntermediateFiles T' }} -
--mutscan: variant enrichment estimates with edgeR and limma-voom following mutscan’s analysis (Soneson et al. 2023) step by step, on the same merged count table: the wildtype’s counts as the per-sample normalisation, replicate as a blocking factor, the input-to-output change as the tested coefficient. The pipeline calls edgeR and limma directly rather than through the mutscan package, so the step runs natively on ARM as well; the result tables are identical to mutscan’s, with one deliberate exception: a TTG or CTG variant codon at the first position of the ORF is named L (standard genetic code), not M (Biostrings’ initiation-codon rule, which mutscan’s names inherit).
Interactive variant effect inspection tool (--pdb)
When --fitness is set and a wildtype 3D structure is supplied via --pdb <structure.pdb> (an experimental structure, an AlphaFold DB model, or any PDB file matching the wildtype ORF), the pipeline additionally builds a portable, interactive HTML tool. It projects per-residue fitness, coverage, counts, counts per coverage and – when error correction is on – the positional error bias onto the structure; clicking a residue shows the effect of each substitution. Structure prediction is not part of the v1.0.0 release, so a user-specified structure file is required to enable the tool.
9. Reporting
nf-core/deepmutscan writes a single, self-contained deepmutscan_report.html to the top of the results directory. It embeds the library QC plots, the error-correction report, the fitness results (and DiMSum/mutscan output, if run), the MultiQC report, links to Nextflow’s execution report and timeline, and the citations of all tools that were used, so it can be shared as a single file.
Updating the pipeline
When you run the original command above, Nextflow automatically pulls the pipeline code from GitHub and stores it as a cached version. When running the pipeline after this, it will always use this cached version if available - even if the pipeline has been updated since. To make sure that you are running the latest version of the pipeline, make sure that you regularly update the cached version:
nextflow pull nf-core/deepmutscanReproducibility
It is a good idea to specify the pipeline version when running the pipeline on your data. This ensures that a specific version of the pipeline code and software are used consistently. If you keep using the same tag, you’ll be running the same version of the pipeline, even if there have been changes to the code since.
First, go to the nf-core/deepmutscan releases page and find the latest pipeline version - numeric only (eg. 1.0.0). Then specify this when running the pipeline with -r (one hyphen) - eg. -r 1.0.0.
This version number will also be logged in reports when you run the pipeline, for example at the bottom of the MultiQC reports.
To further assist in reproducibility, you can share and reuse parameter files to repeat pipeline runs with the same settings without having to write out a command with every single parameter.
If you wish to share such a profile (e.g. providing it as supplementary material for academic publications), make sure to not include your cluster specific file paths or institutional specific profiles.
Core Nextflow arguments
These options are part of Nextflow and use a single hyphen (pipeline parameters use a double-hyphen)
-profile
Use this parameter to choose a configuration profile. Profiles can give configuration presets for different compute environments.
Several generic profiles are bundled with the pipeline which instruct the pipeline to use software packaged using different methods (Docker, Singularity, Podman, Shifter, Charliecloud, Apptainer, Conda) - see below.
We highly recommend the use of Docker or Singularity containers for full pipeline reproducibility, however when this is not possible, Conda is also supported.
The pipeline also dynamically loads configurations from https://github.com/nf-core/configs when it runs, making multiple config profiles for various institutional clusters available at run time. For more information and to check if your system is supported, please see the nf-core/configs documentation.
Note that multiple profiles can be loaded, for example: -profile test,docker - the order of arguments is important!
They are loaded in sequence, so later profiles can overwrite earlier profiles.
If -profile is not specified, the pipeline will run locally and expect all software to be installed and available on the PATH. This is not recommended, since it may lead to varying or even irreproducible results across users’ different computer environments.
test- A profile with a complete configuration for automated testing
- Includes links to test data so needs no other parameters
docker- A generic configuration profile to be used with Docker
singularity- A generic configuration profile to be used with Singularity
podman- A generic configuration profile to be used with Podman
shifter- A generic configuration profile to be used with Shifter
charliecloud- A generic configuration profile to be used with Charliecloud
apptainer- A generic configuration profile to be used with Apptainer
wave- A generic configuration profile to enable Wave containers. Use together with one of the above (requires Nextflow
24.03.0-edgeor later).
- A generic configuration profile to enable Wave containers. Use together with one of the above (requires Nextflow
conda- A generic configuration profile to be used with Conda. Please only use Conda as a last resort i.e. when it’s not possible to run the pipeline with Docker, Singularity, Podman, Shifter, Charliecloud, or Apptainer.
-resume
Specify this when restarting a pipeline. Nextflow will use cached results (from within the /work directory) from any pipeline steps where the inputs are the same, continuing from where it got to previously. For input to be considered the same, not only the names must be identical but the files’ contents as well. For more info about this parameter, see this blog post.
You can also supply a run name to resume a specific run: -resume [run-name]. Use the nextflow log command to show previous run names.
-c
Specify the path to a specific config file (this is a core Nextflow command). See the nf-core website documentation for more information.
Custom configuration
Resource requests
Whilst the default requirements set within the pipeline will hopefully work for most people and with most input data, you may find that you want to customise the compute resources that the pipeline requests. Each step in the pipeline has a default set of requirements for number of CPUs, memory and time. For most of the pipeline steps, if the job exits with any of the error codes specified here it will automatically be resubmitted with higher resources request (2 x original, then 3 x original). If it still fails after the third attempt then the pipeline execution is stopped.
To change the resource requests, please see the max resources and customise process resources section of the nf-core website.
Custom Containers
In some cases, you may wish to change the container or conda environment used by a pipeline steps for a particular tool. By default, nf-core pipelines use containers and software from the biocontainers or bioconda projects. However, in some cases the pipeline specified version maybe out of date.
To use a different container from the default container or conda environment specified in a pipeline, please see the updating tool versions section of the nf-core website.
Custom Tool Arguments
A pipeline might not always support every possible argument or option of a particular tool used in pipeline. Fortunately, nf-core pipelines provide some freedom to users to insert additional parameters that the pipeline does not include by default.
To learn how to provide additional arguments to a particular tool of the pipeline, please see the customising tool arguments section of the nf-core website.
nf-core/configs
In most cases, you will only need to create a custom config as a one-off but if you and others within your organisation are likely to be running nf-core pipelines regularly and need to use the same settings regularly it may be a good idea to request that your custom config file is uploaded to the nf-core/configs git repository. Before you do this please can you test that the config file works with your pipeline of choice using the -c parameter. You can then create a pull request to the nf-core/configs repository with the addition of your config file, associated documentation file (see examples in nf-core/configs/docs), and amending nfcore_custom.config to include your custom profile.
See the main Nextflow documentation for more information about creating your own configuration files.
If you have any questions or issues please send us a message on Slack on the #configs channel.
Running in the background
Nextflow handles job submissions and supervises the running jobs. The Nextflow process must run until the pipeline is finished.
The Nextflow -bg flag launches Nextflow in the background, detached from your terminal so that the workflow does not stop if you log out of your session. The logs are saved to a file.
Alternatively, you can use screen / tmux or similar tool to create a detached session which you can log back into at a later time.
Some HPC setups also allow you to run nextflow within a cluster job submitted your job scheduler (from where it submits more jobs).
Nextflow memory requirements
In some cases, the Nextflow Java virtual machines can start to request a large amount of memory.
We recommend adding the following line to your environment to limit this (typically in ~/.bashrc or ~/.bash_profile):
NXF_OPTS='-Xms1g -Xmx4g'