Skip to content

Commit

Permalink
Taxonomic updates fixes (#119)
Browse files Browse the repository at this point in the history
Two fixes:

    Added align_name to group_by argument to ensure dataset_id correctly attributed to original_name by aligned_name combinations. (Closes issue #117)

    Filter taxonomic_updates to only include taxa for which trait data exists,

NOTE: the taxa table still includes taxa in excluded data, but not taxon names that are in a data.csv file but for which no data (in traits table or excluded data table) exists
  • Loading branch information
ehwenk authored Nov 2, 2023
1 parent d3e1416 commit a7e4730
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions R/process.R
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ dataset_process <- function(filename_data_raw,
dplyr::filter(!is.na(.data$error)) %>%
dplyr::select(dplyr::all_of(c("error")), everything()) %>%
dplyr::select(-dplyr::all_of(c("unit_in"))),
taxonomic_updates = taxonomic_updates,
taxonomic_updates = taxonomic_updates %>%
dplyr::filter(aligned_name %in% traits$taxon_name),
taxa = taxonomic_updates %>%
dplyr::select(dplyr::all_of(c(taxon_name = "aligned_name"))) %>%
dplyr::distinct(),
Expand Down Expand Up @@ -1811,11 +1812,11 @@ build_combine <- function(..., d = list(...)) {
# Taxonomy
taxonomic_updates <-
combine("taxonomic_updates", d) %>%
dplyr::group_by(.data$original_name, .data$taxon_name, .data$taxonomic_resolution) %>%
dplyr::group_by(.data$original_name, .data$aligned_name, .data$taxon_name, .data$taxonomic_resolution) %>%
dplyr::mutate(dataset_id = paste(.data$dataset_id, collapse = " ")) %>%
dplyr::ungroup() %>%
dplyr::distinct() %>%
dplyr::arrange(.data$original_name, .data$taxon_name, .data$taxonomic_resolution)
dplyr::arrange(.data$original_name, .data$aligned_name, .data$taxon_name, .data$taxonomic_resolution)

# Metadata
contributors <- combine("contributors", d)
Expand Down

0 comments on commit a7e4730

Please sign in to comment.