Skip to content

Commit

Permalink
Rownames discrepancies unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
HediaTnani committed Jan 9, 2024
1 parent 629dd76 commit cd0fb5d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/DEqual.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 13 additions & 0 deletions tests/testthat/test-DEqual.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
})

0 comments on commit cd0fb5d

Please sign in to comment.