diff --git a/R/getDegTx.R b/R/getDegTx.R index 108bd27..4e25cfb 100644 --- a/R/getDegTx.R +++ b/R/getDegTx.R @@ -41,7 +41,9 @@ getDegTx <- function(rse_tx, type = c("cell_component", "standard", "top1500"), if (!is(rse_tx, "RangedSummarizedExperiment")) { stop("Error: rse_tx must be a RangedSummarizedExperiment object.") } - + if (any(!grepl("^ENST", rownames(rse_tx)))) { + stop("Error: Some rownames do not start with 'ENST'.") + } rse_tx <- rse_tx[rownames(rse_tx) %in% sig_transcripts, , drop = FALSE] if (mean(rowMeans(assays(rse_tx)[[assayname]])) < 1) { warning("The transcripts selected are lowly expressed in your dataset. This can impact downstream analysis.") diff --git a/tests/testthat/test-getDegTx.R b/tests/testthat/test-getDegTx.R index a30013d..335ea7b 100644 --- a/tests/testthat/test-getDegTx.R +++ b/tests/testthat/test-getDegTx.R @@ -19,3 +19,17 @@ test_that("test warning output for lowly expressed transcripts", { expect_warning(getDegTx(rse_tx_low)) }) +# Test for rownames starting with "ENST" +test_that("getDegTx correctly processes covComb_tx_deg", { + # If covComb_tx_deg is correctly structured and all rownames start with "ENST", expect no error + expect_silent(getDegTx(covComb_tx_deg)) + # 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] <- "INVALID0001" # Change the first rowname to an invalid one + + # Expect an error when rownames do not start with "ENST" + expect_error(getDegTx(altered_covComb_tx_deg), "Error: Some rownames do not start with 'ENST'.") +}) + + + \ No newline at end of file