From cd0fb5d66435cc05578f00c6ead03bc77e8be62a Mon Sep 17 00:00:00 2001 From: HediaTnani Date: Tue, 9 Jan 2024 18:45:29 -0500 Subject: [PATCH] Rownames discrepancies unit test --- R/DEqual.R | 4 ++-- tests/testthat/test-DEqual.R | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/R/DEqual.R b/R/DEqual.R index e25036c..79ae414 100644 --- a/R/DEqual.R +++ b/R/DEqual.R @@ -57,9 +57,9 @@ DEqual <- function(DE) { stop("Error: Row names of DE are null.") } - # Check if any rowname in degradation_tstats is in rownames DE + # Check if any rowname in rownames DE is in degradation_tstats if (!any(rownames(DE) %in% rownames(qsvaR::degradation_tstats) | rownames(DE) %in% (gsub('\\..*', '', rownames(qsvaR::degradation_tstats))))) { - stop("The rownames of the DE output and the rownames of the degradation t-statistic do not match") + stop("DE and degradation t-statistic rownames mismatch error.") } # Check if all rownames start with "ENST" diff --git a/tests/testthat/test-DEqual.R b/tests/testthat/test-DEqual.R index c055222..19b42b0 100644 --- a/tests/testthat/test-DEqual.R +++ b/tests/testthat/test-DEqual.R @@ -35,3 +35,16 @@ test_that("DEqual correctly processes random_de", { # Expect an error when rownames do not start with "ENST" expect_error(DEqual(altered_random_de), "Error: Some rownames do not start with 'ENST'.") +}) + +# Test: None of the DE rownames are in degradation_tstats rownames +test_that("No DE rownames are in degradation_tstats rownames", { + # Alter rownames of random_de to simulate non-matching genes + altered_random_de <- random_de + rownames(altered_random_de) <- paste0("gene", 1:length(rownames(random_de))) + + # Expect an error if rownames in altered_random_de don't match those in degradation_tstats + expect_error({ + DEqual(altered_random_de) + }, "DE and degradation t-statistic rownames mismatch error.") +}) \ No newline at end of file