Reconstructing full-length transposable element insertions from fragmented RepeatMasker annotations — transparently, without RepeatMasker IDs or hand-made lookup tables.
Pre-release notice (
v0.8): This is the preview release (v0.8) of joinTEr, shared ahead of the upcoming manuscript. The upcomingv1.0manuscript release will unify the CLI across TE classes and freeze the final benchmark release. All code, parameters, and self-contained unit tests for both the ERV and LINE-1 reconstruction engines are included here.
Almost half of the human genome is made of transposable elements (TEs) — ancient mobile DNA insertions such as endogenous retroviruses (ERVs) and LINE-1 retrotransposons.
When standard annotation tools like RepeatMasker scan a genome, they do a great job finding individual repeat pieces, but a single historical insertion is routinely shattered into many separate rows:
- Nested insertions ("Russian dolls"): Millions of years after an ERV or LINE-1 landed, younger elements (Alu, L1, SVA, or younger ERVs) jumped right into the middle of it, splitting one insertion into pieces separated by thousands of base pairs.
- Sequence decay & model switching: Over evolutionary time, mutations cause RepeatMasker to label different halves of the same insertion with different consensus model names (e.g., two related subfamily consensuses) or to miss degraded stretches altogether.
- 5′ inversions in LINE-1 (twin priming): During LINE-1 reverse transcription, the 5′ half often flips onto the opposite DNA strand, so a single insertion looks like two opposing-strand fragments.
- Unreliable heuristic IDs: RepeatMasker's built-in chaining IDs (
rm_id) sometimes under-split nested elements, over-merge unrelated tandem copies, or change unpredictably across Dfam library releases.
What RepeatMasker sees on the chromosome (5 separate rows):
[5' LTR] [int piece 1] --- [young Alu] --- [young L1] --- [int piece 2] [3' LTR]
What actually happened biologically (1 host ERV + 2 nested younger insertions):
├── Host ERV provirus: [5' LTR ━━━ internal body ━━━ 3' LTR] (flanked by its own TSD)
│ ├── nested_in: [young Alu] (arrived later)
│ └── nested_in: [young L1] (arrived later)
joinTEr reconstructs those shattered fragments back into complete, biologically coherent insertions, tells you exactly why every pair of fragments was joined (or kept separate), grades each call's confidence (T1–T4), and explicitly maps the nesting hierarchy (child nested_in parent).
Instead of relying on RepeatMasker IDs or brittle species-specific lookup tables (zero hand-made family tables, zero rm_id in scoring), joinTEr learns its compatibility priors directly from the input genome and reconstructs loci in four transparent steps:
flowchart LR
A["RepeatMasker fragments<br/>(.out / rmsk + Genome FASTA)"] --> B["1. Genome-Learned Priors<br/>Zero hand-made tables<br/>(compatibility & TSD length)"]
B --> C["2. Inside-Out Peeling<br/>Excise younger nested TEs<br/>(Alu, L1, SVA, younger ERVs)"]
C --> D["3. Grammar-Constrained DP<br/>Chain fragments in collapsed<br/>coordinates & score seams"]
D --> E["4. Grade & Explain<br/>Tiers T1–T4, alternatives,<br/>nesting & self-audit"]
- Order & Grammar: Fragments of one insertion must progress cleanly along a shared consensus coordinate system without impossible backward jumps:
- ERVs (
erv/):5′ LTR → internal body → 3′ LTRon one strand (with on-the-fly single-consensus alignment when RepeatMasker switches model names). Tandem proviruses sharing a middle LTR are kept as two distinct elements linked byshared_ltr, never fused. - LINE-1 (
line1/):5′ UTR → ORF1 → ORF2 → 3′ UTR/poly(A)colinearly, plus explicit biophysical handling of opposite-strand 5′ twin-priming inversions ((-, +)turnaround geometry, TSD closure, and anchored local alignment).
- ERVs (
- Inside-Out Peeling: Younger intervening insertions are excised iteratively from youngest to oldest, collapsing the genomic distance between the two host halves (
g_raw → g_coll). Every peeled element is recorded as an explicitnested_inrelation. - Strict Gap Accounting: After peeling, any leftover gap must match missing consensus sequence (
m). Missing consensus is charged a deletion penalty (S_del); unexplained extra genomic DNA is charged an extra-sequence penalty (S_extra). Nothing is ever free. - Local Chance Control: Every candidate join must beat the local Poisson probability (
S_chance) that two unrelated copies of the same family happened to land that close by chance in a 2 Mb window. - Parse First, Grade Separately (
T1–T4): Reconstruction finds the highest-scoring biologically valid partition (plus runner-up alternatives within5.0nats). Confidence is then graded independently using outer-end physical proof (target site duplications, TSDs), 5′–3′ LTR concordance, and empirical opposite-strand FDR calibration.
flowchart TD
subgraph ERV ["ERV / LTR Retrotransposon Grammar (erv/ → HERVarium)"]
direction LR
E_TSD1(["TSD<br/>4–6 bp"]) --- E_5L["5' LTR"] --> E_INT["Internal body<br/>(gag · pro · pol · env)"] --> E_3L["3' LTR"] --- E_TSD2(["TSD<br/>4–6 bp"])
end
subgraph L1 ["LINE-1 Retrotransposon Grammar (line1/ → LINEpedia)"]
direction LR
L_TSD1(["TSD<br/>8–30 bp"]) --- L_5U["5' UTR / 5' inversion<br/>(sense or twin-primed antisense)"] --> L_O1["ORF1"] --> L_O2["ORF2"] --> L_3U["3' UTR + poly(A)"] --- L_TSD2(["TSD<br/>8–30 bp"])
end
Every reconstructed element receives a human-readable confidence tier — no opaque black-box probabilities:
| Tier | Meaning in Plain English | What Proves It? |
|---|---|---|
T1 |
Ends physically proven | Clean reconstruction plus tight, exact family-length Target Site Duplications (TSDs) flanking both outer boundaries — direct molecular proof that both ends came from a single integration event. |
T2 |
Coherent + independent support | Clean reconstruction backed by at least one independent corroborating signal (looser outer TSD, paired-LTR identity concordance, or structural confirmation). |
T3 |
Coherent reconstruction | Geometrically consistent after peeling, gap accounting, divergence concordance, and local chance testing, passing empirical false-discovery controls. |
T4 |
Ambiguous — competing reading published | Borderline score margin, high-FDR seam stratum, or structural conflict. Every single T4 element is guaranteed to list its competing split/merge partition in alternatives.tsv. |
- Frozen
v0.7.1core DP engine (erv/scripts/03_reconstruct_neon.py,scoring.py,seq_utils.py): genome-learned LTR–internal compatibility, on-the-fly single-consensus alignment, genome-learned per-family TSD lengths (ERV1 = 4 bp,ERVL/MaLR = 5 bp,ERVK = 6 bp), iterative Wave 0–5 peeling, exact K-best laminar DP, and automated end-of-run self-audit (self_audit_v07.py). v0.8Second-Pass Layer (erv/scripts/second_pass_layer.py, gated behind--second-pass-layer-v0, byte-identical when OFF):- Module
E3(labels only): flags recurrent internal LTR-like insertions (recurrent_internal_ltr_like) with null-calibrated per-model recurrence thresholds and 3-tier segmental-duplication independence. - Module
F1(correct + flag): resolves internal LTRs mistaken as provirus ends via competing-hypotheses testing (H_endvsH_inside), with hard protection of supported complete proviruses. - Module
tandem(labels only): identifies boundary-consistent shared-LTR tandem proviruses (shared_ltr). - Module
R2(labels only): strictly structural, family-name-free detector for L1-mediated retrotransposed ERV copies (l1_mediated_copy_candidatevia 5′/3′ LTR truncation + poly(A) + L1-style TSD).
- Module
v0.8Non-ERV Nesting Relations Layer (erv/scripts/layer_relations_nonERV.py): pure annotation layer that emits explicitnested_inlinks for non-ERV interspersed repeats (Alu,L1,SVA, DNA transposons, etc.) inside ERV host gaps without altering a single ERV join, partition, or tier.
- Frozen
LINEpedia v8engine (line1/v8/engine_v8.py,rules_v8.py,runner_v8.py): strictly zero RepeatMasker IDs (rm_idstripped on load), zero primate data in calibration, zero family names or hand-made lookup tables. - Six switch-gated, biologically calibrated mechanisms (
line1/v8/v8_policy.json):tsd_mismatch_inversion— rescues 5′ inversions corroborated by outer TSD closure.twin_priming_geometry— models canonical LINE-1 twin-priming turnaround coordinates.utr3_tip_rescue— recovers short, conserved 3′ UTR tips.tsd_colinear_rescue— rescues colinear splits validated by flanking TSDs.near3_inversion— handles near-3′ inversions with calibrated wear bounds.anchored_unknown_frame_inversion— local anchored Smith–Waterman rescue for unknown-frame inverted arms (restricted strictly toT4with an explicit split alternative).
- Whole-genome production workflow (
line1/workflow/): parallelized 24-chromosome orchestration, resource watchdog, structural contract auditor, and SHA-256 verification.
All validation precision figures below come from independent 7-primate phylogenetic empty-site adjudication (never used during training or reconstruction; multi-species ≥ 2 discordant species rule).
| Target Genome | Reconstructed Elements | Complete 5′LTR–int–3′LTR |
Nesting Relations | Held-Out Primate Precision (≥2-sp) |
Dfam 3.9 vs 4.0 Stability |
|---|---|---|---|---|---|
| Human GRCh38 (Dfam 3.9) | 482,568 |
16,725 |
24,349 ERV-in-ERV + 88,703 non-ERV-in-ERV (68,178 Alu, 11,042 L1, 757 SVA, 8,726 other) |
99.51% overall (1,217/1,223) · 99.64% T1–T3 · 99.81% complete T1–T3 (538/539) |
88.5% Jaccard (complete ERVs) |
Mouse mm39 (chr1–3) (zero tuning) |
162,267 |
3,281 |
Identical parameters, zero .align files |
0/18 opposite-strand F1 false positives |
— |
Metric (9 out-of-sample chromosomes: chrX + 8 even autosomes · 3,419 primate truth loci) |
joinTEr LINE-1 (v8) |
|---|---|
| Genome-wide catalogue (all 24 chroms) | 923,172 fragments → 672,483 elements (8,657 5′ inversions, 249,748 parent→child nesting links) |
Phylogenetic precision (≥2-sp rule) |
99.6% (2,076/2,084, only 8 vetoes) · 99.93% on 5′ inversions · 100.0% on T1 (635/635) |
| Recall & F1 (Span IoU ≥ 0.90) | 62.9% recall (2,151/3,419) · F1 = 77.1% (Union IoU ≥ 0.90: 65.8%, F1 = 79.2%) |
Exact recall (±50 bp) |
57.0% (1,948/3,419) · rescues 129 strict RepeatMasker-ID errors without ever reading rm_id |
| Pathological structural errors | 0 reverse-order merges (0/1,907) · 0 non-inversion mixed-strand calls · 0 untraced T4 calls |
Dfam 3.9 vs 4.0 stability (chrX) |
83.7%–87.4% multifragment Jaccard |
Both modules publish the same clean, auditable set of tab-separated tables (plus SHA-256 checksums in outputs.sha256):
| File | What It Contains |
|---|---|
elements.tsv |
One row per reconstructed TE insertion: coordinates, strand, structure (5LTR-int-3LTR, solo_LTR, 5′-inversion, etc.), family composition, fragment count, and confidence tier (T1–T4). |
membership.tsv |
Exact fragment-to-element mapping (element_id ↔ RepeatMasker fragment and role). |
relations.tsv |
Directed biological relationships: nested_in (ERV-in-ERV, L1-in-L1, and non-ERV-in-ERV via relations_all.tsv) and shared_ltr / tandem_with. |
alternatives.tsv |
Competing near-optimal partitions and score margins — guaranteed non-empty for every T4 element. |
evidence.tsv |
Full per-seam audit trail showing every additive score term (S_base, S_chance, S_age, S_family, S_peel, S_del, S_extra, S_restart, S_self_tsd), raw vs collapsed gaps, and provenance tags. |
git clone https://github.com/tmontserrat/joinTEr.git
cd joinTEr
# Option 1: Conda / Mamba (recommended — includes Snakemake and BLAST+)
conda env create -f environment.yml
conda activate jointer
# Option 2: pip (core Python dependencies)
pip install -r requirements.txtAll self-contained unit tests for both the ERV and LINE-1 engines can be run immediately after cloning:
# 1. ERV core DP engine, scoring, peeling, and self-audit tests (32 tests)
python3 erv/scripts/test_neon_unit.py
# 2. ERV v0.8 second-pass layer tests — E3, F1, tandem, R2 (15 tests)
python3 -m unittest erv/scripts/test_second_pass_layer.py -v
# 3. ERV v0.8 non-ERV nesting relations layer tests
python3 -m unittest erv/scripts/test_layer_relations_nonERV.py -v
# 4. LINE-1 v8 engine, policy switches, and firewall tests
python3 -m unittest line1/test_line1_unit.py -v- ERV workflow (
erv/):- Edit
erv/config.yamlto point to your reference genome FASTA and prepared RepeatMasker.out/ UCSCrmskinputs (seedocs/INPUT_CONTRACT_ERV.md). - Run the frozen core via Snakemake:
cd erv snakemake --cores 3 out_v071/outputs.sha256 - Apply the
v0.8second-pass layer and non-ERV nesting relations layer:python3 scripts/second_pass_layer.py --second-pass-layer-v0 --in-dir out_v071 --out-dir out_v08 python3 scripts/layer_relations_nonERV.py --in-dir out_v08 --out-dir out_v08_relations_layer \ --rm-path /path/to/genome.fa.out --fasta /path/to/genome.fa
- Edit
- LINE-1 workflow (
line1/): SetJOINTER_DATA_ROOT/JOINTER_FASTAto your genome workspace and seeline1/v8/run_frozen_v8.py,line1/workflow/produce.py, anddocs/PRODUCTION_LINE1.md.
joinTEr/
├── assets/ # Logos (joinTEr, HERVarium, LINEpedia)
├── docs/
│ ├── METHODS_ERV.md # Full mathematical & biological specification (ERV v0.8)
│ ├── INPUT_CONTRACT_ERV.md # Exact RepeatMasker .out / rmsk vs optional .align schema
│ ├── PRODUCTION_LINE1.md # Whole-genome LINE-1 v8 production & structural audit summary
│ └── BENCHMARK_LINE1.md # Out-of-sample 9-chromosome LINE-1 benchmark vs comparators
├── erv/
│ ├── Snakefile # Portable Snakemake workflow for ERV reconstruction
│ ├── config.yaml # Template configuration
│ ├── config/ # Frozen parameters (v071_params.json, PARAMETERS.tsv, fdr_lookup)
│ └── scripts/ # Core DP engine, v0.8 second-pass layer, non-ERV relations, tests
├── line1/
│ ├── v8/ # Frozen LINE-1 v8 engine, 6 biological switches & policy JSON
│ ├── workflow/ # Whole-genome 24-chromosome orchestration & structural verification
│ ├── test_line1_unit.py # Self-contained LINE-1 unit tests
│ └── FREEZE.md # Freeze provenance & development validation gates
├── environment.yml # Reproducible conda environment
├── requirements.txt # Minimal Python pip dependencies
├── CHANGELOG.md # Release notes (v0.8 pre-release & roadmap to v1.0)
└── LICENSE # MIT License
joinTEr is the reconstruction engine powering two companion human transposable-element catalogues currently in preparation:
![]() joinTEr The biological reconstruction engine (ERV & LINE-1) |
![]() HERVarium Human ERV provirus & solo-LTR catalogue |
![]() LINEpedia Human LINE-1 insertion & coding catalogue |
Released under the MIT License.
Developed by Tomàs Montserrat Ayuso (t.montserrat.ayuso@gmail.com).
If you use or explore joinTEr v0.8 before the v1.0 manuscript is published, please cite this repository (https://github.com/tmontserrat/joinTEr, release v0.8).


