## Abstract

Sequence analysis frequently requires intuitive understanding and convenient representation of motifs. Typically, motifs are represented as position weight matrices (PWMs) and visualized using sequence logos. However, in many scenarios, in order to interpret the motif information or search for motif matches, it is compact and sufficient to represent motifs by wildcard-style consensus sequences (such as [GC][AT]GATAAG[GAC]). Based on mutual information theory and Jensen-Shannon divergence, we propose a mathematical framework to minimize the information loss in converting PWMs to consensus sequences. We name this representation as sequence Motto and have implemented an efficient algorithm with flexible options for converting motif PWMs into Motto from nucleotides, amino acids, and customized characters. We show that this representation provides a simple and efficient way to identify the binding sites of 1156 common transcription factors (TFs) in the human genome. The effectiveness of the method was benchmarked by comparing sequence matches found by Motto with PWM scanning results found by FIMO. On average, our method achieves a 0.81 area under the precision-recall curve, significantly (*P*-value < 0.01) outperforming all existing methods, including maximal positional weight, Cavener’s method, and minimal mean square error. We believe this representation provides a distilled summary of a motif, as well as the statistical justification.

MOTIF analysis is crucial for uncovering sequence patterns, such as transcription factor (TF) binding sites (Thompson *et al.* 2003), splicing sites (Murray *et al.* 2008), DNA methylation patterns (Wang *et al.* 2019), and histone modifications (Ngo *et al.* 2019b). A motif is typically represented as a position weight matrix (PWM), in which each entry shows the occurrence frequency of a certain type of nucleic acid at each position of the motif. PWMs are often visualized by the sequence logo (Schneider and Stephens 1990), which requires a graphical interface. However, when in a textual interface, representing PWMs requires an n by k matrix, where n is the number of characters (such as A, C, G, T, for nucleotides), and k is the length of the motif. Recently, several studies have shown the usefulness of representing motifs using kmers (Fletez-Brant *et al.* 2013; Ghandi *et al.* 2014; Zeng *et al.* 2016; Guo *et al.* 2018); despite the power of this representation in machine learning models, it is cumbersome to have a set of kmers to characterize a single motif. In many scenarios, motifs can be sufficiently represented by regular expressions of the consensus sequences, such as [GC][AT]GATAAG[GAC] for the GATA2 motif. This representation is the most compact and intuitive way to delineate a motif. In the GATA2 motif example, the GATAAG consensus in the center is the most prominent pattern that would be read off the PWM or sequence logo. For this reason, consensus sequences are still widely used by the scientific community. Consensus sequences in regular expression form are the only supported textual format to highlight motif occurrence in popular genome browsers such as UCSC (Kent *et al.* 2002) and IGV (Robinson *et al.* 2011). Consensus sequences are assigned to *de novo* motifs and sequences for informative denotations (Bailey *et al.* 2009; Heinz *et al.* 2010; Whitaker *et al.* 2015; Wang *et al.* 2019). Wildcard-like sequence patterns are also supported in DNA oligo libraries synthesis by major vendors including Invitrogen, Sigma-Aldrich, and Thermo-Fisher.

However, current methods that convert PWMs to consensus sequences are often heuristic. One simple approach is taking the nucleotide with maximal frequency at each position to define the consensus sequence (*e.g.*, GGTCAAGGTCAC for ESRRB). Unsurprisingly, this could misrepresent positions with similar frequencies (*e.g.*, 0.26, 0.25, 0.25, 0.24, which should have been assigned as N). Alternatively, in 1987, Cavener proposed to follow a set of rules: use the single nucleotide with the highest frequency when it exceeds 0.50 and two times the second-highest frequency; else, use the top two dinucleotides when their total frequencies exceed 0.75; else, use N (Cavener 1987). However, these rules are arbitrary, inflexible, and lack a mathematical framework.

Here, we present Motto, a sequence consensus representation of motifs based on information theory, which ensures minimal information loss when converted from a PWM (Figure 1). We provide a standardized solution that determines the optimal motif consensus sequence. We have also implemented a lightweight and easy-to-use Python package with versatile options for biologists.

## Materials and Methods

A positional weight matrix (PWM) defines the probability of the jth character (out of n characters) at the ith position (out of k positions), where and For a given position let denote a output consensus character set, where m is the number of characters to be presented, and let denote the perceived frequencies for a combination of m characters, defined by equal frequencies shared among included characters:For example, a is a case for and with frequencies of [0.333, 0.333, 0, 0.333] for [A, C, G, T], respectively. Thus, we consider the optimal consensus sequence as a series of combination of characters that has the most similarity between and for each position

For convenience, in the following discussion we will omit the index i when possible, as we note that optimal is independent of the position under consideration. To further simplify the discussion, we use the second position of the human TF P73 (Figure 1), where the and for demonstration below.

### Motto method using minimal Jensen-Shannon divergence

Here, we propose to use Jensen-Shannon divergence (JSD) to measure the similarity between and JSD has been widely used in information theory to characterize the difference between distributions (Lin 1991). Using this metric, the combination of nucleotides with the least JSD from to P will have the minimal “information loss,” and is thus considered as the optimal consensus nucleotide.

To efficiently compare JSD between all possible nucleotide combinations, we propose the following algorithm (Figure 1). First, we sort the nucleotides of the PWM in descending order, so that:For example, at the second position of the human TF P73 (Figure 1), the nucleotides are sorted by occurrence frequencies so that:Next, we reasoned that if a nucleotide with probability is included in the output consensus sequence set, then all nucleotides with frequencies larger than must also be included. Therefore, the optimal consensus character set M (denoted as ) is given by the optimal m(denoted as ), where:For example, if , then the optimal output character set will be where

The closer this distribution is to the original distribution of nucleotide frequencies, the better approximation of the consensus motif is to the original PWM. Thus, can be determined by minimizing the JSD between the two distributions:Here, is the ambiguity penalty, a parameter input from the user to penalize a larger in case a more definite output is preferred. When (the default value), the optimal marks the canonical minimal JSD, which we deem to have retained the most information about the original PWM. When is guaranteed to be 1, thus the output consensus nucleotide is equivalent to using nucleotides with the maximal frequency.

Thus, the optimal consensus nucleotide set at the ith position is:Repeat this procedure for every position , the final optimal consensus sequence is given by:

### Minimal mean squared error method

For comparison purposes, we have also implemented a minimal mean squared error (MSE) method, which is another metric used widely to measure distribution discrepancy (Lele 1993). The rest of the implementation is unchanged, except that the optimal m is now determined by minimizing the MSE between the two distributions:

### Evaluating motif occurrence sites

We have collected 1156 common TFs from human and mouse from the databases of Transfac (Matys *et al.* 2006), Jaspar (Portales-Casamar *et al.* 2010), Uniprobe (Robasky and Bulyk 2011), hPDI (Xie *et al.* 2010), and HOCOMOCO (Kulakovskiy *et al.* 2018). Each PWM is converted into consensus sequences, using default options of the four discussed methods: JSD (described above), MSE (described above), Cavener (Cavener 1987), and the naive approach of using the maximal frequency. Motif occurrence sites are determined in the human genome (hg19), matched by their regular expressions. The ground truth of the occurrence sites is determined by scanning the original PWMs with FIMO (Grant *et al.* 2011) using a 1e-5 *P*-value cutoff. The resulting *P*-values are converted into a significance score [−log(*P*-value)] and assigned to the matched motif occurrence sites from sequence Mottos. Thus, the area under the precision-recall curves (Davis and Goadrich 2006) (auPRC) is calculated by comparing the motif occurrence sites and their significance scores. Resulting auPRCs are averaged and a paired (by each motif) *t*-test is conducted to determine performance. Comparisons with significance (*P*-value < 0.01) are shown (Figure 3).

### Data availability

The authors state that all data necessary for confirming the conclusions presented in the article are represented fully within the article. Motto is freely available at https://github.com/MichaelMW/motto. Motto representation of all 1156 common TFs, as well as their sequence logo used in this study can be found at http://wanglab.ucsd.edu/star/motto.

## Results and Discussion

Motto takes the MEME format of PWM as the input because of its popularity. The MEME format is supported by the majority of the motif databases (Kulakovskiy *et al.* 2018), and the MEME suite provides packages for integrative analysis and conversion from other motifs formats (Bailey *et al.* 2009). The recently proposed kmer-based motif models also support conversion to MEME format (Fletez-Brant *et al.* 2013; Ghandi *et al.* 2014; Zeng *et al.* 2016; Guo *et al.* 2018). Our package is lightweight and open-source. The algorithm is efficiently implemented in Python and the conversion for 1000 motif sequences typically takes <2 sec. In addition, perhaps expectedly, downstream analysis like matching motif occurrences using Motto is much faster (∼5 sec for a common PWM on a chromosome, implemented inhouse with Python) than a conventional PWM scanning (about 1 min, scanned with FIMO (Grant *et al.* 2011)). By default, the Motto package takes a motif in the MEME format, parses the header to get the nucleotide, computes the optimal consensus sequences based on the Motto method, and then outputs the sequence in a compact format (Figure 1). Motto provides flexibility at each step along this process. Input can be from a file, or from standard input, and Motto can consider nucleotides, amino acids, and customized characters such as CpG/non-CpG methylation (Ngo *et al.* 2019a) and protein phosphorylation (Amanchy *et al.* 2011). We have provided four methods for comparison: maximal probability (Max), heuristic Cavener’s method (hereafter referred to as Cavener), minimal MSE method, and our proposed Motto method using the minimal JSD (Motto) (see *Materials and Methods*). Three output styles are provided: (1) IUPAC uses a single character to represent the combination of nucleotides (*e.g.*, S for [CG]) and is the most compact form, but requires reference to the nomenclature (Johnson 2010); (2) regular expression (“regex”) enumerate all output consensus nucleotide ranked by occurrences and is recommended for downstream analysis, such as motif occurrence and oligo designs; (3) “compact” (the default) is the same as “regex,” except that it replaces [ACGT] with N. To trim off Ns ([ACGT]s) at both ends of the output sequences, a optional flag “–trim” is provided. If the users prefer consensus with more certainty (*e.g.*, prefer [AC] to [ACG]), they can use either “–maxCharacter” as a hard limit to the number of characters allowed, or use “–penalty” to penalize ambiguity (see *Materials and Methods*).

Effects of these options are shown using an example of human TF CTCF (Figure 2, upper panel). Unsurprisingly, MSE, Motto, and Cavener are more representative than the naive maximal probability methods. For example, positions 1, 2, 3 and 20 with low information content (<0.2) in CTCF, are justifiably called as “N” by Motto and Cavener, which is an improvement over strictly calling the top nucleotide. MSE considers [TCG] and [GAT] more representative at the first and the third position but agrees with Motto and Cavener at the 2nd and 20th. Similarly, Motto, MSE, and Cavener successfully capture strong double-consensus patterns at indices 7, 11, 12 and 16, which maximal probability fails to capture. The advantage of Motto over Cavener is noticeable at index 6, where the logo of CTCF shows a dominating AG consensus. While Motto finds this co-consensus, Cavener disregards G that barely misses the cutoff. In addition, at index 19, the logo of CTCF shows a strong three-way split among A, G and C, but Cavener, by its rules (as described previously), ignores all such triple patterns. In addition, among the four methods, only the Motto and MSE are capable of generating consensus sequences for amino acid motifs (Bailey and Elkan 1994) (Figure 2, lower panel). Due to its arbitrary nature, heuristic methods like Cavener have difficulties defining decision boundaries for motifs of more than four nucleotides or customized character sets found in motifs containing methylated DNA (Ngo *et al.* 2019a) and phosphorylated amino acids (Amanchy *et al.* 2011). In such cases, Motto and MSE provide more mathematically rigorous information than Cavener and oversimplified maximal consensus methods. With increased penalty level at 0, 0.2, 0.5,and 1 respectively, the consensus sequence smoothly progresses toward single nucleotide consensus (Figure 2). Such flexibility gives an advantage to users that are biased toward more defined consensus results.

To quantify how well these four methods summarize the information in the original PWMs, we converted 1156 common human and mouse TFs to consensus sequences and compared their matched occurrences (by regular expression) in the human genome (hg19) with conventional motif sites scanned by FIMO (Grant *et al.* 2011) with PWMs, which is how conventionally motif sites are determined (see *Materials and Methods*). We observe that using the Motto method has resulted in the best (0.81 ± 0.01) area under the Precision-Recall curve (auPRC), significantly (*P*-value < 0.01) better than existing alternative methods, including MSE (0.76 ± 0.01), Cavener (0.76 ± 0.01), and maximal frequency (0.53 ± 0.04) (Figure 3). In addition, we observed Motto performs better with lower ambiguity penalty, where the default setting with minimal ambiguity penalty (–*P* = 0) performs significantly (*P*-value < 0.01) better than setting penalty at 0.2 (0.78 ± 0.01) or 0.5 (0.76 ± 0.01) (Figure 3). This is consistent with the finding that setting the ambiguity penalty to the maximal value of 1 (–*P* = 1) is equivalent to using the max frequency method, resulting in the worst performance. These results confirm that Motto conversion minimizes information discrepancy (per JSD) from the original PWM, while setting larger penalties will result in more determined sequences at the cost of accurately recapitulating the original PWM.

In summary, Motto provides a mathematical framework and a set of convenient features to textualize PWMs in a compact, intuitive and accurate manner.

## Acknowledgments

This work was partially supported by National Institutes of Health (NIH) (U54HG006997 R01HG009626) and California Institute for Regenerative Medicine (CIRM) (RB5-07012). The authors declare no conflict of interest.

Author contributions: M.W. conceived the idea, implemented the package, performed the analyses, and wrote the manuscript; D.W. implemented key aspects of the package, contributed to the data analysis and manuscript preparation; K.Z., V.N., and S.F. contributed to data analysis and manuscript preparation; W.W. supervised the analyses of the project and contributed to manuscript preparation.

## Footnotes

*Communicating editor: D. Nielsen*

- Received May 31, 2020.
- Accepted August 17, 2020.

- Copyright © 2020 Wang
*et al*.

Available freely online through the author-supported open access option.

This is an open-access article distributed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.