Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem disambiguating homonyms with search_taxa #168

Closed
mjwestgate opened this issue Nov 2, 2022 · 2 comments
Closed

Problem disambiguating homonyms with search_taxa #168

mjwestgate opened this issue Nov 2, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@mjwestgate
Copy link
Collaborator

@fontikar recently found a homonym during a call to search_taxa:

> search_taxa("ACANTHOCEPHALA") # Problem, ACANTHOCEPHALA is a Phylum and a class
# A tibble: 1 × 2
  search_term    issues 
  <chr>          <chr>  
1 ACANTHOCEPHALA homonym
Warning message:
Your search returned multiple taxa due to a homonym issue.
ℹ Please provide another rank in your search to clarify taxa.
✖ Homonym issue with "ACANTHOCEPHALA". 

That's fine, but there should be a way to disambiguate this. My proposed solution is to use a data.frame to ensure this gets passed to the searchByClassification API, i.e.:

> search_taxa(data.frame(phylum = "ACANTHOCEPHALA"))
Error:
! Column name `phylum` must not be duplicated.
Use .name_repair to specify repair.
Caused by error in `repaired_names()`:
! Names must be unique.
✖ These names are duplicated:
  * "phylum" at locations 1 and 8.
Run `rlang::last_error()` to see where the error occurred.

The error here suggests that the search has worked, but the joining of the input and output tibbles has failed. There is also a broader question of whether this is efficient for specifying multiple ranks for a single search, or whether a filter-like implementation might be more efficient, e.g.

search_taxa(phylum == "ACANTHOCEPHALA")

Finally, the other alternative of specifying an authority for a name (suggested by @daxkellie) also fails:

> search_taxa("ACANTHOCEPHALA Koelreuther, 1771")
# A tibble: 1 × 2
  search_term                      issues 
  <chr>                            <chr>  
1 ACANTHOCEPHALA Koelreuther, 1771 homonym
Warning message:
Your search returned multiple taxa due to a homonym issue.
ℹ Please provide another rank in your search to clarify taxa.
✖ Homonym issue with "ACANTHOCEPHALA Koelreuther, 1771".

Just to prove that this taxon occurs in the atlas, if we look up the identifier we can get the query to run:

> galah_call() %>% 
+     galah_identify("https://biodiversity.org.au/afd/taxa/3cbb537e-ab39-4d85-864e-76cd6b6d6572", search = FALSE) %>% 
+     atlas_counts()
# A tibble: 1 × 1
  count
  <int>
1   395
@mjwestgate mjwestgate added the bug Something isn't working label Nov 2, 2022
daxkellie added a commit that referenced this issue Feb 28, 2023
* Add `dplyr::rename` to NAMESPACE
@daxkellie
Copy link
Contributor

Homonym errors now suggest for you to use a tibble and see the ?search_taxa help file to learn how to clarify taxa.

> search_taxa("ACANTHOCEPHALA")
No taxon matches were found for "ACANTHOCEPHALA" in the selected atlas (Australia).
# A tibble: 1 × 1
  search_term   
  <chr>         
1 ACANTHOCEPHALA
Warning message:
Your search returned multiple taxa due to a homonym issue.
ℹ Please provide another rank in your search to clarify taxa.
ℹ Use a tibble to clarify taxa, see `?search_taxa`.
✖ Homonym issue with "ACANTHOCEPHALA". 

Clarifying taxa in a data.frame or tibble no longer fails, mainly because of an update to {dplyr} which renames duplicate rows that are merged after bind_rows(). Column names have been changed to avoid messages from {dplyr}

> library(tibble)
> search_taxa(tibble(phylum = "ACANTHOCEPHALA"))
# A tibble: 1 × 10
  search_term    scientific_name scientific_name_authorship taxon_concept_id                             rank  match…¹ kingdom phylum verna…² issues
  <chr>          <chr>           <chr>                      <chr>                                        <chr> <chr>   <chr>   <chr>  <chr>   <chr> 
1 ACANTHOCEPHALA ACANTHOCEPHALA  Koelreuther, 1771          https://biodiversity.org.au/afd/taxa/3cbb53… phyl… exactM… Animal… Acant… Thorny… noIss…
# … with abbreviated variable names ¹​match_type, ²​vernacular_name

@mjwestgate
Copy link
Collaborator Author

Closed as complete

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants