Skip to content

Commit

Permalink
Add unit test for assayname not in assayNames in qSVA function
Browse files Browse the repository at this point in the history
  • Loading branch information
HediaTnani committed Jan 12, 2024
1 parent c6e12f4 commit 3dd703f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion R/qSVA.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,14 @@ qSVA <-
assayname) {
## We don't need to pass type to getDegTx() since it's not used internally
## once the sig_transcripts have been defined.
DegTx <-

# Check if assayname is in assayNames
if (!assayname %in% assayNames(rse_tx)) {
stop(sprintf("'%s' is not in assayNames(rse_tx).", assayname), call. = FALSE)
}

# Get the qSVs
DegTx <-
getDegTx(rse_tx, sig_transcripts = sig_transcripts, assayname = assayname)
PCs <- getPCs(DegTx, assayname)
k <- k_qsvs(DegTx, mod = mod, assayname = assayname)
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-qSVA.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ test_that("output is a matrix", {
test_that("output is an array", {
expect_equal(class(qsva_cc)[2], "array")
})

# Test for assayname not in assayNames
test_that("qSVA throws an error when assayname is not in assayNames", {
expect_error(qSVA(covComb_tx_deg, type = "standard", mod = mod,assayname = "not_in_assayNames"), "'not_in_assayNames' is not in assayNames\\(rse_tx\\).")
})

0 comments on commit 3dd703f

Please sign in to comment.