From 8b0763780c5b012653380fbb6a3ad4e93d35a586 Mon Sep 17 00:00:00 2001
From: aduvermy <arnaud.duvermy@ens-lyon.fr>
Date: Tue, 2 Apr 2024 14:43:02 +0200
Subject: [PATCH] add check for <countMatrix> and <metadata> dimensions

Former-commit-id: f66936e5b1ee6ea63b9b15054f87b2916494c8e8
Former-commit-id: 3eedbea70438a57a7828338fdabc6909be139092
Former-commit-id: 3ba2e32df23e2849a7e2cd1bd6bd82f6dfc3f198
---
 R/prepare_data2fit.R      | 2 ++
 dev/flat_full.Rmd         | 2 ++
 vignettes/02-tutorial.Rmd | 1 -
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/R/prepare_data2fit.R b/R/prepare_data2fit.R
index e10e1fd..660e3de 100644
--- a/R/prepare_data2fit.R
+++ b/R/prepare_data2fit.R
@@ -142,6 +142,8 @@ custom_matrix_transform <- function(count_matrix, custom_expression) {
 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( 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 742804c..b9d8dc1 100644
--- a/dev/flat_full.Rmd
+++ b/dev/flat_full.Rmd
@@ -2801,6 +2801,8 @@ custom_matrix_transform <- function(count_matrix, custom_expression) {
 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( length(row_threshold) == 1 && is.numeric(row_threshold) && row_threshold >= 0  )
   if (row_threshold > 0){          
diff --git a/vignettes/02-tutorial.Rmd b/vignettes/02-tutorial.Rmd
index 966cd96..3eeb443 100644
--- a/vignettes/02-tutorial.Rmd
+++ b/vignettes/02-tutorial.Rmd
@@ -15,7 +15,6 @@ knitr::opts_chunk$set(
 ```
 
 ```{r setup}
-devtools::load_all()
 library(HTRfit)
 ```
 
-- 
GitLab