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,dictorNone) – The pseudocounts to apply before normalizing the count matrix. If afloatis given, then a similar pseudocount is applied to every column of the matrix (excluding the default symbol). Otherwise, adictmay be given to map each symbol of the alphabet to a distinct pseudocount. IfNonegiven, no pseudocount is used.