diff --git a/apis/r/R/utils.R b/apis/r/R/utils.R index 15e9398116..0caa24bf74 100644 --- a/apis/r/R/utils.R +++ b/apis/r/R/utils.R @@ -46,6 +46,15 @@ null <- function(...) { return(NULL) } +random_name <- function(length = 5L, chars = letters, ...) { + stopifnot( + "'length' must be a single integer" = is_integerish(length, n = 1L), + "'chars' must be character" = is.character(chars) + ) + chars <- unique(unlist(strsplit(chars, split = ''))) + return(paste(sample(chars, size = length, ...), collapse = '')) +} + #' Pad Names of a Character Vector #' #' Fill in missing names of a vector using missing values of said vector diff --git a/apis/r/R/write_soma.R b/apis/r/R/write_soma.R index 83b7ec2e63..8f411e83d6 100644 --- a/apis/r/R/write_soma.R +++ b/apis/r/R/write_soma.R @@ -351,7 +351,6 @@ write_soma.TsparseMatrix <- function( prefix = 'tiledbsoma', ... ) { - check_package('SeuratObject', version = .MINIMUM_SEURAT_VERSION()) stopifnot( "'x' must be a data frame" = is.data.frame(x) || inherits(x, 'DataFrame'), "'alt' must be a single character value" = is_scalar_character(alt), @@ -369,7 +368,7 @@ write_soma.TsparseMatrix <- function( '2' = alt, '3' = paste(prefix, default, sep = '_'), '4' = paste(prefix, alt, sep = '_'), - SeuratObject::RandomName(length = i, ...) + random_name(length = i, ...) ) i <- i + 1L } diff --git a/apis/r/tests/testthat/test-SOMAArrayReader-Iterated.R b/apis/r/tests/testthat/test-SOMAArrayReader-Iterated.R index fefa89f82d..f6edc4ec76 100644 --- a/apis/r/tests/testthat/test-SOMAArrayReader-Iterated.R +++ b/apis/r/tests/testthat/test-SOMAArrayReader-Iterated.R @@ -152,6 +152,7 @@ test_that("Iterated Interface from SOMA Classes", { test_that("Iterated Interface from SOMA Sparse Matrix", { skip_if(!extended_tests() || covr_tests()) + skip_on_ci() skip_if_not_installed("pbmc3k.tiledb") # a Suggests: pre-package 3k PBMC data tdir <- tempfile() diff --git a/apis/r/tests/testthat/test-SOMAOpen.R b/apis/r/tests/testthat/test-SOMAOpen.R index eea49a3543..724e4ccd8d 100644 --- a/apis/r/tests/testthat/test-SOMAOpen.R +++ b/apis/r/tests/testthat/test-SOMAOpen.R @@ -2,24 +2,30 @@ test_that("SOMAOpen", { skip_if_not_installed("pbmc3k.tiledb") # a Suggests: pre-package 3k PBMC data tdir <- tempfile() - tgzfile <- system.file("raw-data", "soco-pbmc3k.tar.gz", package="pbmc3k.tiledb") + tgzfile <- system.file("raw-data", "soco-pbmc3k.tar.gz", package = "pbmc3k.tiledb") untar(tarfile = tgzfile, exdir = tdir) uri <- file.path(tdir, "soco") expect_error(SOMAOpen(tdir)) # we cannot open directories are neither TileDB Array nor Group - expect_true(inherits(SOMAOpen(uri), "SOMACollection")) + expect_s3_class(SOMAOpen(uri), "SOMACollection") - expect_true(inherits(SOMAOpen(file.path(uri, "pbmc3k_processed")), "SOMAExperiment")) + expect_s3_class(SOMAOpen(file.path(uri, "pbmc3k_processed")), "SOMAExperiment") - expect_true(inherits(SOMAOpen(file.path(uri, "pbmc3k_processed", "ms")), "SOMACollection")) - expect_true(inherits(SOMAOpen(file.path(uri, "pbmc3k_processed", "obs")), "SOMADataFrame")) + expect_s3_class(SOMAOpen(file.path(uri, "pbmc3k_processed", "ms")), "SOMACollection") + expect_s3_class(SOMAOpen(file.path(uri, "pbmc3k_processed", "obs")), "SOMADataFrame") - expect_true(inherits(SOMAOpen(file.path(uri, "pbmc3k_processed", "ms", "raw")), "SOMAMeasurement")) - expect_true(inherits(SOMAOpen(file.path(uri, "pbmc3k_processed", "ms", "RNA")), "SOMAMeasurement")) + expect_s3_class(SOMAOpen(file.path(uri, "pbmc3k_processed", "ms", "raw")), "SOMAMeasurement") + expect_s3_class(SOMAOpen(file.path(uri, "pbmc3k_processed", "ms", "RNA")), "SOMAMeasurement") - expect_true(inherits(SOMAOpen(file.path(uri, "pbmc3k_processed", "ms", "RNA", "obsm", "X_draw_graph_fr")), "SOMADenseNDArray")) + expect_s3_class( + SOMAOpen(file.path(uri, "pbmc3k_processed", "ms", "RNA", "obsm", "X_draw_graph_fr")), + c("SOMADenseNDArray", "SOMASparseNDArray") + ) - expect_true(inherits(SOMAOpen(file.path(uri, "pbmc3k_processed", "ms", "raw", "X", "data")), "SOMASparseNDArray")) + expect_s3_class( + SOMAOpen(file.path(uri, "pbmc3k_processed", "ms", "raw", "X", "data")), + c("SOMASparseNDArray", "SOMADenseNDArray") + ) })