diff --git a/R/prepare_data2fit.R b/R/prepare_data2fit.R index 660e3de9a0807af09ce12f416f5d1d20703dcafd..5d0194c9d67018666b32763fcd943e0ffe5583b6 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 d4642a768f1007335f4e76a9b30bd9e60128be76..22153966cd3c156a86c5a23f1be6021dd9d0740f 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){