Skip to content

Commit

Permalink
Add an internal dataset for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
igordot committed Feb 18, 2025
1 parent 9b7b035 commit c21c55f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
21 changes: 16 additions & 5 deletions R/msigdbr.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
#'
#' @export
msigdbr <- function(species = "Homo sapiens", db_species = "HS", collection = NULL, subcollection = NULL, category = deprecated(), subcategory = deprecated()) {
# Check that msigdbdf is installed
msigdbr_check_data()

# Check parameters
if (!is(species, "character")) {
stop("`species` is not a character string")
Expand Down Expand Up @@ -58,8 +55,22 @@ msigdbr <- function(species = "Homo sapiens", db_species = "HS", collection = NU
subcollection <- subcategory
}

# Get the gene sets table
mdb <- msigdbdf::msigdbdf(target_species = db_species)
# Get the gene sets table or use an internal Hallmark dataset without msigdbdf
if (requireNamespace("msigdbdf", quietly = TRUE)) {
# Get the gene sets table
mdb <- msigdbdf::msigdbdf(target_species = db_species)
} else {
if (species == "Homo sapiens" && db_species == "HS" && collection == "H") {
# Use an internal human Hallmark dataset for minimal functionality without msigdbdf
# msigdb_h <- msigdbdf::msigdbdf(target_species = "HS")
# msigdb_h <- dplyr::filter(msigdb_h, gs_collection == "H")
# usethis::use_data(msigdb_h, internal = TRUE, overwrite = TRUE, compress = "xz")
mdb <- msigdb_h
} else {
# Check if msigdbdf is available and try to install otherwise
msigdbr_check_data()
}
}

# Filter by collection
if (is.character(collection)) {
Expand Down
Binary file added R/sysdata.rda
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/testthat/test-msigdbr.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ test_that("human db rat genes", {
})

test_that("human hallmark category", {
skip_if_not_installed("msigdbdf")
# should be using internal data if msigdbdf is not installed
m_hs_h <- msigdbr(species = "Homo sapiens", collection = "H")
expect_s3_class(m_hs_h, "tbl_df")
expect_gt(nrow(m_hs_h), 5000)
Expand Down

0 comments on commit c21c55f

Please sign in to comment.