2
$\begingroup$

I am trying to create a sequence logo, and I am completely confused by how to determine the height/bits for each column. So, for example I understand how to create the flat sequence logo: (add up all the letters, the letters should represent their ratio for that position) but not the normal sequence logo:.

I have been reading this paper "WebLogo: A Sequence Logo Generator" again and again and I can't figure out how to determine the bits/height for each given position.

$\endgroup$
  • $\begingroup$ Can you provide a link to the paper you're referring to? I believe I've found it myself, however, there is no mentioning of normalizing data. $\endgroup$ – user22020 Aug 3 '17 at 18:49
  • $\begingroup$ It's weblogo.berkeley.edu/Crooks-2004-GR-WebLogo.pdf $\endgroup$ – nosefouratyou Aug 3 '17 at 20:53
1
$\begingroup$

Wikipedia has a page on sequence logo which discusses the calculation briefly.

The "bits" here are related to those used in Shannon entropy. This is an information-theoretic equivalent to the Boltzmann entropy from thermodynamics. This is a measure of how "disordered" the position is, or more precisely how specific the distribution is.

The general formula for the total entropy (expressed based on probabilities/fractions) is

$$ S = -k \sum_i p_i \cdot log( p_i ) $$

where $i$ ranges across all the various states (e.g. each nucleotide).

The difference between Shannon entropy and Boltzmann entropy (aside from the contexts where it's used) is the value of the constant (one for Shannon, Boltzmann's constant for Boltzmann entropy) and which logarithm used (the natural logarithm for Boltzmann entropy, and typically base-2 for Shannon entropy.) As it uses base-2 logarithms, the Shannon entropy is typically measured in units named "bits".

The wrinkle is that the entropy of a distribution isn't really what you want to display in a sequence logo. Instead, you want something that gets larger (not zero) when the sequence becomes more defined. As such, the values displayed are not the entropy itself, but the "entropy loss" from a completely random (maximal entropy) distribution.

That's how you get the total number of bits at a position (the total height). The height of the individual letters comes by taking the total height and multiplying it by the probability of each state. This might not have rigid theoretical justification (you can't attribute the entropy loss to individual nucleotides like that), but it fulfills the display purposes of making the more prevalent nucleotide identities larger in display size.


For example, if you have a position with 70% G and 30% C, then you have $$ (4 \cdot -0.25 \cdot log_2(0.25)) - (-0.7 \cdot log_2( 0.7 ) + -0.3 \cdot log_2( 0.3 )) = 1.12$$ bits of total height. G gets a height of $1.12 *0.7 = 0.78$ bits, whereas C gets $1.12 *0.3 = 0.34$ bits.

|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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