CountMatrix#

class lightmotif.CountMatrix(values, *, protein=False)#

A matrix storing the count of a motif letters at each position.

normalize(pseudocount=None)#

Normalize this count matrix to obtain a position weight matrix.

This method converts the count matrix to a weight matrix. Each row from the matrix is normalized so that they sum to 1.0. Each element is then divided by a uniform background probability to obtain odds-ratio at every position of the motif. Pseudocounts can be given to prevent zero elements, which may translate into -∞ scores in the final position-specific scoring matrix.

Parameters:

pseudocount (float, dict or None) – The pseudocounts to apply before normalizing the count matrix. If a float is given, then a similar pseudocount is applied to every column of the matrix (excluding the default symbol). Otherwise, a dict may be given to map each symbol of the alphabet to a distinct pseudocount. If None given, no pseudocount is used.

protein#

True if the count matrix stores protein counts.

Type:

bool