Skip to content

Commit

Permalink
Merge pull request jeromekelleher#315 from jeromekelleher/turn-on-nj
Browse files Browse the repository at this point in the history
Enable neighbour joining for sample group inference
  • Loading branch information
jeromekelleher authored Sep 27, 2024
2 parents c198b06 + b90ce33 commit 7fd5b44
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions sc2ts/tree_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,11 @@ def infer_binary_topology(ts, tables):
# greater than 0 and 1).
Y = scipy.spatial.distance.pdist(G.T, "hamming")

# nj_tree = bsp.neighbor_joining(scipy.spatial.distance.squareform(Y))
biotite_tree = bsp.upgma(scipy.spatial.distance.squareform(Y))
if ts.num_samples < 3:
# NJ fails with < 4
biotite_tree = bsp.upgma(scipy.spatial.distance.squareform(Y))
else:
biotite_tree = bsp.neighbor_joining(scipy.spatial.distance.squareform(Y))
pi, n = biotite_to_oriented_forest(biotite_tree)
# Node n - 1 is the pre-specified root, so force rerooting around that.
reroot(pi, n - 1)
Expand Down

0 comments on commit 7fd5b44

Please sign in to comment.