Adjusting parameters
AccuSNV is set up with parameters that have been optimized for accuracy in SNV calling, and in many cases, you may not have to adjust these defaults. However, depending on your particular data and run environment, you may have to, and all of the parameters behind an AccuSNV run are organized into two yaml config files:
pipeline.yaml: contains all pipeline parameters.
config.yaml: contains all runtime parameters (for snakemake and SLURM)
By default, both config files are created in <output_dir>/configs/ with their defaults filled in on every run. Alternatively, you can pass -c [config.yaml] or -p [pipeline.yaml] to accusnv to use previously modified versions of these files. If you do so, your files are copied into <output_dir>/configs/ for your new run. Further, any command line options passed to AccuSNV are written into those config files. This way, the config files in a given output directory are always indicative of the values run during that run.
To modify parameters, you can run once (with accusnv -m dryrun), copy the generated file, edit it, and pass it back:
accusnv -p pipeline.yaml -c config.yaml -i samples.csv -r reference_genomes -o my_output
Pipeline parameters: pipeline.yaml
Logging
Key |
Default |
Description |
|---|---|---|
|
|
The summary log file name found in |
|
|
The extended log file name that contains the output of every external tool. |
Read trimming and mapping
Key |
Default |
Description |
|---|---|---|
|
|
|
|
|
Prevents piping |
|
|
Number of cores each |
|
|
The 3’ adapter |
|
|
Phred quality threshold for |
|
|
Reads shorter than this after trimming are dropped. |
|
|
Maximum insert size ( |
|
|
Optical-duplicate pixel distance for |
Pileup and variant calling
Key |
Default |
Description |
|---|---|---|
|
|
Minimum read mapping quality for |
|
|
Maximum per-file pileup depth. |
|
|
Minimum alternate-allele fraction for |
|
|
The |
Sample-level filters
Key |
Default |
Description |
|---|---|---|
|
|
Remove a sample when it has no read coverage at more than this percentage of the candidate positions. Set to |
|
|
Either a comma-separated list of sample names to drop, or a number of max SNVs per sample. When it is an integer, the pipeline will drop any sample with at least that many candidate SNVs. |
Per-basecall filters
These four filters decide whether one sample’s base call at one position is trusted for nomination of a candidate SNV.
Key |
Default |
Description |
|---|---|---|
|
|
Minimum call quality (negative |
|
|
Minimum forward reads and minimum reverse reads at the position. ( |
|
|
The most common base must account for at least this fraction of the reads. ( |
|
|
Drop the call when more than this fraction of the covering reads contain an insertion or deletion. ( |
|
|
Minimum “mutation quality” for a SNV. The mutation quality is defined by AccuSNV as the best FQ score for a given site, for the more weakly supported variant at that site. Effectively, it discards sites where there is no strong evidence that two samples disagree. |
min_cov_filt is the filter that matters most at low depth. In low coverage samples, you may consider reducing this.
Across-sample position filters
These filters check SNV position quality across the whole group of samples.
Key |
Default |
Description |
|---|---|---|
|
|
Drop a position when more than this fraction of samples have no confident base call. The default is |
|
|
Drop a position whose median read depth across samples is below this. ( |
|
|
Drop a position whose depth averages more than this many times the genome-wide median. ( |
|
|
As above, but for any single sample. ( |
Overruling SNVs rejected by the CNN
When the AccuSNV CNN rejects a candidate site as a SNV but it still passes all of the rule filters above, AccuSNV keeps the SNV only if the positions with the variant do not have mixed read support (the Fraction_ambiguous_samples column). This cutoff is by default <25% if there are less than 20 samples in the group, and 10% if there are more than 20 samples in the group.
Key |
Default |
Description |
|---|---|---|
|
|
Group size above which the stricter cutoff applies. |
|
|
The |
|
|
The |
Manual SNV curation options
Key |
Default |
Description |
|---|---|---|
|
|
Path to a file of |
|
|
Path to a file of |
accusnv --exclude_positions and --include_positions create these parameter key values. Both are applied after SNV calling, so --downstream_only gets these SNVs without re-calling.
Recombination detection
Key |
Default |
Description |
|---|---|---|
|
|
Only SNV pairs closer together than this are tested for correlation. |
|
|
Correlation above which a pair is flagged as recombinant. |
|
|
Turn detection off entirely, which means nothing is ever flagged. |
See Recombination for what these actually do and when to change them.
Annotation
Key |
Default |
Description |
|---|---|---|
|
|
The major-allele cutoff used when base calls are rebuilt for annotation. Looser than the calling cutoff so the per-sample columns show a base rather than an |
The promoter window, which is how far upstream of a gene a SNV can be and still be reported as type P for promoter, is fixed at 250 bp, and not currently a flag.
Very large runs: “fast mode”
Key |
Default |
Description |
|---|---|---|
|
|
Above this many candidate positions, switch to fast mode. |
In fast mode AccuSNV scores every position with the CNN and then stops. It writes
snv_table_cnn_raw.tsv and candidate_mutation_table_final.npz, and skips annotation, dN/dS, the tree and the report. If this threshold is crossed in a group of isolates, the user may wish to select more closely related groups of isolates for more accurate SNV calling.
Optional stages
Key |
Default |
Description |
|---|---|---|
|
|
Skip the HTML report. |
|
|
Skip dN/dS. |
|
|
Skip the parsimony tree. dMRCA is still estimated. |
|
|
Build a neighbor-joining tree with Biopython instead of a parsimony tree with |
|
|
Write one NEXUS tree per SNV with tips colored by base call. |
|
|
Stop after the annotated SNV tables. |
|
|
Re-run only the evolutionary analyses. |
Runtime configuration: config.yaml
config.yaml is the Snakemake execution profile, plus the input and output paths that AccuSNV will fill in from your -i, -r and -o arguments.
rerun-incomplete: true
latency-wait: 30
keep-going: true
printshellcmds: true
# Resubmit a failed job at the next resource tier up. 0 disables.
retries: 3
# Slurm execution
executor: slurm
jobs: 100
default-resources:
- slurm_partition="partition_a,partition_b"
- mem_mb=4000
- runtime=60
Key |
Description |
|---|---|
|
Redo any job whose output is half-written, for example after a killed run. Almost certainly best to keep as true. |
|
Seconds to wait for a file to appear on a shared filesystem before declaring it missing. You probably only need to increase this on an overloaded or old system. |
|
Carry on with jobs that do not depend on a failed one, instead of stopping the whole run. |
|
How many times a failed job is resubmitted, each time with a higher resource tier. |
|
Maximum Slurm jobs running at once. |
|
The resources for every job. By default, resources are decided per job and per tier by |
|
This is passed from the CLI parameter |
The config: block at the bottom includes sample_table, outdir and env. AccuSNV fills those in automatically from the command line parameters, so you do not need to touch them.
Slurm job resource allocation
The memory and run-time resources requested for each job are determined for each step (Snakemake rule) by resources.py. By default, Snakemake will start with a reasonably small memory and run-time request for a given job. If it then runs out of time or memory, it will restart that job at a higher ‘tier’, requesting more memory and run-time.
The tiers are a plain Python dictionary in src/accusnv/workflow/resources.py if you need to
adjust them for your cluster. Here are their default values, in MB of RAM and minutes:
TIERS = {
'create_mapping_index': [(2000, 60), (8000, 60), (320000, 240)],
'mapping': [(8000, 120), (32000, 120), (64000, 240)], ## medium amount of RAM
'cutadapt': [(2000, 30), (8000, 60), (32000, 240)],
'sickle': [(2000, 30), (8000, 60), (32000, 240)],
'sam2bam': [(4000, 30), (16000, 60), (64000, 240)],
'mpileup2vcf': [(1000, 30), (4000, 60), (64000, 240)],
'vcf2quals': [(2000, 30), (4000, 60), (64000, 240)],
'variants2positions': [(1000, 30), (4000, 60), (64000, 240)],
'upstream_rejects': [(1000, 30), (4000, 60), (64000, 240)],
'pileup2diversity': [(8000, 30), (32000, 60), (128000, 240)],
'combine_positions': [(1000, 30), (4000, 60), (32000, 240)],
'combine_upstream_rejects': [(1000, 30), (4000, 60), (32000, 240)],
'candidate_mutation_table': [(32000, 30), (64000, 60), (128000, 240)], ## can use a LOT of RAM
'calling_accusnv': [(16000, 30), (64000, 60), (128000, 240)], ## can use a decent amount of RAM
'annotate_snvs': [(4000, 30), (16000, 60), (64000, 240)],
'dnds': [(2000, 30), (16000, 60), (64000, 240)],
'build_tree': [(2000, 30), (16000, 60), (64000, 240)],
'report_html': [(2000, 30), (4000, 60), (32000, 240)],
}
If you need to change the requests for a particular stage, you can do that by adding a section to the config.yaml that will override these parameters for a particular pipeline stage. Here is an example for how to increase the memory required by the candidate_mutation_table stage:
set-resources:
candidate_mutation_table:
mem_mb: 200000
runtime: 480