|
| 1 | +# Tight Span Walker (TSW) - Parsimony Network Algorithm |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +The Tight Span Walker (TSW) algorithm constructs haplotype networks using parsimony principles by computing the **tight span** of a distance matrix. The tight span is the smallest metric space that contains all optimal paths between sequences, making it ideal for representing complex evolutionary relationships with reticulation events. |
| 6 | + |
| 7 | +## Algorithm Details |
| 8 | + |
| 9 | +### How It Works |
| 10 | + |
| 11 | +1. **Compute dT Distances (Tree Metric)** |
| 12 | + - For each pair of sequences (i, j), calculate: `dT(i,j) = max over all k of |d(i,k) - d(j,k)|` |
| 13 | + - This represents the minimum distance if sequences were constrained to a tree structure |
| 14 | + |
| 15 | +2. **Build Geodesic Paths** |
| 16 | + - For each pair of haplotypes, construct the geodesic (shortest) path |
| 17 | + - Compare the actual distance with the dT distance |
| 18 | + - If `actual_distance - dT_distance > epsilon`, infer intermediate median vertices |
| 19 | + |
| 20 | +3. **Infer Median Vertices** |
| 21 | + - When needed, create intermediate (ancestral) nodes |
| 22 | + - Medians represent hypothetical ancestral or intermediate sequences |
| 23 | + |
| 24 | +4. **Construct Network** |
| 25 | + - Connect all haplotypes through geodesic paths |
| 26 | + - Include inferred median vertices to maintain metric properties |
| 27 | + |
| 28 | +### Key Features |
| 29 | + |
| 30 | +- **Metric Preservation**: Maintains all distance relationships from original data |
| 31 | +- **Reticulate Networks**: Can represent complex relationships |
| 32 | +- **Ancestral Inference**: Automatically infers hypothetical ancestral sequences |
| 33 | +- **Parsimony-Based**: Uses parsimony principles |
| 34 | + |
| 35 | +## Parameters |
| 36 | + |
| 37 | +- **epsilon** (float, default=1e-6): Tolerance for metric comparisons |
| 38 | +- **distance_method** (str, default='hamming'): Distance calculation method |
| 39 | + |
| 40 | +## When to Use TSW |
| 41 | + |
| 42 | +✓ Complex evolutionary relationships with reticulation |
| 43 | +✓ Small to medium datasets (n < 100) |
| 44 | +✓ Accurate metric representation needed |
| 45 | +✓ Ancestral sequence inference desired |
| 46 | + |
| 47 | +## Usage Example |
| 48 | + |
| 49 | +```python |
| 50 | +from pypopart.algorithms import TightSpanWalker |
| 51 | +from pypopart.io import load_alignment |
| 52 | + |
| 53 | +alignment = load_alignment('sequences.fasta') |
| 54 | +tsw = TightSpanWalker(distance_method='hamming') |
| 55 | +network = tsw.construct_network(alignment) |
| 56 | +``` |
| 57 | + |
| 58 | +## References |
| 59 | + |
| 60 | +1. Dress, A. W., & Huson, D. H. (2004). Constructing splits graphs. IEEE/ACM Transactions on Computational Biology and Bioinformatics, 1(3), 109-115. |
| 61 | +2. Bryant, D., & Moulton, V. (2004). Neighbor-Net. Molecular Biology and Evolution, 21(2), 255-265. |
0 commit comments