Kapur Lab - Penn State · USDA · Bioinformatic Diagnostic Tools (bdtools)
vSNP3
Whole-genome SNP analysis for bacterial and viral isolates: how sequencing reads
become a high-resolution genotype, and how the SNP database is built and maintained.
vSNP3 aligns reads to a reference genome and counts every difference, reporting the
number of SNPs between any two isolates. Methods that read only a few loci, such as spoligotyping and
MLST, assign isolates to a single type; comparing the whole genome separates isolates within that type
and measures how far apart they are.
The same eight isolates under both methods. Numbers on the branches are SNPs
(illustrative): distances show which isolates are closely related, which are not, and by how much.
vSNP3 · Kapur Lab · Penn State · USDA
02
Overview/the whole process
The whole process on one page.
Reads in, aligned to a reference, one VCF per sample collecting in a database that
only grows — then split into groups, each read as a tree and a SNP table.
vSNP3 · Kapur Lab · Penn State · USDA
03
The database/reference types
The database is organized by reference type.
A reference type is one folder per reference genome, holding everything needed to compare samples against it — together with every VCF already processed there.
Mycobacterium_AF2122/
├──*.fastathe reference genome├──*.gbkannotation → a SNP gets a gene├──*_define_filter.xlsxdefining SNPs + per-group filters├──*_metadata.xlsxfile stem → display label└──*_remove_from_analysis.xlsxsamples/regions to drop
Add an organism by adding a folder. The reference name is the folder name.
The VCF set only grows as samples are processed against that reference.
The reference defines the positions. Two samples called against the same
reference can be compared position by position. Against a different reference the same site
carries a different number, so Step 2 will not mix them.
Each reference type is its own database — separate Step 1, Step 2 and comparisons
Step 1 aligns one sample’s reads to a reference and calls its variants.
Reads go in; every difference from the reference is called and every uncovered region is recorded. This is the slow stage, and it runs once per sample.
Zero coverage is recorded. A - later means no data at that position, not a match.
The BAM is kept, so the reads behind any call can be reviewed later.
Adding samples is incremental. Alignment is done once.
In bdtools: pick the reference, Grab ready-to-run samples, then Runbdtools · vSNP GUI v0.4.80 · Step 1.
A few lines of a _zc.vcf
#CHROM POS REF ALT QUAL INFO FORMAT sample
MTBC0 6406 C T 3514.88 AC=2;AF=1;DP=119;MQ=60;TYPE=snp GT:DP:AD 1/1:119:0,119
MTBC0 8285 C T 2588.83 AC=2;AF=1;DP=91;MQ=60;TYPE=snp GT:DP:AD 1/1:91:2,88
MTBC0 13228 GCCCCCCGCT GCCCCCGCT 1056.36 AC=2;DP=39;TYPE=del GT:DP:AD 1/1:39:0,38
MTBC0 17868 N . . no reads covered this position GT ./.
The SNP, its depth and quality — and a row for every position with
no coverage at all.
vSNP3 · Kapur Lab · Penn State · USDA
05
Quality control/between Step 1 and Step 2
Review the Step 1 statistics before running Step 2.
Step 1 flags each sample PASS or REVIEWbdtools · vSNP GUI v0.4.80 · Step 1 Results with the reason. Failing samples are excluded before a comparison runs.
Metric
Healthy
Review when
Average depth of coverage
≥ 40×
< 20×
Reads mapping to the reference
> 90%
< 80%
% reference with zero coverage
< 5%
> 10%
R1/R2 % passing Q20
> 50%
very low
Quality SNP count
organism-typical
a spike
Low mapping usually means contaminating reads — host DNA or another organism. Parse the sample down to your target taxon with Kraken from inside Step 1, then re-run it.
Kraken runs from inside Step 1; the parsed sample carries its taxon in the name, and
only that cleaned sample is re-aligned.Kraken · Krona chart of one sample
vSNP3 · Kapur Lab · Penn State · USDA
06
Large sample sets/defining SNPs
Defining SNPs sort samples into groups before the comparison is run.
Defining SNPs assign each sample to a group, so every table you actually read is smaller and internally comparable. A whole-complex table is thousands of positions across dozens of samples, and the differences between lineages drown out the few SNPs that separate recent cases.
In <reference>_define_filter.xlsx: row 1 is a chrom:position,
row 2 names the group, and the rows beneath list positions to filter out within it.
Adding a group is adding a name and a position to that file — the next run reports it as its own group. A real run of this MTBC set produced 173 groups, each with its own table, tree, and SNP distances.
vSNP3 · Kapur Lab · Penn State · USDA
07
Step 2/comparison
Each Step 1 result joins the database; Step 2 compares any selection from it.
Every finished sample is copied into the project’s VCF database, which only ever grows. Step 2 takes whichever samples you tick, splits them into groups, and builds a table and tree for each one. No reads are re-aligned.
The database holds every sample processed against this reference; each was aligned
once, whenever it was first run.
You tick what goes in: this project’s samples plus optional shared panels. See the builderbdtools · vSNP GUI v0.4.80 · Step 2 build
One table and tree per subgroup come out of the same run. See the outputsbdtools · vSNP GUI v0.4.80 · Step 2 Results
vSNP3 · Kapur Lab · Penn State · USDA
08
Reading the output/table and tree together
The SNP table and the tree show the same data two ways.
Same samples, same SNPs, presented two ways: the
tablebdtools · vSNP GUI v0.4.80 · cascade table lists them position by position, the
tree draws the same differences as distance. A block of shared SNPs in the table is the branch
that groups those samples in the tree. In the
built-in tree viewerbdtools · vSNP GUI v0.4.80 · tree viewer, clicking a clade opens the
table for just those samples.
The three SNPs that S1, S2 and S3 share (highlighted, left) are the branch that groups
them (highlighted, right). Rows are aligned across both views. Branch length is proportional to the
number of SNPs, and the scale bar shows one SNP.
vSNP3 · Kapur Lab · Penn State · USDA
09
Validation/the v in vSNP
vSNP stands for validate SNP: any call can be checked in the read alignment.
In bdtools a cell in the cascading table is a linkbdtools · vSNP GUI v0.4.80 · cascade table:
clicking it opens the alignment at that position. When two isolates differ by only a few SNPs,
each position affects the result, so they are reviewed in the read alignmentbdtools · IGV · MTBC0:1,263,022
rather than taken from the table alone.
Cells that look the same in the table. The read alignment tells them apart, which is why
Step 1 keeps the BAM.
vSNP3 · Kapur Lab · Penn State · USDA
10
Summary/six properties
Six properties of the vSNP3 workflow.
What the preceding slides add up to.
01
Zero coverage is recorded
A gap is reported as missing data, never as agreement with the reference.
02
Step 1 and Step 2 are separate
Align once per sample; compare as often as you like.
03
One reference per dataset
Positions stay comparable. References are never mixed.
04
Grouping is yours to maintain
Defining SNPs are a curated file, not a clustering threshold.
05
Sample differences are visually validated
A table cell opens the read alignment at that position.
06
Every run is repeatable
Inputs, parameters and versions are stored with every run.
In bdtools every step above is a button, with the same layout as the other tools in the suite. The command line is optional.
vSNP3 · Kapur Lab · Penn State · USDA
11
Running it/five steps
Running vSNP3 in bdtools: five steps.
All of it in the browser. Allow about an hour, most of it unattended while Step 1 aligns.
01Open the dashboard and launch vSNP3bdtools · dashboard. Check the paths in Settings.
02Create a project and add inputsbdtools · vSNP GUI v0.4.80 · Projects & Inputs — server files, drag-and-drop, or SRA accessions.
03Step 1: choose the reference, then Runbdtools · vSNP GUI v0.4.80 · Step 1. This is the longest stage.
05Step 2: tick what to compare, then Runbdtools · vSNP GUI v0.4.80 · Step 2 Results. Read the table and tree together.
Practice data.docs/TRAINING.md Module 4 runs the whole workflow on nine public TB accessions; Module 5 scales it to a labelled MTBC panel. docs/TRAINING.html is the same guide as one standalone file you can email or hand out.