Skip to main content

TF-MoDISco

TF-MoDISco (Transcription Factor Motif Discovery from Importance Scores) is an algorithm for discovering sequence motifs from machine-learning-model-derived importance scores. Unlike traditional motif discovery methods that rely solely on sequence enrichment, TF-MoDISco leverages context-aware importance scores to identify patterns.

These importance scores can be generated using various attribution methods, such as DeepLIFT or SHAP, applied to models like BPNet. The algorithm identifies high-importance regions (seqlets), clusters them into motifs, and provides a report comparing discovered motifs to known databases.

Algorithm Description

The TF-MoDISco algorithm starts with a set of importance scores on genomic sequences and performs the following tasks:

  1. Identify high-importance windows of the sequences, termed "seqlets"
  2. Divide the seqlets into positive and negative sets (metaclusters) based on the overall importance score of each seqlet
  3. Cluster recurring similar seqlets
  4. Generate motifs by aligning the clustered seqlets

During clustering, a coarse-grained similarity is calculated as the cosine similarity between gapped k-mer representations between all pairs of seqlets. This information is used to calculate the top nearest neighbors, for which a fine-grained similarity is calculated as the maximum Jaccard index as two seqlets are aligned with all possible offsets. This sparse similarity matrix is then density adapted, similarly to t-SNE, and Leiden clustering is used to extract patterns. Finally, some heuristics are used to merge similar patterns and split apart the seqlets comprising dissimilar ones.

image

References

TF-MoDISco is described in:

Wang, Tseng, Ramalingam, Schreiber, et al. "Decoding predictive motif lexicons and syntax from deep learning models of transcription factor binding profiles." (manuscript in preparation)

Related tools:

  • Fi-NeMo: Motif instance detection using TF-MoDISco patterns
  • BPNet: Deep learning models for TF binding prediction
  • ChromBPNet: Deep learning models for chromatin accessibility prediction

Installation

TF-MoDISco requires Python 3.9 or newer. Leiden is pinned to version 0.11.0 to keep clustering results consistent; its igraph dependency requires Python 3.9 or newer.

You can install TF-MoDISco using pip install modisco

Running TF-MoDISco (test)

You can run TF-MoDISco using the command line tool modisco which comes with the TF-MoDISco installation. This tool allows you to run TF-MoDISco on a set of sequences and corresponding attributions, and then to generate a report (like the one seen above) for the output generated from the first step.

modisco motifs -s ohe.npz -a shap.npz -n 2000 -o modisco_results.h5

This command will run modisco on the one-hot encoded sequences in ohe.npz, use the attributions from shap.npz, use a maximum of 2000 positive/negative seqlets (this is low, but a good starting point for testing the algorithm on your own data), and will output the results to modisco_results.h5. The one-hot encoded sequences and attributions are assumed to be in length-last format, i.e., have the shape (# examples, 4, sequence length). Note that you can also use npy files if you don't want to use compressed data for some reason.

The output saved in modisco_results.h5 will include all of the patterns and has the following struture:

pos_patterns/
    pattern_0/
        sequence: [...]
        contrib_scores: [...]
        hypothetical_contribs: [...]
        seqlets/
            n_seqlets: [...]
            start: [...]
            end: [...]
            example_idx: [...]
            is_revcomp: [...]
            sequence: [...]
            contrib_scores: [...]
            hypothetical_contribs: [...]
        subpattern_0/
            ...
    pattern_1/
        ...
    ...
neg_patterns/
    pattern_0/
        ...
    pattern_1/
        ...
    ...

where [...] denotes that data is stored at that attribute. Importantly, the seqlets are all in the correct orientation. If a seqlet has been flipped to be the reverse complement, the sequence, contribution scores, and coordinates have also been flipped. In cases where there are not enough seqlets to consider a metacluster, that attribute (neg_patterns or pos_patterns) may not appear in the file.

Generating reports

The TF-MoDISco report can be generated with the following command:

modisco report -i modisco_results.h5 -o report/ -s report/ -m motifs.txt

Each pattern produced by TF-MoDISco is compared against the database of motifs using TOMTOM. A good default choice is this collection of human motifs produced by the MotifCompendium package.

The report details each pattern, including seqlet importance and spatial distributions, example seqlets at different importance levels, and motif visualizations.

For users who need the legacy report format use:

modisco report-simple -i modisco_results.h5 -o simple_report/ -m motifs.txt

Metadata

Release files for modisco-lite 3.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for modisco-lite 3.0.0
File Size Uploaded
modisco_lite-3.0.0.tar.gz 168.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for modisco-lite 3.0.0
File Interpreter ABI Platform
modisco_lite-3.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 286.9 kB

Release files / modisco_lite-3.0.0.tar.gz

Download URL modisco_lite-3.0.0.tar.gz
Size 168.3 kB
Tags Source
SHA-256 checksum
How to use checksums
733fe1699a144f6e93fa45aabebfe8ca1ff7be13c7e95d138ea9cc26e60698ce
BLAKE2b-256 checksum
How to use checksums
a6645235f30e38d5fedd212728a6e0f9ece2476c65dba63032639cbd8a7104c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / modisco_lite-3.0.0-py3-none-any.whl

Download URL modisco_lite-3.0.0-py3-none-any.whl
Size 118.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
264a350690b1786081757cd68a90fbe6271e9d765c6f14b9a6309424f821ca8d
BLAKE2b-256 checksum
How to use checksums
845dc7e956c99d51a11ff03781d1c5bc36f5c6f4975e5ffa36f1e05aed75eb66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

3.0.0 This release

2 release files

2.4.0

2 release files

2.3.2

2 release files

2.3.1

2 release files

2.3.0

2 release files

2.2.1

1 release file

2.2.0

2 release files

2.1.1

2 release files

2.1.0

1 release file

2.0.7

3 release files

2.0.6

3 release files

2.0.5

3 release files

2.0.4

3 release files

2.0.3

3 release files

2.0.2

2 release files

2.0.1

3 release files

2.0.0

2 release files

1.0.0

1 release file

0.0.9

1 release file

0.0.8

3 release files

0.0.6

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page