Skip to content

Commit

Permalink
Add working na.rm option and test
Browse files Browse the repository at this point in the history
  • Loading branch information
alanocallaghan committed Mar 11, 2024
1 parent 8e8f3d7 commit e4ec55e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: BASiCS
Type: Package
Title: Bayesian Analysis of Single-Cell Sequencing data
Version: 2.15.2
Date: 2023-12-22
Version: 2.15.3
Date: 2024-03-11
Authors@R: c(person("Catalina", "Vallejos", role=c("aut", "cre"),
email="[email protected]",
comment=c(ORCID = "0000-0003-3638-1960")),
Expand Down
13 changes: 8 additions & 5 deletions R/Methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,14 @@ setMethod("Summary",
nrow = ncol(n),
dimnames = list(colnames(n), c("median", "lower", "upper"))
)
HPD[,1] <- colMedians(n)
HPD[!is.na(HPD[,1]),2:3] <- coda::HPDinterval(
coda::mcmc(n[,!is.na(HPD[,1])]),
prob = prob
)
HPD[, 1] <- colMedians(n, na.rm = na.rm)
ind_not_na <- !is.na(HPD[, 1])
HPD[ind_not_na, 2:3] <- apply(n[, ind_not_na], 2, function(col) {
if (na.rm) {
col <- na.omit(col)
}
coda::HPDinterval(coda::mcmc(col), prob = prob)
})
HPD
}
)
Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ test_that("show", {
expect_output(show(v), "An object of class BASiCS_ResultVG.")
})

test_that("Summary na.rm", {
data(ChainSC)
ChainSC@parameters$nu[1, 1] <- NA
ChainSC@parameters$nu[1, 4] <- NA
s1 <- Summary(ChainSC, na.rm = TRUE)
s2 <- Summary(ChainSC, na.rm = FALSE)
expect_false(any(is.na(s1@parameters$nu)))
expect_true(all(is.na(s2@parameters$nu[1, ])))
expect_true(all(is.na(s2@parameters$nu[4, ])))
})

test_that("subset", {
data(ChainSC)
data(ChainSCReg)
Expand Down

0 comments on commit e4ec55e

Please sign in to comment.