Skip to content

Commit

Permalink
add column renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
stemangiola committed Feb 7, 2024
1 parent c0f4e86 commit 77677a8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
6 changes: 6 additions & 0 deletions R/functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 6 additions & 0 deletions R/functions_SE.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
23 changes: 14 additions & 9 deletions tests/testthat/test-bulk_methods_SummarizedExperiment.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ test_that("tidybulk SummarizedExperiment normalisation",{

})


test_that("quantile normalisation",{

res = se_mini |> quantile_normalise_abundance()
Expand Down Expand Up @@ -109,7 +108,6 @@ test_that("quantile normalisation",{

})


test_that("tidybulk SummarizedExperiment normalisation subset",{

res = se |> identify_abundant() |> scale_abundance(
Expand All @@ -124,10 +122,6 @@ test_that("tidybulk SummarizedExperiment normalisation subset",{

})





test_that("tidybulk SummarizedExperiment clustering",{

res = cluster_elements(se, method="kmeans", centers = 2)
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -437,6 +430,20 @@ 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

res =
breast_tcga_mini_SE |>
identify_abundant(factor_of_interest = Call) |>
test_differential_abundance( ~ Call * interaction_term, contrasts = "CallHer2" )

})

test_that("Voom with treat method",{

Expand Down Expand Up @@ -524,8 +531,6 @@ test_that("differential trancript abundance - random effects SE",{

})



test_that("filter abundant - SummarizedExperiment",{

res = keep_abundant( se )
Expand Down

0 comments on commit 77677a8

Please sign in to comment.