Skip to content

Commit

Permalink
Fix tests after interactive debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick-Eagles committed Nov 26, 2024
1 parent 19149ab commit 57317e9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
5 changes: 4 additions & 1 deletion tests/testthat/test-getDegTx.R
Original file line number Diff line number Diff line change
@@ -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
Expand Down
22 changes: 20 additions & 2 deletions tests/testthat/test-qSVA.R
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
})

0 comments on commit 57317e9

Please sign in to comment.