Shannon entropy calculator
Entropy in bits per symbol for a sequence, or for every column of an alignment.
Entropy in bits per symbol for a sequence, or for every column of an alignment.
Shannon entropy measures how evenly the symbols of a sequence are used. It is the average number of bits needed per symbol if the sequence were encoded using only its composition. A sequence that uses all letters equally has the maximum entropy; a repetitive or biased one has less.
pi is the fraction of symbol i. Symbols that do not occur contribute nothing. The normalised value runs from 0 (one letter only) to 1 (perfectly even composition) and lets DNA and protein be compared on one scale.
The example sequence ATGCGCGCTAGCTAGGCCAT has 20 bases: 4 A, 6 C, 6 G and 4 T, so the fractions are 0.2, 0.3, 0.3 and 0.2.
The maximum for DNA is 2 bits, so the normalised entropy is 1.9710 / 2 = 0.9855.
In the alignment tab, paste aligned sequences of equal length in FASTA format. The same formula is applied to each column, counting only residues (gaps and ambiguity codes are skipped). The example alignment has five sequences; column 1 is M in all of them, so H = 0, while column 3 holds L, L, I, L, V, which gives H = −(0.6 × log2 0.6 + 2 × 0.2 × log2 0.2) = 1.371 bits.
The table lists the most common residue, the entropy and the number of gaps for every column, and Copy gives the same table as tab-separated text.
For DNA and RNA: A, C, G and T or U (U is counted as T). For protein: the twenty standard amino acids. Ambiguity codes such as N, R, X or B, stop signs and gaps are not counted. The type is detected from the letters; set it by hand if a short peptide made of A, C, G and T is read as DNA.
2 bits per base, reached when A, C, G and T each make up exactly a quarter of the sequence. For proteins the maximum is log2(20) = 4.32 bits per residue, when all twenty amino acids are equally common.
The composition is biased: a few symbols make up most of the sequence. Homopolymer runs, microsatellites and low-complexity protein regions give low values. A sequence of a single letter has an entropy of 0.
No. It is computed from the composition alone, so ACGTACGTACGT and a shuffled version of it both give 2 bits. To find local low-complexity stretches, compute it for short windows, or use the alignment tab to look at columns.
Each alignment column is treated as its own small sequence. A fully conserved column has entropy 0 and a column where every residue type is equally common has the maximum. Low-entropy columns mark conserved positions such as active sites and binding motifs.
They are left out of the frequencies. In the alignment tab the number of gaps in each column is listed next to the entropy, because an entropy from only a few residues is not reliable.