Extract the per-name mapping table from a reconciliation
Source:R/reconcile_accessors.R
reconcile_mapping.RdReturns the mapping tibble inside a reconciliation object. Use this when you want to filter matches programmatically (e.g. pull all unresolved species, all fuzzy matches above a given score, or join the mapping back to the original data frame).
Arguments
- reconciliation
A reconciliation object returned by
reconcile_tree(),reconcile_data(),reconcile_trees(),reconcile_to_trees(), orreconcile_multi().- include_unused_overrides
Logical. Appends the rejected override rows to the returned tibble when
TRUE, withmatch_type = "override_unused",match_score = NA, and thenotescolumn carrying the rejection reason (name_x_not_in_data,name_y_not_in_target, oralready_matched). DefaultFALSEfor backward compatibility — the bare mapping tibble has the same shape as before.
Value
A tibble with one row per unique name seen in either source and the following columns:
name_xStatement: this column holds the original name as it appeared in source
x(your data).NAfor rows that exist only in sourcey(e.g. tree tips not in your data).name_yStatement: this column holds the original name as it appeared in source
y(the reference dataset or tree).NAfor rows that exist only in sourcex.name_resolvedThe accepted/canonical name returned by the taxonomic authority, when synonym resolution was used.
NAwhenauthority = NULLor no synonym was found.match_typeOne of
"exact","normalized","synonym","fuzzy","manual"(set viareconcile_override()),"flagged"(low-confidence, needs review),"unresolved", or — wheninclude_unused_overrides = TRUE—"override_unused"(override row not applied because of missing names or prior matches).match_scoreNumeric in [0, 1].
1for exact/normalized/synonym/manual matches; a genus-weighted Levenshtein score for fuzzy matches;NAfor unresolved and for unused-override rows.match_sourceWhere the match came from:
"exact","normalisation", the taxadb authority code (e.g."col"),"fuzzy", or"user_override".in_xLogical. This column records whether the name was present in source
x.in_yLogical. This column records whether the name was present in source
y.notesFree-text notes, populated e.g. when a name is flagged for review or when an override carries a user comment. For
match_type = "override_unused"rows this column carries the rejection reason.
See also
reconcile_summary() for a printed breakdown;
reconcile_suggest() for near-miss candidates for unresolved
names; reconcile_apply() to turn the mapping into an aligned
data-tree pair. The unused-override rows surfaced by
include_unused_overrides = TRUE mirror the unused_overrides
slot on the reconciliation object.
Other reconciliation functions:
reconcile_apply(),
reconcile_augment(),
reconcile_crosswalk(),
reconcile_data(),
reconcile_diff(),
reconcile_export(),
reconcile_merge(),
reconcile_multi(),
reconcile_override(),
reconcile_override_batch(),
reconcile_plot(),
reconcile_report(),
reconcile_review(),
reconcile_splits_lumps(),
reconcile_suggest(),
reconcile_summary(),
reconcile_to_trees(),
reconcile_tree(),
reconcile_trees()
Examples
data(avonet_subset)
data(tree_jetz)
rec <- reconcile_tree(avonet_subset, tree_jetz,
x_species = "Species1", authority = NULL)
#> ℹ Reconciling 919 data names vs 657 tree tips
#> ℹ Matching 919 x 657 names through 2 stages...
#> ℹ Stage 1/2: Exact matching...
#> ℹ Stage 2/2: Normalised matching (0 matched so far)...
#> ✔ Matched 657/919 data names to tree tips
mapping <- reconcile_mapping(rec)
# How many species matched?
sum(mapping$in_x & mapping$in_y)
#> [1] 657
# Which species are in the data but missing from the tree?
head(mapping[mapping$in_x & !mapping$in_y, c("name_x", "match_type")])
#> # A tibble: 6 × 2
#> name_x match_type
#> <chr> <chr>
#> 1 Acanthiza cinerea unresolved
#> 2 Calamanthus cautus unresolved
#> 3 Calamanthus montanellus unresolved
#> 4 Calamanthus pyrrhopygius unresolved
#> 5 Gerygone citrina unresolved
#> 6 Pyrrholaemus sagittatus unresolved
# Append rejected overrides for audit
mapping_full <- reconcile_mapping(rec, include_unused_overrides = TRUE)