Skip to content

Commit

Permalink
Fix unit test and error message for mixed annotation rownames
Browse files Browse the repository at this point in the history
Co-authored-by: Nick Eagles <[email protected]>
  • Loading branch information
HediaTnani and Nick-Eagles committed Jan 11, 2024
1 parent 060a2b9 commit 08b5a84
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/getDegTx.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ getDegTx <- function(rse_tx, type = c("cell_component", "standard", "top1500"),
is_ensembl = all(grepl("^ENST", rownames(rse_tx)) & !grepl("\\.", rownames(rse_tx)))
if (is_ensembl) {
sig_transcripts <- gsub("\\..*", "", sig_transcripts)
} else(!is_gencode) {
} else if (!is_gencode) {
stop("Rownames must all be ENSEMBL or GENCODE transcript IDs.")
}

Expand Down
13 changes: 12 additions & 1 deletion tests/testthat/test-getDegTx.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,15 @@ test_that("getDegTx works with original and altered row names", {
expect_identical(original_results, altered_results)
})


# Test where we have mixed row names annotations (ENST and ENST.*?\.)
test_that("Mixed row names annotations throw an error", {
# For testing the error condition, altered manually rownames of covComb_tx_deg
altered_covComb_tx_deg <- covComb_tx_deg
rownames(altered_covComb_tx_deg)[1] <- "ENST00000442987" # Change the first rowname
rownames(altered_covComb_tx_deg)[2] <- "ENST00000623083" # Change the second rowname
expect_error({
# Check if mixed row names annotations (ENST and ENST.*?\.) throw an error
getDegTx(altered_covComb_tx_deg)

}, "Rownames must all be ENSEMBL or GENCODE transcript IDs.")
})

0 comments on commit 08b5a84

Please sign in to comment.