Motif discovery and binding-site prediction in DNA and RNA are central tasks in regulatory genomics, but the methodological landscape is split between interpretable but rigid position weight matrices (PWMs) and high-performing but opaque machine-learning models.

KDM is a unifying framework in which both motifs and sequences are represented as probability distributions over a shared k-mer dictionary, embedded via the Hellinger transformation. This common geometry enables motif–sequence scoring, motif–motif comparison, de novo discovery and binding prediction with a single primitive: the Bhattacharyya coefficient.

A collaborative project with the Pozzoli lab @ Scientific Institute IRCCS E. Medea.

The four tools

Four tools are instantiated on this representation:

ToolPurpose
KDMFindUnsupervised de novo motif discovery via projective non-negative matrix factorization (PNMF)
KDMMapPositional Enrichment (PE) and Class Enrichment (CE) of motifs in labelled sequences
KDMMatchInformation-content-aware motif matching / annotation
KDM-LRLMBinding prediction with Lasso-regularized logistic regression
KDM overview: known motifs and DNA/RNA sequences are represented, embedded into a shared k-mer space by the Hellinger transformation, and compared with the Bhattacharyya coefficient; the four tools KDMMap, KDMMatch, KDMFind and KDM-LRLM are built on that single representation.

Represent — known motifs (via PWM2KDM) and positive/negative sequence sets (via k-mer encoding) enter the same pipeline. Embed — both become distributions over the dictionary D, Hellinger-embedded as motif matrix W and sequence matrix V. Compare, score, discover, predict — a single primitive, the Bhattacharyya coefficient BC = WTV, serves all four tools.

All the methods are implemented in a C++ library. We provide an R package as a wrapper.

⚠️ The current versions are those used in the paper. Both the library and the package are still under development to provide full access to all the functions and related parameters.

The functions in this tutorial are a simplified interface to the KDM library. To reproduce the results reported in the paper, use the scripts in CODE/R-SCRIPTS of the GitHub repository, where cross-validation folds are fixed within the datasets. Numbers obtained with this tutorial may therefore differ slightly from those in the paper.


Tutorial pages

The pages below follow a single worked example end to end — discovering the motifs bound by NRF1 from a set of bound and unbound sequences, annotating them, and training a predictive model.


Typical workflow

KDMDictionary()        # 1. choose the k-mer space
readRDS()              # 2. load bound (pseq) and unbound (nseq) sequences
KDMFind()              # 3. discover motifs de novo
KDMMap()               # 4. where are they, and are they enriched?
KDMMatch()             # 5. what known factors do they correspond to?
KDM.LRLM.train()       # 6. build a predictive model
KDM.LRLM.performance() # 7. evaluate it on held-out sequences
KDM — source on GitHub · preprint