From 6306b219ed41d4c305690a708254789cad9cdbfd Mon Sep 17 00:00:00 2001 From: sdgamboa Date: Thu, 11 Jan 2024 11:52:25 -0500 Subject: [PATCH] Add argument for removing asr when importing bp with importBugphyzz. And filtering "all" for validation data. --- R/bugphyzz.R | 12 +++++++++--- man/importBugphyzz.Rd | 11 +++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/R/bugphyzz.R b/R/bugphyzz.R index 6709ef4e..86a7541b 100644 --- a/R/bugphyzz.R +++ b/R/bugphyzz.R @@ -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 @@ -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_", @@ -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) @@ -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) } diff --git a/man/importBugphyzz.Rd b/man/importBugphyzz.Rd index 8eba5c31..4f408a10 100644 --- a/man/importBugphyzz.Rd +++ b/man/importBugphyzz.Rd @@ -4,7 +4,12 @@ \alias{importBugphyzz} \title{Import bugphyzz} \usage{ -importBugphyzz(version = "devel", force_download = FALSE, v = 0.5) +importBugphyzz( + version = "devel", + force_download = FALSE, + v = 0.5, + remove_asr = TRUE +) } \arguments{ \item{version}{Character string. The version to download. Default is 'devel' @@ -13,7 +18,9 @@ importBugphyzz(version = "devel", force_download = FALSE, v = 0.5) \item{force_download}{Logical value. Force a fresh download of the data or use the one stored in the cache (if available). Default is FALSE.} -\item{v}{Validation value. Deafult 0.5.} +\item{v}{Validation value. Default 0.5.} + +\item{remove_asr}{Logical. Default is TRUE.} } \value{ A data.frame.