Skip to content

Commit

Permalink
Added test for gs_score function and bump version.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gene233 committed Mar 26, 2024
1 parent a94421c commit a72ecd6
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: smartid
Title: Scoring and Marker Selection Method Based on Modified TF-IDF
Version: 0.99.1
Version: 0.99.2
Authors@R:
person("Jinjin", "Chen", email = "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-7923-5723"))
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
# smartid 0.99.1

* Ready for submission to Bioconductor.

# smartid 0.99.2

* Added test for `gs_score` function.
1 change: 1 addition & 0 deletions R/AllGenerics.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ setGeneric(
#'
#' @inheritParams gs_score_init
#' @param data an expression object, can be matrix or SummarizedExperiment
#' @param features vector or named list, feature names to compute score
#' @param slot a character, specify which slot to use when data is se object,
#' optional, default 'score'
#' @param suffix a character, specify the name suffix to save score when
Expand Down
2 changes: 1 addition & 1 deletion man/gs_score.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions tests/testthat/test-gs_score.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
test_that("gs_score works", {
## sim data
set.seed(123)
data <- matrix(rnorm(100), 10, dimnames = list(seq_len(10)))

se <- SummarizedExperiment::SummarizedExperiment(
assays = list(counts = data)
)

## test matrix
res <- gs_score(data, features = seq_len(3))
expect_type(res, "double")

## test matrix, feature list
res <- gs_score(data, features = list(a = seq_len(3), b = seq_len(5)))
expect_type(res, "list")

## test se
res <- gs_score(se, features = seq_len(3), slot = "counts")
expect_type(res$score, "double")

## test se, feature list
res <- gs_score(se, features = list(a = seq_len(3), b = seq_len(5)),
slot = "counts")
expect_type(colnames(res@colData), "character")
})
10 changes: 8 additions & 2 deletions tests/testthat/test-marker_selection.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ test_that("marker selection works", {
res <- markers_mixmdl(top_n, k = 3, dist = "gamma")
expect_type(res, "list")

## test mclust
## test mclust max.one
res <- markers_mclust(top_n)
expect_type(res, "list")
## test mclust remove.min
res <- markers_mclust(top_n, method = "remove.min")
expect_type(res, "list")

## test hdbscan
## test hdbscan max.one
res <- markers_hdbscan(top_n, minPts = 2)
expect_type(res, "list")
## test hdbscan remove.min
res <- markers_hdbscan(top_n, minPts = 2, method = "remove.min")
expect_type(res, "list")
})
2 changes: 1 addition & 1 deletion tests/testthat/test-plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ test_that("plot works", {
p <- plot_mm(mixmdl = mixmdl, dist = "gamma")
expect_true(is.ggplot(p))

## test plot_mm for gamma
## test plot_mm_clust for gamma
set.seed(123)
p <- plot_mm_clust(score = rnorm(50), clust = rep(c("A","B"), 25))
expect_true(is.ggplot(p))
Expand Down

0 comments on commit a72ecd6

Please sign in to comment.