Detect and polarize interdomain horizontal gene transfer with reciprocal hits, genomic context, and tree-decided gene phylogenies. Use for virus-host gene exchange, endogenous viral elements, or donor direction.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Bio Interdomain Hgt?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/fmschulz-bio-interdomain-hgt)
---
name: bio-interdomain-hgt
description: Detect and polarize interdomain horizontal gene transfer with reciprocal hits, genomic context, and tree-decided gene phylogenies. Use for virus-host gene exchange, endogenous viral elements, or donor direction.
disable-model-invocation: true
---
# Bio Interdomain HGT
Detect, polarize, and confirm horizontal gene transfer between a query genome (virus, MAG, isolate, or bin) and other domains of life. Built for the common asymmetric case where the query is well annotated but the comparison set is genome-only. Pairs with `bio-annotation`, the [phylogenomics page](../omics-pipeline/references/phylogenomics.md) (`VeryFastTree` first, then `IQ-TREE 3`), and `bio-viromics` (including **ViroSync** for endogenized viral elements in eukaryotic genomes). Shared pipeline rules: read `../omics-pipeline/SKILL.md` first. `SKILL_DIR` is the directory that holds this `SKILL.md`.
## Instructions
Run steps in order and record provenance at each step. Steps 0 (database gate) and 5 (frame-aware context guard on eukaryotic DNA) are the most often skipped and most often responsible for wrong calls. Steps 1-4 and 6-8 are in [references/workflow.md](references/workflow.md).
Give every search and tree step an explicit thread count (`diamond --threads`, `VeryFastTree -threads`, `iqtree3 -T`, `mafft --thread`).
After Steps 0-7 have produced normalized TSVs, apply the evidence gates with the driver (`RUN_DIR` is `results/<date>_<name>/`):
```bash
uv run --script "$SKILL_DIR/scripts/run_hgt_evidence.py" \
forward_hits.tsv --arbiter-hits arbiter_hits.tsv --reciprocal reciprocal.tsv \
--context context.tsv --trees trees.tsv --sampling-depth sampling_depth.tsv \
--databases databases.json --hypotheses hypotheses.tsv --reflections reflections.tsv \
--query-domain ncldv --out "$RUN_DIR/interdomain-hgt"
```
The driver checks database presence and domain coverage (`--verify-checksums` recomputes full SHA-256 checksums on demand), applies the gates below, normalizes confirmed candidates by lineage sampling depth, and writes `run_manifest.json` under [schemas/hgt-evidence.schema.json](schemas/hgt-evidence.schema.json):
| Gate | Pass rule in the driver |
| --- | --- |
| Homology | query and subject coverage `>= 0.5` and e-value `<= 1e-5` |
| Reciprocal best hit | `forward_rank` and `reverse_rank` both `1` |
| Direction (hits + tree) | Query best-matching recipient domain supports `recipient_to_query`; recipient best-matching `--query-domain` supports `query_to_recipient`. **When both hold (typical reciprocal pair), the hits are tied and the ML gene tree decides.** Below `--min-identity`, direction stays `ambiguous`. |
| Context | `recipient_domain_fraction >= 0.6`; eukaryotic recipients require `method = diamond_blastx` |
| Phylogeny (typed support) | `trees.tsv` carries `support` (`0-1`), `support_type` (`ufboot`, `bootstrap`, or `sh_like`), and `shalrt` (`0-1` or `na`). Strong ML support requires `ufboot >= 0.95` (with `shalrt >= 0.80` if given) or `bootstrap >= 0.70`; `sh_like` (`VeryFastTree`) is exploratory only and cannot confirm a transfer. A strongly supported tree that disagrees with the hit direction **rejects** the call. |
Lineages (`recipient_lineage`, `expected_clade`, `nesting_clade`) use `;`-separated root-down ranks compared rank by rank (accepting both clade-inside-lineage and ancestor-of-lineage matches, while leaving a broad ancestor shared by both sides uninformative). Domain labels use `eukaryota`, `bacteria`, `archaea`, `ncldv`, `phage`, `organelle`. Hypotheses require at least five unique IDs with at least one `technical` or `null` row; reflections cover `database`, `forward`, `reciprocal`, `context`, `phylogeny`, `final` in order.
### Step 0: Database availability gate
Resolve `$BIO_DB_ROOT` (`check_databases.py --export`); never hardcode absolute paths. Verify BOTH exist before searching:
1. **Multi-domain reciprocal-arbiter proteome** (DIAMOND `.dmnd` or MMseqs2) spanning all six domains (`eukaryota`, `bacteria`, `archaea`, `ncldv`, `phage`, `organelle`) with a `genome_id -> lineage` table ([docs/database-availability.md](docs/database-availability.md)). Prefer a clustered build (`clusterednr` / MMseqs2-reduced). Never polarize HGT with a single-domain arbiter.
2. **Per-domain comparison collection** (e.g., eukaryote genome catalog or viral catalog) with completeness/contamination metadata. Record whether it ships proteins or nucleotides only.
### Step 5: Genomic-context contamination guard
- Require flanking genes on the recipient contig to match the recipient domain; otherwise flag as contamination or a free donor contig.
- **On eukaryotic genome assemblies, never use Prodigal/pyrodigal** (introns fragment genes). Run frame-aware, intron-tolerant `diamond blastx --range-culling --top 10 -F 15` of the locus +/- flank window against the arbiter; cross-check viral regions with geNomad or **ViroSync** (for integrated eukaryotic EVEs).
- Transcriptome assemblies carry ~1 transcript per contig, so rely primarily on reciprocity and phylogeny.
## Performance gotchas
- Use default DIAMOND sensitivity for whole-arbiter domain classification; reserve `--sensitive` for focal sets. On CUDA GPUs, `mmseqs easy-taxonomy --gpu` is an alternative.
- Build an initial **VeryFastTree** (`sh_like`) to clean alignments and prune contaminants quickly, then confirm candidates with **IQ-TREE 3** (`ufboot` + `shalrt`) before marking HGT as `confirmed`.
## Input Requirements
- The two Step 0 databases under `$BIO_DB_ROOT`.
- Query proteins (`.faa`), query contigs (`.fna`), and tools (`diamond`, `mafft`/`famsa`, `clipkit`/`trimal`, `VeryFastTree`, `iqtree3`, `genomad`, `taxonkit`, `seqkit`; [docs/README.md](docs/README.md)).
## Output
Driver outputs under `$RUN_DIR/interdomain-hgt/`: `hgt_candidates.tsv`, `query_protein_origin.tsv`, `lineage_sampling_normalization.tsv`, `phylogeny_evidence.tsv`, `hypothesis_register.tsv`, `gate_reflections.tsv`, and `run_manifest.json`.
- (agent-authored) `forward_hits.tsv`, `lineage_function_matrix.tsv`, `phylogeny/<gene>/`, `hgt_report.md`, and `logs/`.
## Quality Gates
- [ ] Arbiter spans all six candidate donor domains; versions and database provenance are recorded.
- [ ] Every candidate carries id%, query/subject coverage, e-value, bitscore, RBH, and typed phylogenetic support (`ufboot`/`bootstrap` required for `confirmed`).
- [ ] Tied reciprocal hits are polarized by ML gene trees; supported tree disagreements reject the call.
- [ ] Deep-homology `--min-identity` cutoff (or reason it is off) and `ambiguous` count are logged.
- [ ] Virus-to-virus alternatives and contamination-prone contigs are explicitly tested and flagged.
## Non-Goals
- No confirmed transfer direction from hits or exploratory `VeryFastTree` (`sh_like`) alone without ML tree nesting.
- No HGT call from single-domain arbiters, no event dating from percent identity, and no lineage-enrichment claims without sampling-depth normalization.