TL;DR
A multiple sequence alignment lines up three or more sequences, such as the same protein from several species, so that letters descended from the same position sit in the same column. A gap marks where one sequence has an insertion or deletion relative to the others. Finding the best alignment exactly is too expensive for many sequences, so most programs build it step by step: they align the most similar pair first, then add the remaining sequences one at a time.
Builds on: Sequence Alignment, Substitution Matrix, Phylogenetic Tree · Leads to: tree inference from aligned sequences, and searches that compare a new sequence against a whole family
Where it's used
Naming a gene in a new species. A lab sequences a gene from a newly found animal and wants to know whether it is the same gene as the human version. Aligning the new sequence with the human and mouse versions shows which columns agree. A long run of matching columns across all three is the sign that they share the gene.
Finding the parts of a protein that matter. Researchers align the same amino acid chain from dozens of species. A column where almost every species has the same residue is usually one that selection has kept, because the protein cannot change it without losing function, so the column is flagged as important. This is one of the standard ways to find the positions a protein depends on.
Building an evolutionary tree. Many tree methods take a multiple alignment as their input, so a mistake in the alignment becomes a mistake in the tree. Studies of how a virus has spread between hosts build their trees from aligned viral genomes, and the alignment is the first step of that work.
How it works
We use three short DNA sequences and a simple scoring rule: a match scores , a mismatch scores , and a gap scores . The sequences are ACGT, AGT and ACT. The goal is one alignment of all three with the best total score.
-
Score every pair. Align each pair with the pairwise method from Sequence Alignment. The results are: with scores , with scores , and with scores . For and the best line-up is ACGT over A-GT, with three matches and one gap, so . Check: the three pair scores are the only numbers this method needs.
-
Build a guide tree. Join the most similar pair first. and tie with and at , so we take and . Then joins last. The order is the guide tree, which says the order to build the alignment in. Check: the first join uses a pair with the highest score.
-
Align the first pair. The best alignment of and is ACGT over AC-T. Its score is . Check: this matches the pairwise score from step 1.
-
Add the third sequence to the alignment. Now AGT is aligned against the two-row alignment, which we treat as a profile of four columns: = A/A, = C/C, = G/-, = T/T. A letter of against a column scores the sum of its pair scores with each row, so G against G/- scores . A gap in against a column scores for each row that holds a letter. A letter of in a brand-new column, with gaps in both rows, scores . Each cell takes the best of three moves: a letter of against a profile column, a letter of in a new column, or a profile column against a gap in . Check: the top-right corner is the answer, and every cell is computed from cells above or to its left.
so far none none 0 -2 -4 -5 -7 A -2 2 0 -1 -3 G -4 0 0 0 -2 T -6 -2 -2 -2 2 -
Trace back. Start at the bottom-right value . It came from the diagonal, so T of sits in column . Next, the G cell in column came from the diagonal, so G sits in . The cell for column came from the left, so column faces a gap in . The A cell in came from the diagonal. The result is:
x A C G T z A C - T y A - G TCheck: the cell is the score the new sequence adds to the profile.
-
Score the whole alignment. Score each column by its three pairs. Column 1 (A, A, A) gives . Column 2 (C, C, -) gives . Column 3 (G, -, G) gives . Column 4 (T, T, T) gives . The total is . Check: this is the profile score plus the added score , so both routes agree on .
flowchart LR
A["Score every pair of sequences"] --> B["Build a guide tree from the scores"]
B --> C["Align the most similar pair"]
C --> D["Add the next sequence to the alignment as a profile"]
D --> E{"Sequences left?"}
E -->|yes| D
E -->|no| F["Final alignment and its score"]
The math
An alignment of sequences with columns has an entry in row and column , which is either a letter or a gap. Let be the pair score, with and . The sum-of-pairs score is
Each column is scored by all its pairs of rows, and each pair of rows is counted once.
Step 2 in symbols: the guide tree
The pairwise scores , and come from the pairwise method. The first join is the pair with the largest . Here two pairs tie at , and we take .
Step 4 in symbols: adding a sequence to a profile
Let the profile have rows and columns , and let be the new sequence. Define three scores:
- , the score of letter against profile column ;
- , the score of a gap in against column ;
- , the score of letter in a new column.
Then the dynamic programming table , the best score for the first letters of and the first profile columns, satisfies
In the walkthrough and , so . The gap scores are , and because holds only one letter. The edges are and . For example is the bottom-right value.
Step 6 in symbols: the total score
The profile already had sum-of-pairs score , and the new sequence adds . The sum of the two is , which is the sum-of-pairs score of the final alignment. This is no accident: the recurrence adds only the new pairs, so the total matches the definition.
Worked examples
Sequences A, A and C, with match and mismatch . No gaps are needed, because every sequence has one letter.
- Pair the first and second sequences: A with A scores .
- Pair the first and third: A with C scores .
- Pair the second and third: A with C scores .
- The total is .
Interpretation: there is only one possible alignment, so the score is just the sum over pairs. The mismatch costs one point each time it appears, and it appears twice.
Score the alignment below with match , mismatch and gap .
x A C G - T
y A C G A T
z A - G A T
- Column 1 (A, A, A): three pairs, each , so the column scores .
- Column 2 (C, C, -): the pair and scores ; the pairs and and and each have a letter against a gap, so each scores . The column scores .
- Column 3 (G, G, G): three pairs, each , so the column scores .
- Column 4 (-, A, A): the pair and scores ; the pairs with and with each have a gap against a letter, so each scores . The column scores .
- Column 5 (T, T, T): three pairs, each , so the column scores .
- The total is .
Interpretation: each gap-letter pair scores , where a match would score , so each one costs two points relative to a match. The two gap columns here hold four such pairs. The score rewards the columns that agree and charges for each gap.
Suppose one column of a four-species alignment of a binding site holds the residues K, K, K and R, in the order human, mouse, chicken and frog. These letters are illustrative, not from a real protein. The question is what fraction of the species pairs agree at this column.
- Four sequences give pairs of species.
- The three K residues agree with each other in pairs.
- The R residue differs from each K, so it contributes no agreeing pair.
- The fraction of agreeing pairs is .
Try it: a column reads K, K, R, R. How many pairs agree, and what fraction is that? Answer: the two K residues agree in one pair and the two R residues agree in one pair, so of the pairs agree, and the fraction is .
Interpretation: half of the pairs agree in the first column, which suggests the residue has mostly been kept, with the frog as the one change. Real studies weight each change by a substitution matrix rather than just counting identical pairs.
Common mistakes and tradeoffs
It is tempting to think that a multiple alignment is just the best pairwise alignment done for every pair. In fact the pairwise alignments can disagree about where gaps go, and they cannot always be combined into one consistent alignment of all sequences.
It is tempting to think that the order of joining does not matter. In fact an early decision is frozen. A gap placed while two sequences are aligned stays in every later alignment, so a poor first step can spoil the result. Methods that revisit and realign the sequences after the first build reduce this problem.
It is tempting to delete every column that contains a gap before building a tree. In fact such a column can be real: it marks a deletion in some species. Removing it discards information and can change the tree, so trimming is a choice to be checked, not a free clean-up.
Exact multiple alignment is a dynamic programming table with one dimension per sequence. For sequences of length it has about cells, so it is practical only for a few short sequences. When to use it. Use an exact or iterative method for a small set of sequences where accuracy matters most. Use a progressive method, which follows a guide tree, for dozens to thousands of sequences. When not to use it. Do not treat the output as a fact about evolution: it depends on the scoring, the guide tree and the gap penalties.
History
Saul Needleman and Christian Wunsch published their pairwise method in 1970, as described in the pairwise lesson. For several sequences, Feng and Doolittle published a progressive method in 1987 that builds the alignment in the order of a guide tree.
In 1988 the CLUSTAL program, by Higgins and Sharp, made progressive alignment a standard tool. CLUSTAL W, published in 1994, added weighting of sequences and gap penalties that depend on position. Later programs such as MAFFT, in 2002, and MUSCLE, in 2004, improved speed and accuracy by refining the alignment after building it.
Progressive alignment caught on because it turned a problem that could not be solved exactly into one that a desktop computer could finish in a reasonable time, and its results were good enough for most uses.
Recap
- A multiple alignment places letters from many sequences in shared columns, with gaps for insertions and deletions.
- Its score is the sum over columns of the pair scores, the sum-of-pairs score.
- The exact table has about cells, so most programs align progressively.
- A guide tree, built from the pairwise scores, sets the order; each step adds one sequence to a growing profile.
- Early gap decisions are kept, so refinement methods that revisit them matter.
Read next: Hidden Markov Model for a model that scores a new sequence against an alignment, and Phylogenetic Tree for what the alignments are used to build.
Check yourself
QuestionRecall: what are the two parts of the sum-of-pairs score, and what is the score of a gap against a gap?Show answer
The score adds the pair scores within each column, and it counts every pair of rows in that column once. The score of a gap against a gap is zero, because two gaps show no evidence either way.
QuestionComputation: with match , mismatch and gap , what is the sum-of-pairs score of the column A, A, G, -?Show answer
The four rows give six pairs. The pair of the two As scores . Each of the two As against G scores , which is . Each of the two As against the gap scores , which is . The G against the gap scores . The total is .
QuestionWhy: why can the best pairwise alignments not simply be combined into one multiple alignment?Show answer
Each pairwise alignment places its gaps to suit only the two sequences it compares. Two pairs can then disagree about where a gap belongs in a shared sequence, so no single set of columns agrees with every pairwise result. A method must choose one order and one set of gap placements, which costs some optimality.
QuestionApplied scenario: before building a tree, a colleague deletes every column that has a gap. What would you check before agreeing?Show answer
Check how many columns are removed and whether the gaps cluster in one sequence. A block of gaps at one end of a single sequence usually means that sequence is incomplete rather than that the species has a deletion there. Then compare the trees built with and without the trimming. If the tree changes a lot, the trimming is driving the result, and the choice should be stated and justified.