# jmschrei/tangermeme architecture

> Architecture diagram of the GitHub repository jmschrei/tangermeme, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jmschrei/tangermeme
- Repository: https://github.com/jmschrei/tangermeme

## Overview

Tangermeme is a PyTorch toolkit for asking what sequence-based models have learned and for designing sequences with them. The user workflow is to encode or load sequences, apply sequence operations or perturbations, evaluate a model, and inspect predictions or attributions; design methods iteratively search for sequences meeting a user-defined objective. Separate branches support genomic annotations, motif/seqlet analysis, plotting, and sequence I/O. The graph uses README descriptions and SOURCE INDEX references for connections; unsampled implementation details are not inferred.

Main entry points: [`tangermeme/predict.py`](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/predict.py) (Model prediction), [`tangermeme/ersatz.py`](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/ersatz.py) (Sequence operations), [`tangermeme/deep_lift_shap.py`](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/deep_lift_shap.py) (DeepLIFT/SHAP), [`tangermeme/utils.py`](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/utils.py) (Sequence utilities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sequence["Sequence data"]
  node_io["Genomic I/O<br/>[io.py]"]
  node_sequence_ops["Sequence operations<br/>[ersatz.py]"]
  node_utils["Sequence utilities<br/>[utils.py]"]
end

subgraph group_experiments["Model experiments"]
  node_predict["Model prediction<br/>[predict.py]"]
  node_ablate["Ablation<br/>[ablate.py]"]
  node_marginalize["Marginalization<br/>[marginalize.py]"]
  node_variant["Variant effects<br/>[variant_effect.py]"]
  node_saturation["Saturation mutagenesis"]
  node_product["Cartesian products<br/>[product.py]"]
  node_space["Sequence spacing<br/>[space.py]"]
end

subgraph group_interpretation["Model interpretation"]
  node_deep_lift["DeepLIFT/SHAP<br/>[deep_lift_shap.py]"]
  node_pisa["PISA attribution<br/>[pisa.py]"]
  node_annotate["Feature annotation<br/>[annotate.py]"]
  node_seqlet["Seqlet calling<br/>[seqlet.py]"]
  node_match["Motif matching<br/>[match.py]"]
  node_kmers["K-mer analysis<br/>[kmers.py]"]
  node_plot["Result plotting<br/>[plot.py]"]
end

subgraph group_design["Sequence design"]
  node_screen["Sequence screening<br/>[screen.py]"]
  node_greedy_sub["Greedy substitution"]
  node_beam_sub["Beam substitution"]
  node_greedy_marg["Greedy marginalization"]
  node_fast_sub["Fast substitution<br/>[_substitute.py]"]
end

subgraph group_shared["Shared runtime"]
  node_results["Result types<br/>[results.py]"]
  node_compat["Device compatibility<br/>[_compat.py]"]
  node_deep_utils["Attribution rules"]
end

node_user(("Researcher"))

node_user -->|"loads sequences"| node_io
node_user -->|"perturbs sequences"| node_sequence_ops
node_user -->|"evaluates model"| node_predict
node_user -->|"inspects attributions"| node_deep_lift
node_user -->|"designs sequences"| node_screen
node_io -->|"encodes sequences"| node_utils
node_sequence_ops -->|"uses encoding"| node_utils
node_predict -->|"preserves model state"| node_compat
node_ablate -->|"perturbs sequences"| node_sequence_ops
node_ablate -->|"evaluates model"| node_predict
node_ablate -->|"returns results"| node_results
node_marginalize -->|"perturbs sequences"| node_sequence_ops
node_marginalize -->|"evaluates model"| node_predict
node_marginalize -->|"returns results"| node_results
node_variant -->|"applies variants"| node_sequence_ops
node_variant -->|"evaluates model"| node_predict
node_variant -->|"returns results"| node_results
node_saturation -->|"evaluates model"| node_predict
node_product -->|"shares device handling"| node_compat
node_space -->|"edits sequences"| node_sequence_ops
node_space -->|"evaluates model"| node_predict
node_deep_lift -->|"preserves model state"| node_compat
node_deep_lift -->|"uses attribution rules"| node_deep_utils
node_deep_lift -->|"returns references"| node_results
node_pisa -->|"uses attribution method"| node_deep_lift
node_pisa -->|"returns references"| node_results
node_annotate -->|"reads genomic data"| node_io
node_annotate -->|"uses utilities"| node_utils
node_seqlet -->|"uses utilities"| node_utils
node_plot -->|"plots attributions"| node_deep_lift
node_plot -->|"uses utilities"| node_utils
node_screen -->|"scores candidates"| node_predict
node_greedy_sub -->|"substitutes motifs"| node_sequence_ops
node_greedy_sub -->|"scores edits"| node_predict
node_beam_sub -->|"substitutes motifs"| node_sequence_ops
node_beam_sub -->|"scores edits"| node_predict
node_beam_sub -->|"uses fast edits"| node_fast_sub
node_greedy_marg -->|"substitutes motifs"| node_sequence_ops
node_greedy_marg -->|"scores edits"| node_predict
node_greedy_sub -->|"uses fast edits"| node_fast_sub

click node_io "https://github.com/jmschrei/tangermeme/blob/main/tangermeme/io.py"
click node_sequence_ops "https://github.com/jmschrei/tangermeme/blob/main/tangermeme/ersatz.py"
click node_utils "https://github.com/jmschrei/tangermeme/blob/main/tangermeme/utils.py"
click node_predict "https://github.com/jmschrei/tangermeme/blob/main/tangermeme/predict.py"
click node_ablate "https://github.com/jmschrei/tangermeme/blob/main/tangermeme/ablate.py"
click node_marginalize "https://github.com/jmschrei/tangermeme/blob/main/tangermeme/marginalize.py"
click node_variant "https://github.com/jmschrei/tangermeme/blob/main/tangermeme/variant_effect.py"
click node_saturation "https://github.com/jmschrei/tangermeme/blob/main/tangermeme/saturation_mutagenesis.py"
click node_product "https://github.com/jmschrei/tangermeme/blob/main/tangermeme/product.py"
click node_space "https://github.com/jmschrei/tangermeme/blob/main/tangermeme/space.py"
click node_deep_lift "https://github.com/jmschrei/tangermeme/blob/main/tangermeme/deep_lift_shap.py"
click node_pisa "https://github.com/jmschrei/tangermeme/blob/main/tangermeme/pisa.py"
click node_annotate "https://github.com/jmschrei/tangermeme/blob/main/tangermeme/annotate.py"
click node_seqlet "https://github.com/jmschrei/tangermeme/blob/main/tangermeme/seqlet.py"
click node_match "https://github.com/jmschrei/tangermeme/blob/main/tangermeme/match.py"
click node_kmers "https://github.com/jmschrei/tangermeme/blob/main/tangermeme/kmers.py"
click node_plot "https://github.com/jmschrei/tangermeme/blob/main/tangermeme/plot.py"
click node_screen "https://github.com/jmschrei/tangermeme/blob/main/tangermeme/design/screen.py"
click node_greedy_sub "https://github.com/jmschrei/tangermeme/blob/main/tangermeme/design/greedy_substitution.py"
click node_beam_sub "https://github.com/jmschrei/tangermeme/blob/main/tangermeme/design/beam_substitution.py"
click node_greedy_marg "https://github.com/jmschrei/tangermeme/blob/main/tangermeme/design/greedy_marginalize.py"
click node_fast_sub "https://github.com/jmschrei/tangermeme/blob/main/tangermeme/design/_substitute.py"
click node_results "https://github.com/jmschrei/tangermeme/blob/main/tangermeme/results.py"
click node_compat "https://github.com/jmschrei/tangermeme/blob/main/tangermeme/_compat.py"
click node_deep_utils "https://github.com/jmschrei/tangermeme/blob/main/tangermeme/_deep_lift_utils.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_io,node_sequence_ops,node_utils toneBlue
class node_predict,node_ablate,node_marginalize,node_variant,node_saturation,node_product,node_space toneAmber
class node_deep_lift,node_pisa,node_annotate,node_seqlet,node_match,node_kmers,node_plot toneMint
class node_screen,node_greedy_sub,node_beam_sub,node_greedy_marg,node_fast_sub toneRose
class node_results,node_compat,node_deep_utils,node_user toneIndigo
```

## Components

### Sequence data

- [Genomic I/O](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/io.py): `tangermeme/io.py`
- [Sequence operations](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/ersatz.py): `tangermeme/ersatz.py`
- [Sequence utilities](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/utils.py): `tangermeme/utils.py`

### Model experiments

- [Model prediction](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/predict.py): `tangermeme/predict.py`
- [Ablation](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/ablate.py): `tangermeme/ablate.py`
- [Marginalization](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/marginalize.py): `tangermeme/marginalize.py`
- [Variant effects](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/variant_effect.py): `tangermeme/variant_effect.py`
- [Saturation mutagenesis](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/saturation_mutagenesis.py): `tangermeme/saturation_mutagenesis.py`
- [Cartesian products](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/product.py): `tangermeme/product.py`
- [Sequence spacing](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/space.py): `tangermeme/space.py`

### Model interpretation

- [DeepLIFT/SHAP](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/deep_lift_shap.py): `tangermeme/deep_lift_shap.py`
- [PISA attribution](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/pisa.py): `tangermeme/pisa.py`
- [Feature annotation](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/annotate.py): `tangermeme/annotate.py`
- [Seqlet calling](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/seqlet.py): `tangermeme/seqlet.py`
- [Motif matching](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/match.py): `tangermeme/match.py`
- [K-mer analysis](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/kmers.py): `tangermeme/kmers.py`
- [Result plotting](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/plot.py): `tangermeme/plot.py`

### Sequence design

- [Sequence screening](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/design/screen.py): `tangermeme/design/screen.py`
- [Greedy substitution](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/design/greedy_substitution.py): `tangermeme/design/greedy_substitution.py`
- [Beam substitution](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/design/beam_substitution.py): `tangermeme/design/beam_substitution.py`
- [Greedy marginalization](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/design/greedy_marginalize.py): `tangermeme/design/greedy_marginalize.py`
- [Fast substitution](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/design/_substitute.py): `tangermeme/design/_substitute.py`

### Shared runtime

- [Result types](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/results.py): `tangermeme/results.py`
- [Device compatibility](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/_compat.py): `tangermeme/_compat.py`
- [Attribution rules](https://github.com/jmschrei/tangermeme/blob/main/tangermeme/_deep_lift_utils.py): `tangermeme/_deep_lift_utils.py`

### Other components

- **Researcher**

## Connections

- Researcher → Genomic I/O: loads sequences (evidence: `README.md`)
- Researcher → Sequence operations: perturbs sequences (evidence: `README.md`)
- Researcher → Model prediction: evaluates model (evidence: `README.md`)
- Researcher → DeepLIFT/SHAP: inspects attributions (evidence: `README.md`)
- Researcher → Sequence screening: designs sequences (evidence: `README.md`)
- Genomic I/O → Sequence utilities: encodes sequences (evidence: `tangermeme/io.py`)
- Sequence operations → Sequence utilities: uses encoding (evidence: `tangermeme/ersatz.py`)
- Model prediction → Device compatibility: preserves model state (evidence: `tangermeme/predict.py`)
- Ablation → Sequence operations: perturbs sequences (evidence: `tangermeme/ablate.py`)
- Ablation → Model prediction: evaluates model (evidence: `tangermeme/ablate.py`)
- Ablation → Result types: returns results (evidence: `tangermeme/ablate.py`)
- Marginalization → Sequence operations: perturbs sequences (evidence: `tangermeme/marginalize.py`)
- Marginalization → Model prediction: evaluates model (evidence: `tangermeme/marginalize.py`)
- Marginalization → Result types: returns results (evidence: `tangermeme/marginalize.py`)
- Variant effects → Sequence operations: applies variants (evidence: `tangermeme/variant_effect.py`)
- Variant effects → Model prediction: evaluates model (evidence: `tangermeme/variant_effect.py`)
- Variant effects → Result types: returns results (evidence: `tangermeme/variant_effect.py`)
- Saturation mutagenesis → Model prediction: evaluates model (evidence: `tangermeme/saturation_mutagenesis.py`)
- Cartesian products → Device compatibility: shares device handling (evidence: `tangermeme/product.py`)
- Sequence spacing → Sequence operations: edits sequences (evidence: `tangermeme/space.py`)
- Sequence spacing → Model prediction: evaluates model (evidence: `tangermeme/space.py`)
- DeepLIFT/SHAP → Device compatibility: preserves model state (evidence: `tangermeme/deep_lift_shap.py`)
- DeepLIFT/SHAP → Attribution rules: uses attribution rules (evidence: `tangermeme/deep_lift_shap.py`)
- DeepLIFT/SHAP → Result types: returns references (evidence: `tangermeme/deep_lift_shap.py`)
- PISA attribution → DeepLIFT/SHAP: uses attribution method (evidence: `tangermeme/pisa.py`)
- PISA attribution → Result types: returns references (evidence: `tangermeme/pisa.py`)
- Feature annotation → Genomic I/O: reads genomic data (evidence: `tangermeme/annotate.py`)
- Feature annotation → Sequence utilities: uses utilities (evidence: `tangermeme/annotate.py`)
- Seqlet calling → Sequence utilities: uses utilities (evidence: `tangermeme/seqlet.py`)
- Result plotting → DeepLIFT/SHAP: plots attributions (evidence: `tangermeme/plot.py`)
- Result plotting → Sequence utilities: uses utilities (evidence: `tangermeme/plot.py`)
- Sequence screening → Model prediction: scores candidates (evidence: `tangermeme/design/screen.py`)
- Greedy substitution → Sequence operations: substitutes motifs (evidence: `tangermeme/design/greedy_substitution.py`)
- Greedy substitution → Model prediction: scores edits (evidence: `tangermeme/design/greedy_substitution.py`)
- Beam substitution → Sequence operations: substitutes motifs (evidence: `tangermeme/design/beam_substitution.py`)
- Beam substitution → Model prediction: scores edits (evidence: `tangermeme/design/beam_substitution.py`)
- Beam substitution → Fast substitution: uses fast edits (evidence: `tangermeme/design/beam_substitution.py`)
- Greedy marginalization → Sequence operations: substitutes motifs (evidence: `tangermeme/design/greedy_marginalize.py`)
- Greedy marginalization → Model prediction: scores edits (evidence: `tangermeme/design/greedy_marginalize.py`)
- Greedy substitution → Fast substitution: uses fast edits (evidence: `tangermeme/design/greedy_substitution.py`)
