Position-specific scoring matrix

A position weight matrix (PWM), also called position-specific weight matrix (PSWM) or position-specific scoring matrix (PSSM), is a commonly used representation of motifs (patterns) in biological sequences.

A PWM is a matrix of score values that gives a weighted match to any given substring of fixed length. It has one row for each symbol of the alphabet, and one column for each position in the pattern. The score assigned by a PWM to a substring $$s=(s_j)_{j=1}^N$$ is defined as $$\textstyle \sum_{j=1}^{N}{m_{s_j,j}}$$, where $$j$$ represents position in the substring, $$s_j$$ is the symbol at position $$j$$ in the substring, and $$m_{\alpha,j}$$ is the score in row $$\alpha$$, column $$j$$ of the matrix. In other words, a PWM score is the sum of position-specific scores for each symbol in the substring.

Basic PWM with log-likelihoods
A PWM assumes independence between positions in the pattern, as it calculates scores at each position independently from the symbols at other positions. The score of a substring aligned with a PWM can be interpreted as the log-likelihood of the substring under a product multinomial distribution. Since each column defines log-likelihoods for each of the different symbols, where the sum of likelihoods in a column equals one, the PWM corresponds to a multinomial distribution. A PWM's score is the sum of log-likelihoods, which corresponds to the product of likelihoods, meaning that the score of a PWM is then a product-multinomial distribution. The PWM scores can also be interpreted in a physical framework as the sum of binding energies for all nucleotides (symbols of the substring) aligned with the PWM.

Incorporating background distribution
Instead of using log-likelihood values in the PWM, as described in the previous paragraph, several methods uses log-odds scores in the PWMs. An element in a PWM is then calculated as $$m_{i,j}=log(p_{i,j} / b_i)$$, where $$p_{i,j}$$ is the probability of observing symbol i at position j of the motif, and $$b_i$$ is the probability of observing the symbol i in a background model. The PWM score then corresponds to the log-odds of the substring being generated by the motif versus being generated by the background, in a generative model of the sequence.

Information content of a PWM
The information content (IC) of a PWM is sometimes of interest, as it says something about how different a given PWM is from a uniform distribution. The self-information of observing a particular symbol at a particular position of the motif is $$-log(p_{i,j})$$. The expected (average) self-information of a particular element in the PWM is then $$-p_{i,j} \cdot log(p_{i,j})$$. Finally, the IC of the PWM is then the sum of the expected self-information of every element: $$\textstyle -\sum_{i,j} p_{i,j}\cdot log(p_{i,j})$$.

Often, it is more useful to calculate the information content with the background letter frequencies of the sequences you are studying rather than assuming equal probabilities of each letter (e.g. the GC-content of DNA of thermophilic bacteria range from 65.3 to 70.8 [1], thus a motif of ATAT would contain much more information than a motif of CCGG). The equation for information content thus becomes $$\textstyle \sum_{i,j} p_{i,j}\cdot log(p_{i,j}/p_{b})$$ where $$p_{b}$$ is the background frequency for that letter.