diff --git a/tests/testthat/test-getDegTx.R b/tests/testthat/test-getDegTx.R index 9983012..d47d8ce 100644 --- a/tests/testthat/test-getDegTx.R +++ b/tests/testthat/test-getDegTx.R @@ -1,7 +1,10 @@ # Filter out lowly expressed transcripts and test if the number of rows in getDegTx output matches expected transcript count rse_tx_low <- rse_tx[rowMeans(assays(rse_tx)$tpm) < 1, ] test_that("length for number of rows is the same as length sig_transcripts", { - expect_equal(nrow(getDegTx(rse_tx)), length(select_transcripts())) + expect_equal( + nrow(getDegTx(rse_tx)), + length(intersect(rownames(rse_tx), select_transcripts())) + ) }) # Test if number of columns in getDegTx output matches number of columns in original dataset diff --git a/tests/testthat/test-qSVA.R b/tests/testthat/test-qSVA.R index 4c1486c..cf2c54c 100644 --- a/tests/testthat/test-qSVA.R +++ b/tests/testthat/test-qSVA.R @@ -12,8 +12,26 @@ qsva_cc <- qSVA( qsva_standard <- qSVA(rse_tx = rse_tx, mod = mod, assayname = "tpm") test_that("number of qsvs is k", { - expect_equal(length(colnames(qsva_cc)), 10) - expect_equal(length(colnames(qsva_standard)), 8) + expect_equal( + ncol(qsva_cc), + k_qsvs( + rse_tx[ + intersect( + rownames(rse_tx), select_transcripts(cell_component = TRUE) + ), + ], + mod, + assayname = "tpm" + ) + ) + expect_equal( + ncol(qsva_cc), + k_qsvs( + rse_tx[intersect(rownames(rse_tx), select_transcripts()),], + mod, + assayname = "tpm" + ) + ) }) test_that("length of qsv rownames is the same as number of samples", { diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 2a6eee2..727a0b3 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -5,7 +5,7 @@ test_that("check_tx_names throw error if annotation is not GENCODE or ENSEMBL", # For testing the error condition, altered manually rownames of rse_tx altered_rse_tx <- rse_tx rownames(altered_rse_tx) <- paste0("gene", 1:length(rownames(altered_rse_tx))) - sig_transcripts <- select_transcripts("cell_component") + sig_transcripts <- select_transcripts(cell_component = TRUE) expect_error(which_tx_names(rownames(altered_rse_tx), sig_transcripts)) expect_error(which_tx_names(sig_transcripts, rownames(altered_rse_tx))) })