From b1d489675a55bf58ee17c21e05132f719effc177 Mon Sep 17 00:00:00 2001
From: aduvermy <arnaud.duvermy@ens-lyon.fr>
Date: Thu, 4 Apr 2024 14:21:22 +0200
Subject: [PATCH] mu hided for user exp

Former-commit-id: 56250a80365d410770eb3dd038abe0e4b6e0d1d7
Former-commit-id: 79d7ca4c3bb2f1ed291d428b31ff5050cce2235c
Former-commit-id: a5d2468176136bf03843ea163e98657e6450988a
---
 R/simulation_initialization.R           | 21 +++++++++++----------
 R/subsetgenes.R                         |  2 +-
 R/wrapper_dds.R                         |  4 ++--
 tests/testthat/test-simulation_report.R | 11 ++++++-----
 4 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/R/simulation_initialization.R b/R/simulation_initialization.R
index 416a0ae..de40d8d 100644
--- a/R/simulation_initialization.R
+++ b/R/simulation_initialization.R
@@ -4,17 +4,17 @@
 #'
 #' @param list_var Either c() or output of init_variable
 #' @param name Variable name
-#' @param mu Either a numeric value or a numeric vector (of length = level)
-#' @param sd Either numeric value or NA
+#' @param sd Either numeric value or NA. Use to specify range of effect sizes.
 #' @param level Numeric value to specify the number of levels to simulate
+#' @param mu Either a numeric value or a numeric vector (of length = level). Default : 0. Not recommended to modify.
 #'
 #' @return
 #' A list with initialized variables
 #' @export
 #'
 #' @examples
-#' init_variable(name = "my_varA", mu = 2, sd = 9, level = 200)
-init_variable <- function(list_var = c(), name = "myVariable", mu = c(2,3), sd = NA, level = NA) {
+#' init_variable(name = "my_varA", sd = 9, level = 200)
+init_variable <- function(list_var = c(), name = "myVariable", sd = NA, level = NA, mu = 0) {
   
   name <- clean_variable_name(name)
   
@@ -200,18 +200,19 @@ build_sub_obj_return_to_user <- function(level, metaData, effectsGivenByUser, co
 #'
 #' @param list_var A list of variables (already initialized)
 #' @param between_var A vector of variable names to include in the interaction
-#' @param mu Either a numeric value or a numeric vector (of length = level)
-#' @param sd Either numeric value or NA
+#' @param sd Either numeric value or NA. Use to specify range of effect sizes.
+#' @param mu Either a numeric value or a numeric vector (of length = level). Default : 0. Not recommended to modify.
+
 #'
 #' @return
 #' A list with initialized interaction
 #' @export
 #'
 #' @examples
-#' init_variable(name = "myvarA", mu = 2, sd = 3, level = 200) %>%
-#' init_variable(name = "myvarB", mu = 1, sd = 0.2, level = 2 ) %>%
-#' add_interaction(between_var = c("myvarA", "myvarB"), mu = 3, sd = 2)
-add_interaction <- function(list_var, between_var, mu, sd = NA) {
+#' init_variable(name = "myvarA", sd = 3, level = 200) %>%
+#' init_variable(name = "myvarB", sd = 0.2, level = 2 ) %>%
+#' add_interaction(between_var = c("myvarA", "myvarB"), sd = 2)
+add_interaction <- function(list_var, between_var, sd = NA, mu = 0) {
   name_interaction <- paste(between_var, collapse = ":")
   check_input2interaction(name_interaction, list_var, between_var, mu, sd)
   
diff --git a/R/subsetgenes.R b/R/subsetgenes.R
index 351d045..81cb56b 100644
--- a/R/subsetgenes.R
+++ b/R/subsetgenes.R
@@ -22,7 +22,7 @@
 #' N_GENES = 100
 #' MAX_REPLICATES = 5
 #' MIN_REPLICATES = 5
-#' input_var_list <- init_variable(name = "varA", mu = 10, sd = 0.1, level = 3)
+#' input_var_list <- init_variable(name = "varA", sd = 0.1, level = 3)
 #' mock_data <- mock_rnaseq(input_var_list, N_GENES,
 #'                         min_replicates = MIN_REPLICATES, 
 #'                         max_replicates = MAX_REPLICATES)
diff --git a/R/wrapper_dds.R b/R/wrapper_dds.R
index b2c050c..7191f50 100644
--- a/R/wrapper_dds.R
+++ b/R/wrapper_dds.R
@@ -22,8 +22,8 @@
 #' MAX_REPLICATES = 5
 #' MIN_REPLICATES = 5
 #' ## --init variable
-#' input_var_list <- init_variable( name = "genotype", mu = 12, sd = 0.1, level = 3) %>%
-#'                    init_variable(name = "environment", mu = c(0,1), NA , level = 2) 
+#' input_var_list <- init_variable( name = "genotype", sd = 0.1, level = 3) %>%
+#'                    init_variable(name = "environment", NA , level = 2) 
 #'
 #' mock_data <- mock_rnaseq(input_var_list, N_GENES, MIN_REPLICATES, MAX_REPLICATES)
 #' dds <- DESeq2::DESeqDataSetFromMatrix(mock_data$counts , 
diff --git a/tests/testthat/test-simulation_report.R b/tests/testthat/test-simulation_report.R
index d69aafd..da6f226 100644
--- a/tests/testthat/test-simulation_report.R
+++ b/tests/testthat/test-simulation_report.R
@@ -63,8 +63,6 @@ test_that("isValidEvalInput with valid input", {
 
 
 test_that("evaluation_report returns correct output", {
-  
-    
   N_GENES <- 100
   MAX_REPLICATES <- 5
   MIN_REPLICATES <- 5
@@ -126,8 +124,12 @@ test_that("get_performances_metrics_obj returns correct output", {
                                                 recall = c(0.09, 0.88)),
                          aggregate = data.frame(from = c("Glm", "Hglm"),
                                                 accuracy = c(0.7, 0.6), recall = c(0.1, 0.8)))
+  r2_agg <- data.frame(from = c("Glm", "Hglm"),
+                          RMSE = c(0.22, 0.55),
+                          R2 = c(0.9, 0.7))
+  
   # Call the function
-  result <- get_performances_metrics_obj(r2_params, r2_dispersion,
+  result <- get_performances_metrics_obj(r2_params, r2_agg, r2_dispersion,
                                           pr_obj, roc_obj, ml_metrics_obj)
   
   # Test the output
@@ -137,7 +139,7 @@ test_that("get_performances_metrics_obj returns correct output", {
   expect_equal(nrow(result$byparams), 6)
   expect_equal(ncol(result$byparams), 7)
   expect_equal(nrow(result$aggregate), 2)
-  expect_equal(ncol(result$aggregate), 5)
+  expect_equal(ncol(result$aggregate), 7)
 })
 
 
@@ -195,7 +197,6 @@ test_that("get_ml_metrics_obj returns correct output", {
 
 
 
-
 # Test get_eval_data_from_ltmb
 test_that("get_eval_data_from_ltmb returns correct output", {
   
-- 
GitLab