From 05cc6f74cdb6bbde78dfe9f353c91788e79f55ef Mon Sep 17 00:00:00 2001 From: Jeff Kimbrel Date: Fri, 8 Nov 2024 14:50:31 -0800 Subject: [PATCH] v0.17.10 --- DESCRIPTION | 2 +- R/add_taxonomy.R | 2 +- R/plot_filter_results.R | 27 +++++++++---------- R/qsip_objects.R | 8 +++--- man/plot_filter_results.Rd | 8 +++--- tests/testthat/_snaps/qsip_data.md | 2 +- tests/testthat/_snaps/qsip_sample_data.md | 4 +-- tests/testthat/_snaps/run_EAF_calculations.md | 2 +- .../testthat/_snaps/run_comparison_groups.md | 4 +-- tests/testthat/_snaps/run_feature_filter.md | 2 +- .../_snaps/run_growth_calculations.md | 2 +- tests/testthat/_snaps/run_resampling.md | 8 +++--- ..._position.R => test-plot_filter_results.R} | 3 --- 13 files changed, 35 insertions(+), 39 deletions(-) rename tests/testthat/{test-plot_filter_gradient_position.R => test-plot_filter_results.R} (87%) diff --git a/DESCRIPTION b/DESCRIPTION index 7af79bcf..78024085 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: qSIP2 Title: qSIP Analysis -Version: 0.17.9 +Version: 0.17.10 Authors@R: person("Jeff", "Kimbrel", , "kimbrel1@llnl.gov", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-7213-9392")) diff --git a/R/add_taxonomy.R b/R/add_taxonomy.R index f8e02871..2e9fe265 100644 --- a/R/add_taxonomy.R +++ b/R/add_taxonomy.R @@ -19,7 +19,7 @@ #' #' @returns An updated `qsip_feature_data` with the taxonomy slot populated with a taxonomy dataframe. #' @importFrom rlang := -#' + add_taxonomy <- function(feature_object, taxa, feature_id) { # make sure feature_object is the right type diff --git a/R/plot_filter_results.R b/R/plot_filter_results.R index 196bb6af..c04e4864 100644 --- a/R/plot_filter_results.R +++ b/R/plot_filter_results.R @@ -10,7 +10,6 @@ #' #' @param qsip_data_object (*qsip_data*) #' @param return_type (*string, default: combined*) Changes the return type from a combined plot (*combined*), list of individual plots (*individual*) or list of dataframes (*dataframe*) -#' @param colors (*strings*) An optional color palette #' #' @export #' @@ -21,28 +20,26 @@ plot_filter_results <- function(qsip_data_object, return_type = "combined", - colors = NULL) { - stopifnot("qsip_data_object should be class " = "qsip_data" %in% class(qsip_data_object)) + colors = lifecycle::deprecated()) { - if (!return_type %in% c("combined", "individual", "dataframe")) { - stop(glue::glue("return_type should be either one of 'combined', 'individual' or 'dataframe'")) + is_qsip_filtered(qsip_data_object, error = TRUE) + + if (lifecycle::is_present(colors)) { + lifecycle::deprecate_warn("0.17.10", "plot_filter_results(colors)") } - if (length(qsip_data_object@filter_results) == 0) { - stop(glue::glue("please run run_filter_feature() on qsip_data_object before plotting results")) + if (!return_type %in% c("combined", "individual", "dataframe")) { + stop(glue::glue("return_type should be either one of 'combined', 'individual' or 'dataframe'")) } # bind variables source_mat_id <- fraction_call <- tube_rel_abundance <- n <- NULL - if (is.null(colors)) { - colors <- c( - "Fraction Passed" = "#2B92BE", - "Fraction Filtered" = "#BE572B", - "Zero Fractions" = "gray30" - ) - } - + colors <- c( + "Fraction Passed" = "#037bcf", + "Fraction Filtered" = "#BE572B", + "Zero Fractions" = "gray70" + ) by_abundance_df <- qsip_data_object@filter_results$fraction_filtered |> dplyr::group_by(source_mat_id, fraction_call) |> diff --git a/R/qsip_objects.R b/R/qsip_objects.R index fabf7d12..0bcd1b5f 100644 --- a/R/qsip_objects.R +++ b/R/qsip_objects.R @@ -595,19 +595,19 @@ S7::method(get_dataframe, qsip_data) <- function(x, type, original_headers = FAL S7::method(print, qsip_source_data) <- function(x, ...) { sd = x@data - print(glue::glue_col(" + print(glue::glue_col(" source_material_id count: {green {length(unique(sd$source_mat_id))}}")) } S7::method(print, qsip_sample_data) <- function(x, ...) { sd = x@data - print(glue::glue_col(" + print(glue::glue_col(" source_material_id count: {green {length(unique(sd$source_mat_id))}} sample_id count: {green {length(unique(sd$sample_id))}}")) } S7::method(print, qsip_feature_data) <- function(x, ...) { - print(glue::glue_col(" + print(glue::glue_col(" feature_id count: {green {dim(x@data)[1]}} sample_id count: {green {dim(x@data)[2] - 1}} data type: {green {x@type}}")) @@ -616,7 +616,7 @@ S7::method(print, qsip_feature_data) <- function(x, ...) { S7::method(print, qsip_data) <- function(x, ...) { - print(glue::glue_col(" + print(glue::glue_col(" group: {green {ifelse(is.null(x@filter_results$group), 'none', x@filter_results$group)}} feature_id count: {green {length(get_feature_ids(x, filtered = is_qsip_filtered(x)))} of {dim(x@feature_data@data)[1]}} sample_id count: {green {length(unique(x@sample_data@data$sample_id))}} diff --git a/man/plot_filter_results.Rd b/man/plot_filter_results.Rd index 5eda713c..e2a663f9 100644 --- a/man/plot_filter_results.Rd +++ b/man/plot_filter_results.Rd @@ -4,14 +4,16 @@ \alias{plot_filter_results} \title{Plot the results of filtering features} \usage{ -plot_filter_results(qsip_data_object, return_type = "combined", colors = NULL) +plot_filter_results( + qsip_data_object, + return_type = "combined", + colors = lifecycle::deprecated() +) } \arguments{ \item{qsip_data_object}{(\emph{qsip_data})} \item{return_type}{(\emph{string, default: combined}) Changes the return type from a combined plot (\emph{combined}), list of individual plots (\emph{individual}) or list of dataframes (\emph{dataframe})} - -\item{colors}{(\emph{strings}) An optional color palette} } \value{ Combined or individual plots, or the raw dataframes diff --git a/tests/testthat/_snaps/qsip_data.md b/tests/testthat/_snaps/qsip_data.md index 584f4f17..34b7163c 100644 --- a/tests/testthat/_snaps/qsip_data.md +++ b/tests/testthat/_snaps/qsip_data.md @@ -6,7 +6,7 @@ There are 15 source_mat_ids, and they are all shared between the source and sample objects There are 284 sample_ids, and they are all shared between the sample and feature objects Output - + group: none feature_id count: 2030 of 2030 sample_id count: 284 diff --git a/tests/testthat/_snaps/qsip_sample_data.md b/tests/testthat/_snaps/qsip_sample_data.md index 972d156d..128534f4 100644 --- a/tests/testthat/_snaps/qsip_sample_data.md +++ b/tests/testthat/_snaps/qsip_sample_data.md @@ -5,7 +5,7 @@ gradient_position = "Fraction", gradient_pos_density = "density_g_ml", gradient_pos_amt = "avg_16S_g_soil", gradient_pos_rel_amt = "gradient_pos_rel_amt") Output - + source_material_id count: 15 sample_id count: 284 @@ -18,7 +18,7 @@ Message not specified. Calculating using avg_16S_g_soil column Output - + source_material_id count: 15 sample_id count: 284 diff --git a/tests/testthat/_snaps/run_EAF_calculations.md b/tests/testthat/_snaps/run_EAF_calculations.md index 05613871..e89f24b7 100644 --- a/tests/testthat/_snaps/run_EAF_calculations.md +++ b/tests/testthat/_snaps/run_EAF_calculations.md @@ -3,7 +3,7 @@ Code run_EAF_calculations(qsip_normal_strict_resampled) Output - + group: none feature_id count: 74 of 2030 sample_id count: 284 diff --git a/tests/testthat/_snaps/run_comparison_groups.md b/tests/testthat/_snaps/run_comparison_groups.md index 91f7ce12..4820a393 100644 --- a/tests/testthat/_snaps/run_comparison_groups.md +++ b/tests/testthat/_snaps/run_comparison_groups.md @@ -5,7 +5,7 @@ resamples = 100) Output $Drought - + group: Drought feature_id count: 305 of 2030 sample_id count: 284 @@ -15,7 +15,7 @@ growth: FALSE $Normal - + group: Normal feature_id count: 239 of 2030 sample_id count: 284 diff --git a/tests/testthat/_snaps/run_feature_filter.md b/tests/testthat/_snaps/run_feature_filter.md index 4c81836d..e73d14fb 100644 --- a/tests/testthat/_snaps/run_feature_filter.md +++ b/tests/testthat/_snaps/run_feature_filter.md @@ -21,7 +21,7 @@ =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ In total, 257 unique feature_ids passed all fraction and source filtering requirements Output - + group: none feature_id count: 257 of 2030 sample_id count: 284 diff --git a/tests/testthat/_snaps/run_growth_calculations.md b/tests/testthat/_snaps/run_growth_calculations.md index 3c78e3cf..e0c99920 100644 --- a/tests/testthat/_snaps/run_growth_calculations.md +++ b/tests/testthat/_snaps/run_growth_calculations.md @@ -8,7 +8,7 @@ Warning: 3968 resamplings have a negative EAF value or calculated labeled copy numbers less than 0. These values have been filtered out and added to @growth$negative_labeled Output - + group: Day 10 feature_id count: 358 of 364 sample_id count: 106 diff --git a/tests/testthat/_snaps/run_resampling.md b/tests/testthat/_snaps/run_resampling.md index 99582a05..2b3e48fc 100644 --- a/tests/testthat/_snaps/run_resampling.md +++ b/tests/testthat/_snaps/run_resampling.md @@ -3,7 +3,7 @@ Code run_resampling(qsip_normal_strict_filtered, resamples = 100, with_seed = 21) Output - + group: none feature_id count: 74 of 2030 sample_id count: 284 @@ -19,7 +19,7 @@ Message Using random seed. For consistency, you can use the with_seed argument Output - + group: none feature_id count: 74 of 2030 sample_id count: 284 @@ -35,7 +35,7 @@ Message Using random seed. For consistency, you can use the with_seed argument Output - + group: none feature_id count: 74 of 2030 sample_id count: 284 @@ -54,7 +54,7 @@ Warning: NA unlabeled and NA labeled feature_ids had resampling failures. Run `get_resample_counts()` or `plot_successful_resamples()` on your object to inspect. Output - + group: none feature_id count: 74 of 2030 sample_id count: 284 diff --git a/tests/testthat/test-plot_filter_gradient_position.R b/tests/testthat/test-plot_filter_results.R similarity index 87% rename from tests/testthat/test-plot_filter_gradient_position.R rename to tests/testthat/test-plot_filter_results.R index 8f51e225..ec710012 100644 --- a/tests/testthat/test-plot_filter_gradient_position.R +++ b/tests/testthat/test-plot_filter_results.R @@ -2,9 +2,6 @@ qsip_normal_strict_filtered <- readRDS(test_path("fixtures", "qsip_normal_strict test_that("works as expected", { expect_true("ggplot" %in% class(plot_filter_results(qsip_normal_strict_filtered))) - expect_true("ggplot" %in% class(plot_filter_results(qsip_normal_strict_filtered, - colors = c("red", "blue", "black") - ))) expect_true("ggplot" %in% class(plot_filter_results(qsip_normal_strict_filtered, return_type = "combined"