Scoring matrix calculator

Score an aligned pair with BLOSUM or PAM, view the matrices, or build a log-odds matrix from an alignment.

Result

What is a scoring matrix?

A scoring matrix, or substitution matrix, gives a score to every pair of residues that can face each other in an alignment. Alignment programs add these scores up over all columns, so the matrix decides which alignment is called the best. For proteins the scores arelog-odds values: they compare how often two amino acids are actually seen aligned in related proteins with how often they would meet by chance. Identical and chemically similar pairs (I/L, K/R, D/E) score positive, unlikely replacements (W/G, C/E) score negative.

How is a log-odds scoring matrix calculated?

s(i, j) = (1/λ) × ln [ q(i, j) ÷ (p(i) × p(j)) ]
  1. In every alignment column, count each pair of sequences once. This gives the pair counts f(i, j); a column with n residues contributes n(n − 1)/2 pairs.
  2. Divide by the total number of pairs T to get observed frequencies. Written as a symmetric table, q(i, i) = f(i, i)/T and q(i, j) = q(j, i) = f(i, j)/(2T).
  3. The background frequency of a residue is its row sum, p(i) = Σ q(i, j). The chance frequency of the pair is p(i) × p(j).
  4. The score is the logarithm of the odds ratio, multiplied by a scale factor 1/λ and usually rounded to an integer. With λ = ln 2 / 2 the score is 2 × log₂ of the ratio, in half bits. Third bits use λ = ln 2 / 3, and the original Dayhoff PAM tables used 10 × log₁₀.

The build mode follows these steps on your alignment and can display every intermediate table. It does not cluster or weight the sequences, which the published BLOSUM procedure does to keep closely related sequences from dominating the counts. Pairs that never occur have q = 0 and a score of −∞; a small pseudocount added to every pair count avoids this.

Worked example of a log-odds score

The build example is a DNA alignment of 6 sequences and 12 columns. Each column holds 6 × 5 / 2 = 15 pairs, so T = 180. C is aligned with C 30 times, which gives q(C, C) = 30/180 = 0.1667. The row sum for C is p(C) = 0.0111 + 0.1667 + 0.0167 + 0.0556 = 0.2500, so the chance frequency is 0.25 × 0.25 = 0.0625 and the odds ratio is 2.667. In half bits, s(C, C) = 2 × log₂ 2.667 = 2.83, rounded to 3. C faces T in 20 pairs: q(C, T) = 20/360 = 0.0556, expected 0.2500 × 0.2639 = 0.0660, ratio 0.842 and s(C, T) = −0.50. The transversion A/C is seen only 4 times and scores −4.82. Over the whole table the relative entropy is H = Σ q × log₂ ratio = 0.591 bits per pair and the expected score Σ p(i) p(j) s(i, j) is −1.35, negative as a usable matrix requires.

BLOSUM62, BLOSUM45, BLOSUM80, PAM120 or PAM250?

MatrixUnitsEntropy (bits)Use for
BLOSUM80half bits0.99closely related proteins, short queries
BLOSUM62half bits0.70general default, BLAST
BLOSUM45third bits0.38distant relatives, long alignments
PAM120half bits0.98closer relatives, about 40 % identity
PAM250third bits0.35distant relatives, about 20 % identity

The values are the integer matrices distributed with NCBI BLAST. BLOSUM80 is the BLAST version in half bits (A/A = 5); some packages ship a third-bit BLOSUM80 with larger numbers (A/A = 7), which describes the same odds ratios on a different scale. The relative entropy is the average information per aligned position: matrices with high entropy separate true from chance alignments over a short length but only for similar sequences.

How do you score an alignment with a substitution matrix?

score = Σ s(aₖ, bₖ) over all columns k without a gap

The score mode looks up every aligned pair in the chosen matrix and adds the values. The pair MVHLTPEEK / MVHLTDAEK scores 5 + 4 + 8 + 4 + 5 − 1 − 1 + 5 + 5 = 34 with BLOSUM62: seven identities, and P/D and E/A at −1 each. Identities are columns with the same residue, positives are identities plus substitutions with a score above zero, the definition BLAST uses. Both are given as a fraction of the compared columns; columns with a gap or a non-standard residue are not compared. Gap penalties are not part of a substitution matrix and are not subtracted here. To produce the alignment in the first place use the Needleman–Wunsch calculatoror the pairwise protein alignment; for identity and similarity across a whole multiple alignment use theidentity and similarity calculator.

Frequently asked questions

What is the BLOSUM62 matrix?

BLOSUM62 is a 20 × 20 table of log-odds scores for amino acid substitutions, built by Henikoff and Henikoff (1992) from ungapped blocks of conserved protein families in which sequences more than 62 % identical were clustered. Scores are in half-bit units: s = 2 × log2 of the observed pair frequency divided by the frequency expected by chance, rounded to an integer. W/W scores 11, A/A 4, K/R 2 and W/G −2. It is the default matrix of protein BLAST.

How is a log-odds score calculated?

Count how often residues i and j are aligned to each other, convert the counts to the observed pair frequency q_ij, and compare it with the frequency expected if the residues paired at random, p_i × p_j. The score is s_ij = (1/λ) × ln(q_ij / (p_i p_j)). With λ = ln 2 / 2 this equals 2 × log2 of the ratio, the half-bit scale of BLOSUM62. A positive score means the pair is seen more often than chance, a negative score less often.

What is the difference between BLOSUM and PAM matrices?

BLOSUM matrices are computed directly from observed substitutions in conserved blocks, clustered at a chosen identity level, so a higher number means more similar sequences (BLOSUM80 for close, BLOSUM45 for distant relatives). PAM matrices are extrapolated from a model of closely related sequences: PAM1 corresponds to 1 accepted mutation per 100 residues and is multiplied by itself, so a higher number means more divergence (PAM120 for closer, PAM250 for distant relatives).

Why do matrices with different units give different numbers for the same pair?

The integer in the table is the log-odds ratio multiplied by a scale factor and rounded. BLOSUM62, BLOSUM80 (BLAST version) and PAM120 use half bits (2 × log2), BLOSUM45 and PAM250 use third bits (3 × log2). To compare them, convert back to an odds ratio: a score of 11 in half bits is 2^(11/2), about 45 times more frequent than chance.

Does this tool align my sequences?

No. The score mode compares the two sequences column by column exactly as entered, so they must already be aligned and of equal length; gap columns are skipped. To align them first, use the Needleman–Wunsch or the pairwise protein alignment tool.