### ============================================================================
### rowCounts
###
### ----------------------------------------------------------------------------
### Non-exported methods
###
.DelayedMatrix_block_rowCounts <- function(x, rows = NULL, cols = NULL,
value = TRUE, na.rm = FALSE,
..., useNames = TRUE) {
# Check input type
stopifnot(is(x, "DelayedMatrix"))
DelayedArray:::.get_ans_type(x, must.be.numeric = FALSE)
# Subset
x <- ..subset(x, rows, cols)
# Compute result
val <- rowblock_APPLY(x = x,
FUN = rowCounts,
value = value,
na.rm = na.rm,
...,
useNames = useNames)
if (length(val) == 0L) {
return(numeric(ncol(x)))
}
unlist(val, recursive = FALSE, use.names = useNames)
}
### ----------------------------------------------------------------------------
### Exported methods
###
# ------------------------------------------------------------------------------
# General method
#
#' @inherit MatrixGenerics::rowCounts
#' @importMethodsFrom DelayedArray seed
#' @rdname colCounts
#' @export
#' @examples
#'
#' rowCounts(dm_DF, value = 5)
#' # Only count those in the odd-numbered rows of the 2nd column
#' rowCounts(dm_DF, rows = seq(1, nrow(dm_DF), 2), cols = 2, value = 5)
setMethod("rowCounts", "DelayedMatrix",
function(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE,
force_block_processing = FALSE, ..., useNames = TRUE) {
.smart_seed_dispatcher(x, generic = MatrixGenerics::rowCounts,
blockfun = .DelayedMatrix_block_rowCounts,
force_block_processing = force_block_processing,
rows = rows,
cols = cols,
value = value,
na.rm = na.rm,
...,
useNames = useNames)
}
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.