From 7df194c754eed9eadf98fb0297bce82ea5a91591 Mon Sep 17 00:00:00 2001 From: stemangiola Date: Thu, 26 Jan 2023 17:24:25 +1100 Subject: [PATCH] deprecate default method --- R/methods.R | 21 +++++++++++++++---- man/test_differential_abundance-methods.Rd | 15 ++++++------- tests/testthat/test-bulk_methods.R | 1 + .../test-bulk_methods_SummarizedExperiment.R | 7 +++++-- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/R/methods.R b/R/methods.R index 75f8d598..8c4ed046 100755 --- a/R/methods.R +++ b/R/methods.R @@ -2676,7 +2676,7 @@ setMethod("ensembl_to_symbol", "tidybulk", .ensembl_to_symbol) #' #' tidybulk::se_mini |> #' identify_abundant() |> -#' test_differential_abundance( ~ condition ) +#' test_differential_abundance( ~ condition, method = "edgeR_quasi_likelihood" ) #' #' # The function `test_differential_abundance` operates with contrasts too #' @@ -2684,6 +2684,7 @@ setMethod("ensembl_to_symbol", "tidybulk", .ensembl_to_symbol) #' identify_abundant(factor_of_interest = condition) |> #' test_differential_abundance( #' ~ 0 + condition, +#' method = "edgeR_quasi_likelihood", #' contrasts = c( "conditionTRUE - conditionFALSE") #' ) #' @@ -2742,7 +2743,7 @@ setGeneric("test_differential_abundance", function(.data, .transcript = NULL, .abundance = NULL, contrasts = NULL, - method = "edgeR_quasi_likelihood", + method = NULL, test_above_log2_fold_change = NULL, scaling_method = "TMM", omit_contrast_in_colnames = FALSE, @@ -2765,7 +2766,7 @@ setGeneric("test_differential_abundance", function(.data, .transcript = NULL, .abundance = NULL, contrasts = NULL, - method = "edgeR_quasi_likelihood", + method = NULL, test_above_log2_fold_change = NULL, scaling_method = "TMM", omit_contrast_in_colnames = FALSE, @@ -2793,11 +2794,23 @@ setGeneric("test_differential_abundance", function(.data, .transcript = col_names$.transcript .abundance = col_names$.abundance + + + + # DEPRECATION OF method = "edgeR_quasi_likelihood" + if (is.null(method)) { + + # Signal the deprecation to the user + warning("In Jannuary 2024 the `method` argument will need to be specified and must NOT be empty. Until then method = NULL will be defaulted to \"edgeR_quasi_likelihood\" as for consistency with old version.") + + method = "edgeR_quasi_likelihood" + } + # DEPRECATION OF significance_threshold if (is_present(significance_threshold) & !is.null(significance_threshold)) { # Signal the deprecation to the user - deprecate_warn("1.1.7", "tidybulk::test_differential_abundance(significance_threshold = )", details = "The argument significance_threshold is now deprecated, tigether with the column significance.") + deprecate_warn("1.1.7", "tidybulk::test_differential_abundance(significance_threshold = )", details = "The argument significance_threshold is now deprecated, together with the column significance.") } diff --git a/man/test_differential_abundance-methods.Rd b/man/test_differential_abundance-methods.Rd index d21594b9..739565be 100755 --- a/man/test_differential_abundance-methods.Rd +++ b/man/test_differential_abundance-methods.Rd @@ -17,7 +17,7 @@ test_differential_abundance( .transcript = NULL, .abundance = NULL, contrasts = NULL, - method = "edgeR_quasi_likelihood", + method = NULL, test_above_log2_fold_change = NULL, scaling_method = "TMM", omit_contrast_in_colnames = FALSE, @@ -36,7 +36,7 @@ test_differential_abundance( .transcript = NULL, .abundance = NULL, contrasts = NULL, - method = "edgeR_quasi_likelihood", + method = NULL, test_above_log2_fold_change = NULL, scaling_method = "TMM", omit_contrast_in_colnames = FALSE, @@ -55,7 +55,7 @@ test_differential_abundance( .transcript = NULL, .abundance = NULL, contrasts = NULL, - method = "edgeR_quasi_likelihood", + method = NULL, test_above_log2_fold_change = NULL, scaling_method = "TMM", omit_contrast_in_colnames = FALSE, @@ -74,7 +74,7 @@ test_differential_abundance( .transcript = NULL, .abundance = NULL, contrasts = NULL, - method = "edgeR_quasi_likelihood", + method = NULL, test_above_log2_fold_change = NULL, scaling_method = "TMM", omit_contrast_in_colnames = FALSE, @@ -93,7 +93,7 @@ test_differential_abundance( .transcript = NULL, .abundance = NULL, contrasts = NULL, - method = "edgeR_quasi_likelihood", + method = NULL, test_above_log2_fold_change = NULL, scaling_method = "TMM", omit_contrast_in_colnames = FALSE, @@ -112,7 +112,7 @@ test_differential_abundance( .transcript = NULL, .abundance = NULL, contrasts = NULL, - method = "edgeR_quasi_likelihood", + method = NULL, test_above_log2_fold_change = NULL, scaling_method = "TMM", omit_contrast_in_colnames = FALSE, @@ -250,7 +250,7 @@ dispersion = counts |> edgeR::estimateDisp(design = design) %$% tagwise.dispersi tidybulk::se_mini |> identify_abundant() |> - test_differential_abundance( ~ condition ) + test_differential_abundance( ~ condition, method = "edgeR_quasi_likelihood" ) # The function `test_differential_abundance` operates with contrasts too @@ -258,6 +258,7 @@ dispersion = counts |> edgeR::estimateDisp(design = design) %$% tagwise.dispersi identify_abundant(factor_of_interest = condition) |> test_differential_abundance( ~ 0 + condition, + method = "edgeR_quasi_likelihood", contrasts = c( "conditionTRUE - conditionFALSE") ) diff --git a/tests/testthat/test-bulk_methods.R b/tests/testthat/test-bulk_methods.R index 8ea1506d..8712bf72 100755 --- a/tests/testthat/test-bulk_methods.R +++ b/tests/testthat/test-bulk_methods.R @@ -807,6 +807,7 @@ test_that("DESeq2 differential trancript abundance - no object",{ .sample = a, .transcript = b, .abundance = c, + method = "edgeR_quasi_likelihood", contrasts = "conditionTRUE - conditionFALSE", action="only" ) diff --git a/tests/testthat/test-bulk_methods_SummarizedExperiment.R b/tests/testthat/test-bulk_methods_SummarizedExperiment.R index 5230714e..abdcba92 100755 --- a/tests/testthat/test-bulk_methods_SummarizedExperiment.R +++ b/tests/testthat/test-bulk_methods_SummarizedExperiment.R @@ -284,7 +284,9 @@ test_that("differential trancript abundance - SummarizedExperiment",{ res = test_differential_abundance( se_mini |> identify_abundant(factor_of_interest = condition), - ~ condition + ~ condition, + method = "edgeR_quasi_likelihood" + ) w = match( c("CLEC7A" , "FAM198B", "FCN1" , "HK3" ), rownames(res) ) @@ -293,7 +295,8 @@ test_that("differential trancript abundance - SummarizedExperiment",{ res_tibble = test_differential_abundance( input_df |> identify_abundant(a, b, c, factor_of_interest = condition), ~ condition , - a, b, c + a, b, c, + method = "edgeR_quasi_likelihood" ) expect_equal(