#' Does the input object contain multiple samples?
#'
#' @name check-scalar-hasMultipleSamples
#' @note Updated 2022-03-04.
#'
#' @inherit check
#' @inheritParams AcidRoxygen::params
#'
#' @seealso `sampleNames`.
#'
#' @examples
#' data(SingleCellExperiment_splatter, package = "AcidTest")
#'
#' ## TRUE ====
#' if (requireNamespace("AcidSingleCell", quietly = TRUE)) {
#' (SingleCellExperiment_splatter)
#' }
#'
#' ## FALSE ====
#' hasMultipleSamples(list())
NULL
#' @rdname check-scalar-hasMultipleSamples
#' @export
hasMultipleSamples <- function(x) {
ok <- is(x, "SummarizedExperiment")
if (!isTRUE(ok)) {
return(false(
"{.var %s} is not {.cls SummarizedExperiment}.",
.toName(x)
))
}
requireNamespaces("Biobase")
ok <- tryCatch(
expr = {
length(Biobase::sampleNames(x)) > 1L
},
error = function(e) {
FALSE
}
)
if (!isTRUE(ok)) {
return(false(
"{.var %s} does not contain multiple samples.",
.toName(x)
))
}
TRUE
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.