Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate default de method #265

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions R/methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2676,14 +2676,15 @@ 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
#'
#' tidybulk::se_mini |>
#' identify_abundant(factor_of_interest = condition) |>
#' test_differential_abundance(
#' ~ 0 + condition,
#' method = "edgeR_quasi_likelihood",
#' contrasts = c( "conditionTRUE - conditionFALSE")
#' )
#'
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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.")

}

Expand Down
2 changes: 1 addition & 1 deletion dev/manuscript_differential_transcript_abundance.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ tt_mds_adj_mds %>%
```

```{r}
tt_test <- tt_adj %>% test_differential_abundance(~ condition + type)
tt_test <- tt_adj %>% test_differential_abundance(~ condition + type, method = "edgeR_quasi_likelihood")

# MA plot
tt_test %>%
Expand Down
15 changes: 8 additions & 7 deletions man/test_differential_abundance-methods.Rd

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

1 change: 1 addition & 0 deletions tests/testthat/test-bulk_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
48 changes: 40 additions & 8 deletions tests/testthat/test-bulk_methods_SummarizedExperiment.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,19 @@ context('Bulk methods SummarizedExperiment')
data("se_mini")
data("breast_tcga_mini_SE")

input_df = se_mini |> tidybulk() |> as_tibble() |> setNames( c( "b","a", "c", "Cell type", "time" , "condition", "days", "dead", "entrez"))
input_df_breast = setNames( breast_tcga_mini_SE |> tidybulk() |> as_tibble(), c( "b", "a","c", "c norm", "call" ))

input_df =
se_mini |>
tidybulk() |>
as_tibble() |>
setNames( c( "b","a", "c", "Cell type", "time" , "condition", "days", "dead", "entrez"))

input_df_breast =
breast_tcga_mini_SE |>
tidybulk() |>
as_tibble() |>
setNames( c( "b", "a","c", "c norm", "call" ))


test_that("tidybulk SummarizedExperiment conversion",{

Expand All @@ -28,12 +39,28 @@ test_that("tidybulk SummarizedExperiment conversion",{

test_that("tidybulk SummarizedExperiment normalisation manual",{

res = tidybulk(tidybulk:::tidybulk_to_SummarizedExperiment(scale_abundance(tidybulk(se) |> identify_abundant())))

res2 = tidybulk(se) |> identify_abundant() |> scale_abundance()
res = se |>
tidybulk() |>
identify_abundant() |>
scale_abundance() |>
tidybulk:::tidybulk_to_SummarizedExperiment() |>
tidybulk()

res2 =
se |>
tidybulk() |>
identify_abundant() |>
scale_abundance()

res |>
distinct(.sample, multiplier) |>
pull(multiplier)

res2 |>
distinct(.sample, multiplier) |>
pull(multiplier)

res |> distinct(.sample, multiplier) |> pull(multiplier)
res2 |> distinct(.sample, multiplier) |> pull(multiplier)


expect_equal(
Expand All @@ -55,6 +82,7 @@ test_that("tidybulk SummarizedExperiment normalisation manual",{

test_that("tidybulk SummarizedExperiment normalisation",{


res = se |> identify_abundant() |> scale_abundance()

expect_equal(
Expand Down Expand Up @@ -284,7 +312,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) )
Expand All @@ -293,7 +323,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(
Expand Down Expand Up @@ -562,6 +593,7 @@ test_that("impute missing",{
tidybulk:::tidybulk_to_SummarizedExperiment(a, b, c) |>
impute_missing_abundance( ~ condition )


list_SE = SummarizedExperiment::assays(res) |> as.list()

list_SE[[1]]["TNFRSF4", "SRR1740034"] |>
Expand Down
4 changes: 3 additions & 1 deletion vignettes/introduction.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ TidyTranscriptomics
```{r de, message=FALSE, warning=FALSE, results='hide'}
se_mini.de =
se_mini |>
test_differential_abundance( ~ condition, action="get")
test_differential_abundance( ~ condition, method = "edgeR_quasi_likelihood", action="get")
se_mini.de
```
</div>
Expand Down Expand Up @@ -468,6 +468,7 @@ se_mini.de =
identify_abundant(factor_of_interest = condition) |>
test_differential_abundance(
~ 0 + condition,
method = "edgeR_quasi_likelihood",
.contrasts = c( "conditionTRUE - conditionFALSE"),
action="get"
)
Expand Down Expand Up @@ -681,6 +682,7 @@ se_mini.norm.SNN |>
mutate(factor_of_interest = `cluster_SNN` == 3) |>
test_differential_abundance(
~ factor_of_interest,
method = "edgeR_quasi_likelihood",
action="get"
)
```
Expand Down
Loading