Local Alignment & Dot Plot
Compare two DNA sequences with a dot plot and Smith-Waterman local alignment.
Learn more
What it does
This tool compares two DNA sequences in two complementary ways: a dot plot that marks every position where a base in one sequence matches a base in the other, and a Smith-Waterman local alignment that finds the single highest-scoring similar region and reports its score and identity. The dot plot shows the global picture of shared structure, repeats and inversions, while the alignment gives the exact matched segment with a visual match line. Each sequence is limited to 2000 base pairs because the algorithm compares every position against every other.
How it works
A dot plot places a dot at coordinate (i, j) whenever base i of sequence 1 equals base j of sequence 2, so an uninterrupted shared segment appears as a diagonal line, a repeated element appears as several parallel diagonals, and an inverted segment appears as a diagonal running the other way. Smith-Waterman then fills a scoring matrix with H(i, j) = max(0, H(i-1, j-1) + s, H(i-1, j) - gap, H(i, j-1) - gap), using match +2, mismatch -1 and gap -1 here, and traces back from the highest cell in the matrix until the score returns to zero. The zero floor is what makes the alignment local: a stretch of poor similarity resets the score instead of dragging it negative, so the algorithm can find a conserved island inside two otherwise dissimilar sequences, which is exactly how it differs from global Needleman-Wunsch alignment. Codes other than A, T, G, C and U are treated as mismatches.
Worked example
Compare sequence 1, ACGTACGTGG, with sequence 2, TTACGTACGTAA. The dot plot shows a clear diagonal offset by two positions, and Smith-Waterman recovers the shared block ACGTACGT aligned against ACGTACGT: 8 matched bases with no gaps, giving a score of 8 x 2 = 16. The flanking bases, GG at the end of sequence 1 and TT and AA in sequence 2, are excluded from the local alignment because extending into them would only lower the score.
When to use it
When a sequencing read behaves oddly, aligning it against a primer or adapter sequence shows whether the adapter is embedded in the read and where it starts. When comparing two alleles, paralogues or homologues from related species, the highest-scoring local region identifies the conserved core, and the dot plot reveals whether the rest of the similarity is a single block or interrupted by insertions. When checking a Sanger read against the expected construct, a clean single diagonal confirms the match, whereas parallel or reversed diagonals point to a tandem repeat or an inverted insert.
FAQ
- What is the difference between local and global alignment?
- Global alignment, as in Needleman-Wunsch, forces the two sequences to be aligned end to end and is appropriate when they are of similar length and expected to correspond overall. Local alignment, as in Smith-Waterman, finds the best-matching subregion and ignores everything else, which is what you want when one sequence is much shorter or when only a domain, motif or exon is conserved.
- What does a dot plot tell you about two DNA sequences?
- The pattern of dots is the information. A single long diagonal means the two sequences correspond over that stretch, a broken diagonal means insertions or deletions interrupt the correspondence, several parallel diagonals mean a repeated element, and a diagonal at right angles to the main one indicates an inverted or reverse-complement segment. Isolated scattered dots are just chance matches, since with four bases about one in four random pairs will match.
- Why is a match worth +2 and a mismatch -1?
- These are scoring parameters, not physical constants, and they set how much mismatch or gap a real alignment is allowed to absorb. Making the match reward large relative to the mismatch and gap penalties favours longer alignments that tolerate imperfection, while harsher penalties yield shorter, near-exact blocks. The scheme used here, match +2, mismatch -1, gap -1, is a common general-purpose choice for DNA.
- How long can the sequences be for local alignment?
- Up to 2000 base pairs each in this tool. Smith-Waterman builds a matrix with one cell per pair of positions, so time and memory grow as the product of the two lengths, and comparing two 2000 base pair sequences already means four million cells. For whole genes, chromosomes or database searches, use a heuristic tool such as BLAST, which finds seed matches first instead of scoring every position pair.