diff --git a/DESCRIPTION b/DESCRIPTION index bc8454a7..688f1978 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: tidybulk Title: Brings transcriptomics to the tidyverse -Version: 1.15.5 +Version: 1.15.6 Authors@R: c(person("Stefano", "Mangiola", email = "mangiolastefano@gmail.com", role = c("aut", "cre")), person("Maria", "Doyle", email = "Maria.Doyle@petermac.org", diff --git a/R/functions.R b/R/functions.R index ed5d0087..ded23a79 100755 --- a/R/functions.R +++ b/R/functions.R @@ -465,6 +465,12 @@ get_differential_transcript_abundance_bulk <- function(.data, data = df_for_edgeR %>% select(!!.sample, one_of(parse_formula(.formula))) %>% distinct %>% arrange(!!.sample) ) + # Replace `:` with ___ because it creates error with edgeR + if(design |> colnames() |> str_detect(":") |> any()) { + message("tidybulk says: the interaction term `:` has been replaced with `___` in the design matrix, in order to work with edgeR.") + colnames(design) = design |> colnames() |> str_replace(":", "___") + } + # Print the design column names in case I want contrasts message( sprintf( diff --git a/R/functions_SE.R b/R/functions_SE.R index 557cb5e4..262d1468 100755 --- a/R/functions_SE.R +++ b/R/functions_SE.R @@ -741,6 +741,12 @@ get_differential_transcript_abundance_bulk_SE <- function(.data, data = sample_annotation ) + # Replace `:` with ___ because it creates error with edgeR + if(design |> colnames() |> str_detect(":") |> any()) { + message("tidybulk says: the interaction term `:` has been replaced with `___` in the design matrix, in order to work with edgeR.") + colnames(design) = design |> colnames() |> str_replace(":", "___") + } + # Print the design column names in case I want contrasts message( sprintf( diff --git a/tests/testthat/test-bulk_methods_SummarizedExperiment.R b/tests/testthat/test-bulk_methods_SummarizedExperiment.R index f6d1c140..26df1262 100755 --- a/tests/testthat/test-bulk_methods_SummarizedExperiment.R +++ b/tests/testthat/test-bulk_methods_SummarizedExperiment.R @@ -64,7 +64,6 @@ test_that("tidybulk SummarizedExperiment normalisation",{ }) - test_that("quantile normalisation",{ res = se_mini |> quantile_normalise_abundance() @@ -109,7 +108,6 @@ test_that("quantile normalisation",{ }) - test_that("tidybulk SummarizedExperiment normalisation subset",{ res = se |> identify_abundant() |> scale_abundance( @@ -124,10 +122,6 @@ test_that("tidybulk SummarizedExperiment normalisation subset",{ }) - - - - test_that("tidybulk SummarizedExperiment clustering",{ res = cluster_elements(se, method="kmeans", centers = 2) @@ -357,7 +351,6 @@ test_that("differential trancript abundance - SummarizedExperiment",{ }) - test_that("differential trancript abundance - SummarizedExperiment - alternative .abundance",{ assays(se_mini) = list(counts = assay(se_mini), bla = assay(se_mini)) @@ -437,6 +430,24 @@ test_that("differential trancript abundance - SummarizedExperiment - alternative }) +test_that("DE interaction effects", { + + # Att interaction factor + col_data = colData(breast_tcga_mini_SE) + set.seed(42) + col_data$interaction_term = sample(c(0,1), size = nrow(col_data), replace = TRUE) + colData(breast_tcga_mini_SE) = col_data + + breast_tcga_mini_SE |> + identify_abundant(factor_of_interest = Call) |> + test_differential_abundance( + ~ Call * interaction_term, + contrasts = "CallHer2___interaction_term", + method="edgeR_quasi_likelihood" + ) |> + expect_no_error() + +}) test_that("Voom with treat method",{ @@ -524,8 +535,6 @@ test_that("differential trancript abundance - random effects SE",{ }) - - test_that("filter abundant - SummarizedExperiment",{ res = keep_abundant( se )