Following this question, I'm confused with the computation of sequence logo

Following data comes from the book "Machine Learning - A Probabilistic Perspective (Figure_1)"

enter image description here

here is the corresponding sequence logo (Figure_2).

enter image description here

ten rows represent sequences of DNA (e.g. row 1 could be a human sequence, row 2 could be the equivalent mouse sequence etc.)

Each column corresponds to a particular position.

Why do ten rows (Figure_1) correspond to 2 bits (Figure_2)?

  • 1
    $\begingroup$ You can find on e.g., wiki how a sequence logo is created. $\endgroup$
    – benn
    Jul 29, 2019 at 15:37

1 Answer 1


Bits are not frequencies. If a position only contains an A (position 3 for example) then you would need 2 questions (bits) to derive that information without a priori knowledge.

  1. Is it a G or C? if no > then it is a A or T
  2. Is it T? If no then it is an A

Position 1 can be derived by 1 question only:

  1. is it a G or C? If no then it is an A or T

In this case the number of bits can be calculated using the frequenci)es.

For 4 bases, A only (100%):

4 * -0.25 * log2(0.25) - (-1 * log2(1)) = 2 (bits)

For 8 letters, A only (100%):

8 * -1/8 * log(1/8)- (-1 * log2(1)) = 3 (bits)

Mixed base possibility (A/T 50% each) with 4 bases:

4 * -0.25 * log2(0.25) - (-0.5 * log2(0.5)+-0.5 * log2(0.5)) = 1 (bit)

As mentioned in the comments, you can follow the wiki link for an example.

Or, an example with a little more explanation from the biology SE site.

sequence logo calcuation

Hopes this helps

  • $\begingroup$ Thanks for your answer. In this specific case, 4 bases is being used, since there are a,t,g,c 4 Nucleotides in total, right? $\endgroup$
    – czlsws
    Jul 30, 2019 at 3:15
  • 1
    $\begingroup$ correct. That is this part: 4 * -0.25 * log2(0.25) of the equation. $\endgroup$
    – Mack123456
    Jul 30, 2019 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.