From ccc83cd0d4bad8fac3cde99c4cfe2e73fd91bd02 Mon Sep 17 00:00:00 2001
From: aduvermy <arnaud.duvermy@ens-lyon.fr>
Date: Wed, 3 Apr 2024 10:35:01 +0200
Subject: [PATCH] modif error message

Former-commit-id: c1750543683da53f443a346710a6b2d63d30da3d
Former-commit-id: ffaeb6e9967bdbb2c869d1bab1a5cfd14f376809
Former-commit-id: 89c862167170c6bb57035aef7b84b97bbeab7d42
---
 R/prepare_data2fit.R |  2 +-
 dev/flat_full.Rmd    | 12 +++++++-----
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/R/prepare_data2fit.R b/R/prepare_data2fit.R
index 660e3de..5d0194c 100644
--- a/R/prepare_data2fit.R
+++ b/R/prepare_data2fit.R
@@ -143,7 +143,7 @@ prepareData2fit <- function(countMatrix, metadata, response_name = "kij",
                             groupID = "geneID", row_threshold = 0, transform = NULL , 
                             normalization = NULL) {
   ## -- first check
-  stopifnot("<countMatrix> and <metadata> dimensions do not match!" = dim(countMatrix)[2] == dim(metadata)[1] )
+  stopifnot("ncol(countMatrix) and nrow(metadata) do not match!" = dim(countMatrix)[2] == dim(metadata)[1] )
   
   stopifnot( length(row_threshold) == 1 && is.numeric(row_threshold) && row_threshold >= 0  )
   if (row_threshold > 0){          
diff --git a/dev/flat_full.Rmd b/dev/flat_full.Rmd
index d4642a7..2215396 100644
--- a/dev/flat_full.Rmd
+++ b/dev/flat_full.Rmd
@@ -2271,6 +2271,7 @@ test_that("replaceUnexpectedInteractionValuesBy0 replaces effects correctly", {
   N_GENES <- 10
   l_dataFrom_normdistr <- getDataFromRnorm(input_var_list, N_GENES)
   metadata <- getGeneMetadata(input_var_list , N_GENES)
+  set.seed(101)
   df_effects <- get_effects_from_rnorm(input_var_list, metadata)
   data <- cbind(metadata, df_effects) 
   
@@ -2278,16 +2279,17 @@ test_that("replaceUnexpectedInteractionValuesBy0 replaces effects correctly", {
   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"))
-  expected_data <- data.frame(geneID = "gene1", label_genotype = "genotype1", label_env = "env1", label_T = "T1", genotype = 0, 
-                              env = 0, T = 0, "genotype:env" = 0, "genotype:env:T" = 0 )
+  expect_identical(colnames(data), c("geneID","label_genotype","label_env", 
+                                     "label_T", "genotype", "env" , "T", "genotype:env"  ,"genotype:env:T"))
+  expected_data <- data.frame(geneID = "gene1", label_genotype = "genotype1", label_env = "env1", label_T = "T1", 
+                              genotype =  -0.7107595, env = -0.09334073, T = -0.1013228, "genotype:env" = 0, "genotype:env:T" = 0 )
   colnames(expected_data) <- c("geneID", "label_genotype", "label_env", "label_T", "genotype", 
                               "env", "T" , "genotype:env", "genotype:env:T" )
   expected_data$label_genotype <- factor(expected_data$label_genotype , levels = c("genotype1", "genotype2"))
   expected_data$label_env <- factor(expected_data$label_env , levels = c("env1", "env2", "env3", "env4"))
   expected_data$label_T <- factor(expected_data$label_T , levels = c("T1", "T2", "T3"))
 
-  expect_identical(data[1,], expected_data )
+  expect_equal(data[1,], expected_data ,tolerance = 0.0001 )
 
 })
 
@@ -2801,7 +2803,7 @@ prepareData2fit <- function(countMatrix, metadata, response_name = "kij",
                             groupID = "geneID", row_threshold = 0, transform = NULL , 
                             normalization = NULL) {
   ## -- first check
-  stopifnot("<countMatrix> and <metadata> dimensions do not match!" = dim(countMatrix)[2] == dim(metadata)[1] )
+  stopifnot("ncol(countMatrix) and nrow(metadata) do not match!" = dim(countMatrix)[2] == dim(metadata)[1] )
   
   stopifnot( length(row_threshold) == 1 && is.numeric(row_threshold) && row_threshold >= 0  )
   if (row_threshold > 0){          
-- 
GitLab