Skip to content

Commit

Permalink
Add argument for removing asr when importing bp with importBugphyzz.
Browse files Browse the repository at this point in the history
And filtering "all" for validation data.
  • Loading branch information
sdgamboa committed Jan 11, 2024
1 parent d221a54 commit 6306b21
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
12 changes: 9 additions & 3 deletions R/bugphyzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#' (current file on the GitHub repo waldronlab/bugphyzzExports).
#' @param force_download Logical value. Force a fresh download of the data or
#' use the one stored in the cache (if available). Default is FALSE.
#' @param v Validation value. Deafult 0.5.
#' @param v Validation value. Default 0.5.
#' @param remove_asr Logical. Default is TRUE.
#'
#' @return A data.frame.
#' @export
Expand All @@ -17,7 +18,7 @@
#' bp <- importBugphyzz()
#' names(bp)
#'
importBugphyzz <- function(version = 'devel', force_download = FALSE, v = 0.5) {
importBugphyzz <- function(version = 'devel', force_download = FALSE, v = 0.5, remove_asr = TRUE) {
types <- c("multistate", "binary", "numeric")
urls <- paste0(
"https://github.com/waldronlab/bugphyzzExports/raw/sdgamboa/phylo/bugphyzz_",
Expand All @@ -41,7 +42,8 @@ importBugphyzz <- function(version = 'devel', force_download = FALSE, v = 0.5) {
output <- purrr::list_flatten(output)
names(output) <- purrr::map_chr(output, ~ unique(.x$Attribute_group))
val <- .validationData() |>
dplyr::select(.data$physiology, .data$attribute, .data$value)
dplyr::select(.data$physiology, .data$attribute, .data$value) |>
dplyr::filter(.data$rank == "all")

output <- purrr::map(output, ~ {
attr_type <- unique(.x$Attribute_type)
Expand All @@ -57,6 +59,10 @@ importBugphyzz <- function(version = 'devel', force_download = FALSE, v = 0.5) {
!(.data$value < v & .data$Evidence == "asr")
)
})

if (remove_asr) {
output <- purrr::map(output, ~ dplyr::filter(.x, .data$Evidence != "asr"))
}
return(output)
}

Expand Down
11 changes: 9 additions & 2 deletions man/importBugphyzz.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6306b21

Please sign in to comment.