Neighbor-Joining Anchors¶
Anchor trees are neighbor-joining trees built from the gene alignments, with corrected pairwise distances (JC69 for DNA, Kimura 1983 for protein).
nj_tree
¶
Compute a neighbor-joining anchor tree from a compressed alignment.
The NJ algorithm runs on all of the alignment's local taxa. The returned HifukuTree is restricted to the taxa currently in taxon_table, so the caller controls the effective namespace by pre-populating taxon_table.
Negative branch lengths produced by the NJ algorithm (a known artifact on non-tree-metric distance matrices) are clamped to zero.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alignment
|
'Alignment'
|
Compressed alignment (DNA or AA) produced by |
required |
taxon_table
|
TaxonTable
|
Shared global TaxonTable. Leaf taxa from the NJ tree that are in
this table are kept; the rest are pruned. Any kept taxa not already
in the table are registered via |
required |
Returns:
| Type | Description |
|---|---|
HifukuTree
|
NJ tree restricted to taxon_table, with |
Notes
Distance model (per seq_type):
'DNA': Jukes-Cantor 1969 correction, d = -(3/4) ln(1-(4/3)p). Jukes & Cantor (1969).'AA': Kimura 1983 correction, d = -ln(1-p-0.2p^2). Kimura (1983).
Saturated pairs are capped at a large finite distance; see _SATURATED_DIST.
Neighbor-joining: saitou1987nj.
Source code in src/hifuku/nj.py
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | |