Skip to contents

Compare a "before" and "after" reconciliation and list every species whose outcome differs: newly matched, newly unresolved, promoted to a higher-confidence match type, or linked to a different target. Useful for:

  • checking the effect of adding a taxonomy crosswalk or a batch of manual overrides,

  • comparing two taxonomic authorities (e.g. Catalogue of Life vs GBIF),

  • auditing changes between runs before and after tightening the fuzzy threshold.

Usage

reconcile_diff(x, y, quiet = FALSE)

Arguments

x

A reconciliation object — the "before" state.

y

A reconciliation object — the "after" state. Must be reconciled against the same x data so that name_x values are comparable.

quiet

Logical. Suppresses the console summary when TRUE. Default FALSE.

Value

A list with the following components:

gained

Tibble of species matched in y but unresolved in x.

lost

Tibble of species matched in x but unresolved in y.

type_changed

Tibble of species whose match_type differs between the two runs.

target_changed

Tibble of species whose name_y differs.

unused_overrides_diff

Tibble of overrides that are in the unused_overrides slot of one reconciliation but not the other; columns name_x, name_y, reason, side ("x" or "y").

summary

A one-row tibble with counts: n_gained, n_lost, n_type_changed, n_target_changed, n_shared, n_unused_override_diff.

Examples

x <- data.frame(species = c("A a", "A old", "B c"))
tree <- ape::read.tree(text = "((A_a:1,A_new:1):1,B_c:2);")

# Without manual overrides
r1 <- reconcile_tree(x, tree, x_species = "species",
                     authority = NULL, quiet = TRUE)

# With one manual override
overrides <- data.frame(name_x = "A old", name_y = "A new",
                        match_type = "manual")
r2 <- reconcile_tree(x, tree, x_species = "species",
                     authority = NULL, overrides = overrides,
                     quiet = TRUE)

d <- reconcile_diff(r1, r2, quiet = TRUE)
cat("Gained:", nrow(d$gained), "| Lost:", nrow(d$lost), "\n")
#> Gained: 1 | Lost: 0