From e592d83304b708b5676bd194e9529b103350f1ff Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Mon, 26 Jun 2023 11:48:58 +0100 Subject: [PATCH] Fuzzy match tree labels --- DESCRIPTION | 2 +- NEWS.md | 2 ++ inst/Parsimony/app.R | 10 ++++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3b693898c..05f689f62 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -47,7 +47,7 @@ Imports: shiny (>= 1.6.0), shinyjs, stats, - TreeDist (>= 2.5.0), + TreeDist (>= 2.6.1.9000), TreeTools (>= 1.9.2.9002), Suggests: knitr, diff --git a/NEWS.md b/NEWS.md index c36e85c18..f01c1842f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,8 @@ - Default to use equal weighting during ratchet iterations - Support null constraints in `AdditionTree()` +- Allow search to continue when loading a new file with different taxon names + into the app # TreeSearch 1.3.2 (2023-04-27) diff --git a/inst/Parsimony/app.R b/inst/Parsimony/app.R index 9bdb3bcba..40917a5d3 100644 --- a/inst/Parsimony/app.R +++ b/inst/Parsimony/app.R @@ -1570,9 +1570,15 @@ server <- function(input, output, session) { " # First tree with optimal score")) r$trees[[firstOptimal]] } else { - # TODO Could try fuzzy matching + # Fuzzy-match labels + oldTree <- r$trees[[1]] + oldLabels <- TipLabels(oldTree) + newLabels <- TipLabels(r$dataset) + matching <- TreeDist::LAPJV(adist(oldLabels, newLabels))$matching + scaffold <- KeepTip(oldTree, !is.na(matching)) + scaffold[["tip.label"]] <- newLabels[matching[!is.na(matching)]] AdditionTree(r$dataset, concavity = concavity(), - constraint = KeepTip(r$trees[[1]], TipLabels(r$dataset))) + constraint = scaffold) } } LogMsg("StartSearch()")