diff --git a/R/simulation.R b/R/simulation.R index ae12e0405f9f9723d0905eff2cb35d576998d533..d9203ddbcb8298a80a28f7c015cc4ff3fad2b21d 100644 --- a/R/simulation.R +++ b/R/simulation.R @@ -70,7 +70,6 @@ getRefLevel <- function(data){ replaceUnexpectedInteractionValuesBy0 <- function(list_var, l_labels_ref , data){ varInteraction <- getListVar(list_var$interactions) df_interaction_with0 <- sapply(varInteraction, function(var){ - var <- varInteraction categorical_var <- paste("label", unlist(strsplit(var, ":")), sep = "_") bool_matrix <- sapply(categorical_var, function(uniq_cat_var) data[uniq_cat_var] == l_labels_ref[uniq_cat_var]) idx_0 <- rowSums(bool_matrix) > 0 ## line without interactions effects diff --git a/dev/flat_full.Rmd b/dev/flat_full.Rmd index b9d8dc1bed6b21cf78189cfae4735d37f5dab284..d4642a768f1007335f4e76a9b30bd9e60128be76 100644 --- a/dev/flat_full.Rmd +++ b/dev/flat_full.Rmd @@ -1587,7 +1587,6 @@ getRefLevel <- function(data){ replaceUnexpectedInteractionValuesBy0 <- function(list_var, l_labels_ref , data){ varInteraction <- getListVar(list_var$interactions) df_interaction_with0 <- sapply(varInteraction, function(var){ - var <- varInteraction categorical_var <- paste("label", unlist(strsplit(var, ":")), sep = "_") bool_matrix <- sapply(categorical_var, function(uniq_cat_var) data[uniq_cat_var] == l_labels_ref[uniq_cat_var]) idx_0 <- rowSums(bool_matrix) > 0 ## line without interactions effects @@ -2259,7 +2258,7 @@ test_that("getRefLevel returns correct reference levels", { expect_identical(ref_levels, expected_ref_levels) }) -# Test for replaceReferenceEffectBy0 function +# Test for replaceUnexpectedInteractionValuesBy0 function test_that("replaceUnexpectedInteractionValuesBy0 replaces effects correctly", { input_var_list <- init_variable( name = "genotype", mu = 0, sd = 2.18, level = 2) %>% @@ -2276,7 +2275,7 @@ test_that("replaceUnexpectedInteractionValuesBy0 replaces effects correctly", { data <- cbind(metadata, df_effects) l_labels_ref <- getRefLevel(data) - data <- replaceReferenceEffectBy0(input_var_list, l_labels_ref, data) + data <- replaceUnexpectedInteractionValuesBy0(input_var_list, l_labels_ref, data) # Check if modified data matches the expected data expect_identical(colnames(data), c("geneID","label_genotype","label_env", "label_T", "genotype", "env" , "T", "genotype:env" ,"genotype:env:T")) @@ -8025,7 +8024,7 @@ eval_data <- data.frame(description = c("A", "A", "A"), isDE = c(TRUE, NA, FALSE test_that("isValidEvalInput with valid input", { # Définir des données de test - mock_obj <- list(settings = NULL, init = NULL, groundTruth = NULL, counts = NULL, metadata = NULL) + mock_obj <- list(settings = NULL, init = NULL, groundTruth = NULL, counts = NULL, metadata = NULL, scaling_factors = NULL) list_gene <- c("gene1", "gene2", "gene3") list_tmb <- list(glmmTMB1 = NULL, glmmTMB2 = NULL) dds <- NULL diff --git a/tests/testthat/test-simulation.R b/tests/testthat/test-simulation.R index edc46c05589d963098540bb2e7108e07b86b0085..ccb06733c51cbb27060564d0fa95d7b22ebf2eed 100644 --- a/tests/testthat/test-simulation.R +++ b/tests/testthat/test-simulation.R @@ -270,7 +270,7 @@ test_that("getRefLevel returns correct reference levels", { expect_identical(ref_levels, expected_ref_levels) }) -# Test for replaceReferenceEffectBy0 function +# Test for replaceUnexpectedInteractionValuesBy0 function test_that("replaceUnexpectedInteractionValuesBy0 replaces effects correctly", { input_var_list <- init_variable( name = "genotype", mu = 0, sd = 2.18, level = 2) %>% @@ -287,7 +287,7 @@ test_that("replaceUnexpectedInteractionValuesBy0 replaces effects correctly", { data <- cbind(metadata, df_effects) l_labels_ref <- getRefLevel(data) - data <- replaceReferenceEffectBy0(input_var_list, l_labels_ref, data) + data <- replaceUnexpectedInteractionValuesBy0(input_var_list, l_labels_ref, data) # Check if modified data matches the expected data expect_identical(colnames(data), c("geneID","label_genotype","label_env", "label_T", "genotype", "env" , "T", "genotype:env" ,"genotype:env:T"))