MatrixGenerics/DESCRIPTION0000644000175200017520000000520014740053113016221 0ustar00biocbuildbiocbuildPackage: MatrixGenerics Title: S4 Generic Summary Statistic Functions that Operate on Matrix-Like Objects Description: S4 generic functions modeled after the 'matrixStats' API for alternative matrix implementations. Packages with alternative matrix implementation can depend on this package and implement the generic functions that are defined here for a useful set of row and column summary statistics. Other package developers can import this package and handle a different matrix implementations without worrying about incompatibilities. biocViews: Infrastructure, Software URL: https://bioconductor.org/packages/MatrixGenerics BugReports: https://github.com/Bioconductor/MatrixGenerics/issues Version: 1.18.1 License: Artistic-2.0 Encoding: UTF-8 Authors@R: c(person("Constantin", "Ahlmann-Eltze", email = "artjom31415@googlemail.com", role = c("aut"), comment = c(ORCID = "0000-0002-3762-068X")), person("Peter", "Hickey", role = c("aut", "cre"), email = "peter.hickey@gmail.com", comment = c(ORCID = "0000-0002-8153-6258")), person("Hervé", "Pagès", email = "hpages.on.github@gmail.com", role = "aut")) Depends: matrixStats (>= 1.4.1) Imports: methods Suggests: Matrix, sparseMatrixStats, SparseArray, DelayedArray, DelayedMatrixStats, SummarizedExperiment, testthat (>= 2.1.0) RoxygenNote: 7.3.2 Roxygen: list(markdown = TRUE, old_usage = TRUE) Collate: 'MatrixGenerics-package.R' 'rowAlls.R' 'rowAnyNAs.R' 'rowAnys.R' 'rowAvgsPerColSet.R' 'rowCollapse.R' 'rowCounts.R' 'rowCummaxs.R' 'rowCummins.R' 'rowCumprods.R' 'rowCumsums.R' 'rowDiffs.R' 'rowIQRDiffs.R' 'rowIQRs.R' 'rowLogSumExps.R' 'rowMadDiffs.R' 'rowMads.R' 'rowMaxs.R' 'rowMeans.R' 'rowMeans2.R' 'rowMedians.R' 'rowMins.R' 'rowOrderStats.R' 'rowProds.R' 'rowQuantiles.R' 'rowRanges.R' 'rowRanks.R' 'rowSdDiffs.R' 'rowSds.R' 'rowSums.R' 'rowSums2.R' 'rowTabulates.R' 'rowVarDiffs.R' 'rowVars.R' 'rowWeightedMads.R' 'rowWeightedMeans.R' 'rowWeightedMedians.R' 'rowWeightedSds.R' 'rowWeightedVars.R' git_url: https://git.bioconductor.org/packages/MatrixGenerics git_branch: RELEASE_3_20 git_last_commit: 5fb4445 git_last_commit_date: 2025-01-08 Repository: Bioconductor 3.20 Date/Publication: 2025-01-09 NeedsCompilation: no Packaged: 2025-01-09 23:05:47 UTC; biocbuild Author: Constantin Ahlmann-Eltze [aut] (), Peter Hickey [aut, cre] (), Hervé Pagès [aut] Maintainer: Peter Hickey MatrixGenerics/MD50000644000175200017520000001051414740053113015027 0ustar00biocbuildbiocbuild307df5ee02bde5c5b28254d11db058c9 *DESCRIPTION 6f4ecd397a49549a2e712518004bcb48 *NAMESPACE 037c4ea593fd4af666c1221c0332d8db *R/MatrixGenerics-package.R d9a1dcaf6cb360e7ae0781185b33c9ae *R/rowAlls.R 2a3d422b4ebee15ea173e44cef2ff106 *R/rowAnyNAs.R b25ba6d1bac94f0f0a96f5504d618648 *R/rowAnys.R cc478e042ad1517b36b283eb76613ce8 *R/rowAvgsPerColSet.R c1459edd69ed33b8c11b7ad8314ec0df *R/rowCollapse.R 1051af38f036911c54efdeaf0f3ba251 *R/rowCounts.R f0e188fa022bb5eab127ef2ce2373bae *R/rowCummaxs.R b14b0e65b6ba8f5bce369be422f21b0b *R/rowCummins.R 59fe866a97beede3ae06a00696c126ee *R/rowCumprods.R 2c50b090a0fd7f2ea7a26c017c6942e1 *R/rowCumsums.R 445fb8237187650f26de58593eb27caa *R/rowDiffs.R 2e38eb182e81232361fe110b5118d6be *R/rowIQRDiffs.R 35a2fa26689c19f1598cbe5a0de8d36f *R/rowIQRs.R 7942fbd29cdc210788af6bd51a760b87 *R/rowLogSumExps.R 5abd8e2ee383b1d6c44bc27d62f31d61 *R/rowMadDiffs.R 06ae28c03db4413244b8975bae66e037 *R/rowMads.R 7fffc27e3e5246865dbca9cf0690e9cf *R/rowMaxs.R 3804c2866f5178d2718b4419a5c150cd *R/rowMeans.R 2c3c34028fab866e961a016dc7a899e2 *R/rowMeans2.R 004363880526363632b250bdd216d361 *R/rowMedians.R b61e9327aa0d62ed59e679a7ac780c70 *R/rowMins.R 5806f620de71434b9dcef526bf772155 *R/rowOrderStats.R adce0e650b7947c7c22254b0620d1cff *R/rowProds.R eceb867e5657d334df660c93f614dd93 *R/rowQuantiles.R fd2f546cc943bf5f979b1e3f83c4b45f *R/rowRanges.R ac53f6b7a9ad699e67df034aa56d1b26 *R/rowRanks.R 63f2367990200fc2064cc5cfaa45bfde *R/rowSdDiffs.R b5cc841e88108108608925591493666d *R/rowSds.R d25703ff098a610a02b9b17e0d546ee9 *R/rowSums.R a2abe4c1c03d184f49acf1582ee82dec *R/rowSums2.R 02dd29c9176a3cff922d5b7e8801cadd *R/rowTabulates.R 0e247fe8b947f0b6005c09406fc2b400 *R/rowVarDiffs.R 34f0eaefc3ffc83e7ddac92803445f64 *R/rowVars.R 7d3366e3b077b8b0ec4be16b370f5b02 *R/rowWeightedMads.R 595e9f3249aabea7cf858bd11b59fa7a *R/rowWeightedMeans.R 426905a6df2edd0a81921f5cd369558b *R/rowWeightedMedians.R 5dbc3752e4d2badf7c9cbd953e510ce8 *R/rowWeightedSds.R aa05e250f119707512d80cefc88398f8 *R/rowWeightedVars.R 040b872b55aee8e5896ff46de4a1a9b3 *README.md 6a98eb6e6bda8355abb977c4408632fb *inst/NEWS.Rd 2de9a5d2d4b1aefc7045588191d7a36a *man/MatrixGenerics-package.Rd 028a14742c0184fa7d21bd0ad8e0aed0 *man/internal-helpers.Rd 4ecf385b63110ccaf72697c0ad3e6215 *man/rowAlls.Rd fcfa8fed94bcc41506f703e1d0dbd0fb *man/rowAnyNAs.Rd 2d247b986d662c80c15b85f237a2ac32 *man/rowAnys.Rd be45cd9a97204515e7566fb685ff21d1 *man/rowAvgsPerColSet.Rd cd1fc63b7e95ee6b1deb6b841652b5ac *man/rowCollapse.Rd afbade5a3bd525ed45e10029cbba4e85 *man/rowCounts.Rd d7adf287354422754a1d4d20c7ef5696 *man/rowCummaxs.Rd ef1aa99d7e39ed3f602de128d9b94915 *man/rowCummins.Rd eec01506abd63ddc9cfad7c557c4a5e5 *man/rowCumprods.Rd 28433e0f757775079c733fb8cae9d714 *man/rowCumsums.Rd 02c4bb75327e6a81b41173023f32e931 *man/rowDiffs.Rd c0282547a7363fe8234427cc3a9613ba *man/rowIQRDiffs.Rd f233037f5982d5c118ddfc8946a8247f *man/rowIQRs.Rd 67ca07ae54bb37752d6d14a2f564b57c *man/rowLogSumExps.Rd 211abb3b1feb4db6bba5d10ce94c91a8 *man/rowMadDiffs.Rd a39264ba5ba113783d24e9f649393955 *man/rowMads.Rd 44e0ccf1d6d5f8f09f9e15e1a2480230 *man/rowMaxs.Rd dc4d7e743632a1716ad11b55755bd9e0 *man/rowMeans.Rd 39b7b7393c31d5e43824a4a5cf63b407 *man/rowMeans2.Rd 5115d36c88696a9624e867cbd85ed144 *man/rowMedians.Rd 7575f9bf91708230601ec87d183c0661 *man/rowMins.Rd 5e8d3134c9166490365769edf24ad05c *man/rowOrderStats.Rd 2257523168e4dab4ee1d538b144069c9 *man/rowProds.Rd 74e956c09012307b8f1fe0b1b5110feb *man/rowQuantiles.Rd 869ff7d35582e42771de3d51ebfaa768 *man/rowRanges.Rd ad6ee4a75f63d2cb49e83485358cd105 *man/rowRanks.Rd 154dbbc5bdd3f5d28ba9a4c1415afe54 *man/rowSdDiffs.Rd 73c905784d2f78188ea57a643a84cbe8 *man/rowSds.Rd 7dfc72802fa9442972951982d176864d *man/rowSums.Rd bd0e43fad5b33b787c4bb6f903030069 *man/rowSums2.Rd a157db5a26660ac88490277ade8f3bc0 *man/rowTabulates.Rd cee6e01de6c1375ca67a5d42eefe6b43 *man/rowVarDiffs.Rd d2947b066b930d0a608132ea6329b68d *man/rowVars.Rd a164965f728b63fcbeaad03321a8f00b *man/rowWeightedMads.Rd a8aa56ade4373158f737f6fbc5db82c5 *man/rowWeightedMeans.Rd 50a7aef9132be377f9eb7dc21dca7b7b *man/rowWeightedMedians.Rd 6345bd00bd59b1563bae63b3befc1cab *man/rowWeightedSds.Rd 5115a62112a6e6b02126556cb58d2deb *man/rowWeightedVars.Rd 9b4c0233801a6fdf7c8e387bc24fb078 *tests/testthat.R 2c1a75432ae946b3f72ea16f322a4667 *tests/testthat/test-api_compatibility.R f1314f83c82adf0e157654eae2b29873 *tests/testthat/test-dynamic_implementation_loading.R MatrixGenerics/NAMESPACE0000644000175200017520000000666614710235307015757 0ustar00biocbuildbiocbuild# Generated by roxygen2: do not edit by hand export(colAlls) export(colAnyNAs) export(colAnys) export(colAvgsPerRowSet) export(colCollapse) export(colCounts) export(colCummaxs) export(colCummins) export(colCumprods) export(colCumsums) export(colDiffs) export(colIQRDiffs) export(colIQRs) export(colLogSumExps) export(colMadDiffs) export(colMads) export(colMaxs) export(colMeans) export(colMeans2) export(colMedians) export(colMins) export(colOrderStats) export(colProds) export(colQuantiles) export(colRanges) export(colRanks) export(colSdDiffs) export(colSds) export(colSums) export(colSums2) export(colTabulates) export(colVarDiffs) export(colVars) export(colWeightedMads) export(colWeightedMeans) export(colWeightedMedians) export(colWeightedSds) export(colWeightedVars) export(normarg_center) export(rowAlls) export(rowAnyNAs) export(rowAnys) export(rowAvgsPerColSet) export(rowCollapse) export(rowCounts) export(rowCummaxs) export(rowCummins) export(rowCumprods) export(rowCumsums) export(rowDiffs) export(rowIQRDiffs) export(rowIQRs) export(rowLogSumExps) export(rowMadDiffs) export(rowMads) export(rowMaxs) export(rowMeans) export(rowMeans2) export(rowMedians) export(rowMins) export(rowOrderStats) export(rowProds) export(rowQuantiles) export(rowRanges) export(rowRanks) export(rowSdDiffs) export(rowSds) export(rowSums) export(rowSums2) export(rowTabulates) export(rowVarDiffs) export(rowVars) export(rowWeightedMads) export(rowWeightedMeans) export(rowWeightedMedians) export(rowWeightedSds) export(rowWeightedVars) exportClasses(matrix_OR_array_OR_table_OR_numeric) exportMethods(colAlls) exportMethods(colAnyNAs) exportMethods(colAnys) exportMethods(colAvgsPerRowSet) exportMethods(colCollapse) exportMethods(colCounts) exportMethods(colCummaxs) exportMethods(colCummins) exportMethods(colCumprods) exportMethods(colCumsums) exportMethods(colDiffs) exportMethods(colIQRDiffs) exportMethods(colIQRs) exportMethods(colLogSumExps) exportMethods(colMadDiffs) exportMethods(colMads) exportMethods(colMaxs) exportMethods(colMeans2) exportMethods(colMedians) exportMethods(colMins) exportMethods(colOrderStats) exportMethods(colProds) exportMethods(colQuantiles) exportMethods(colRanges) exportMethods(colRanks) exportMethods(colSdDiffs) exportMethods(colSds) exportMethods(colSums2) exportMethods(colTabulates) exportMethods(colVarDiffs) exportMethods(colVars) exportMethods(colWeightedMads) exportMethods(colWeightedMeans) exportMethods(colWeightedMedians) exportMethods(colWeightedSds) exportMethods(colWeightedVars) exportMethods(rowAlls) exportMethods(rowAnyNAs) exportMethods(rowAnys) exportMethods(rowAvgsPerColSet) exportMethods(rowCollapse) exportMethods(rowCounts) exportMethods(rowCummaxs) exportMethods(rowCummins) exportMethods(rowCumprods) exportMethods(rowCumsums) exportMethods(rowDiffs) exportMethods(rowIQRDiffs) exportMethods(rowIQRs) exportMethods(rowLogSumExps) exportMethods(rowMadDiffs) exportMethods(rowMads) exportMethods(rowMaxs) exportMethods(rowMeans2) exportMethods(rowMedians) exportMethods(rowMins) exportMethods(rowOrderStats) exportMethods(rowProds) exportMethods(rowQuantiles) exportMethods(rowRanges) exportMethods(rowRanks) exportMethods(rowSdDiffs) exportMethods(rowSds) exportMethods(rowSums2) exportMethods(rowTabulates) exportMethods(rowVarDiffs) exportMethods(rowVars) exportMethods(rowWeightedMads) exportMethods(rowWeightedMeans) exportMethods(rowWeightedMedians) exportMethods(rowWeightedSds) exportMethods(rowWeightedVars) import(matrixStats) import(methods) MatrixGenerics/R/0000755000175200017520000000000014740010125014713 5ustar00biocbuildbiocbuildMatrixGenerics/R/MatrixGenerics-package.R0000644000175200017520000001344714710235307021374 0ustar00biocbuildbiocbuild#' The MatrixGenerics package #' #' The \pkg{MatrixGenerics} package defines S4 generic summary statistic #' functions that operate on matrix-Like objects. #' #' @import methods matrixStats #' #' @name MatrixGenerics-package #' @exportClass matrix_OR_array_OR_table_OR_numeric #' @aliases class:matrix_OR_array_OR_table_OR_numeric #' @aliases matrix_OR_array_OR_table_OR_numeric-class #' @aliases matrix_OR_array_OR_table_OR_numeric # NOTE: Starting with R 4.0.0 a matrix is an array so no need to explicitly # list "matrix" as a member of the union. setClassUnion("matrix_OR_array_OR_table_OR_numeric", c("array", "table", "numeric") ) ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## make_default_method_def() ## ## All packages listed below must also be listed in the Suggests field. ## They are expected to implement methods for the generics defined in ## MatrixGenerics. No need to list matrixStats here as it is special and ## already imported by default. .SUGGESTED_PACKAGES_TO_SEARCH <- c( # Most row/col summarization methods for dgCMatrix objects are defined # in the sparseMatrixStats package but a few of them are defined in the # Matrix package. "Matrix", "sparseMatrixStats", # The SparseArray package implements SVT_SparseMatrix objects and defines # row/col summarization methods for them. "SparseArray", # Most row/col summarization methods for DelayedMatrix objects are defined # in the DelayedMatrixStats package but a few of them are defined in the # DelayedArray package. "DelayedArray", "DelayedMatrixStats" # ... add more packages in the future ) .long_and_fancy_errmsg <- function(short_errmsg, unloaded_pkgs) { plural <- length(unloaded_pkgs) > 1L pkgs_to_install <- if (plural) "..." else paste0("\"", unloaded_pkgs, "\"") errmsg <- paste0(short_errmsg, "\n However, the following package", if (plural) "s are" else " is", " likely to contain the missing method\n but ", if (plural) "are" else "is", " not installed: ", paste0(unloaded_pkgs, collapse=", "), ".\n ", "Please install ", if (plural) "them" else "it", " (with 'BiocManager::install(", pkgs_to_install, ")')", if (plural) " " else "\n ", "and try again.") if (plural) errmsg <- paste0(errmsg, "\n Alternatively, if you know where ", "the missing method is defined, install\n only ", "that package.") errmsg } ## The purpose of .load_next_suggested_package_to_search() is to support ## useful fallbacks methods i.e. "ANY" methods that implement a fallback ## mechanism in case dispatch failed to find a suitable method. ## Try to load installed packages first. .load_next_suggested_package_to_search <- function(x, genericName=NULL) { if (is.null(genericName)) { ## The ugly and hacky code below tries to find the name of the ## generic. Taken from the implementation of callGeneric(). call <- sys.call(sys.parent(1L)) .local <- identical(call[[1L]], quote(.local)) methodCtxInd <- 1L + if (.local) 1L else 0L callerCtxInd <- methodCtxInd + 1L methodCall <- sys.call(sys.parent(methodCtxInd)) if (methods:::fromNextMethod(methodCall)) methodCtxInd <- methodCtxInd + 1L methodFrame <- parent.frame(methodCtxInd) genericName <- methods:::getGenericFromCall(methodCall, methodFrame) if (is.null(genericName)) stop("when 'genericName' is not supplied, ", ".load_next_suggested_package_to_search()\n ", "must be called from within a method body") } short_errmsg <- paste0("Failed to find a ", genericName,"() method ", "for ", class(x)[[1L]], " objects.") is_loaded <- vapply(.SUGGESTED_PACKAGES_TO_SEARCH, isNamespaceLoaded, logical(1)) if (all(is_loaded)) stop(short_errmsg) unloaded_pkgs <- .SUGGESTED_PACKAGES_TO_SEARCH[!is_loaded] for (pkg in unloaded_pkgs) { if (requireNamespace(pkg, quietly=TRUE)) { ## This is just a hack to refresh the method dispatch cache. ## Calling trace() on the method has the side effect of making ## showMethods(genericName) aware of the method. ## See https://github.com/Bioconductor/MatrixGenerics/pull/16#issuecomment-707516999 ## for more information. GENERIC <- match.fun(genericName) suppressMessages(trace(GENERIC, signature=class(x))) suppressMessages(untrace(GENERIC, signature=class(x))) return() } } stop(.long_and_fancy_errmsg(short_errmsg, unloaded_pkgs)) } ## Not exported (for internal use only). make_default_method_def <- function(genericName) { def <- function() { } formals(def) <- formals(match.fun(genericName)) e <- expression(MatrixGenerics:::.load_next_suggested_package_to_search(x), callGeneric()) body(def) <- as.call(c(as.name("{"), e)) environment(def) <- getNamespace("MatrixGenerics") def } ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## normarg_center() ## ## Check and normalize 'center' argument. ## Supplied 'center' must be either NULL or a numeric vector of length 'n' ## or 1. Normalized value is guaranteed to be NULL or a numeric vector of ## length 'n'. #' @export #' @name internal-helpers #' @title Internal helpers #' @description Not for end users #' @keywords internal utilities normarg_center <- function(center, n, what) { if (is.null(center)) return(center) stopifnot(is.numeric(center)) if (length(center) == 1L) return(rep.int(center, n)) if (length(center) != n) stop("'center' must be of length '", what, "' (", n, ") or 1") center } MatrixGenerics/R/rowAlls.R0000644000175200017520000000446014710235307016475 0ustar00biocbuildbiocbuild#' Check if all elements in a row (column) of a matrix-like object are equal to #' a value #' #' Check if all elements in a row (column) of a matrix-like object are equal to #' a value. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowAlls #' #' @templateVar rowName rowAlls #' @templateVar colName colAlls #' #' @template matrixStatsLink #' #' @template standardParameters #' @template valueParameter #' @template dimParameter #' @template na_rmParameter #' @template returnVectorLgl #' @template useNamesParameter #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats:rowAlls]{rowAlls}()} and #' \code{matrixStats::\link[matrixStats:rowAlls]{colAlls}()} which are #' used when the input is a \code{matrix} or \code{numeric} vector. #' \item For checks if \emph{any} element is equal to a value, see #' \code{\link{rowAnys}()}. #' \item \code{base::\link{all}()}. #' } #' #' @template standardExamples setGeneric("rowAlls", function(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("rowAlls"), signature = "x" ) .matrixStats_rowAlls <- function(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE){ matrixStats::rowAlls(x, rows = rows, cols = cols, value = value, na.rm = na.rm, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowAlls setMethod("rowAlls", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowAlls) #' @export #' @rdname rowAlls ## Default method with user-friendly fallback mechanism. setMethod("rowAlls", "ANY", make_default_method_def("rowAlls")) #' @export #' @rdname rowAlls setGeneric("colAlls", function(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("colAlls"), signature = "x" ) .matrixStats_colAlls <- function(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE){ matrixStats::colAlls(x, rows = rows, cols = cols, value = value, na.rm = na.rm, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowAlls setMethod("colAlls", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colAlls) #' @export #' @rdname rowAlls ## Default method with user-friendly fallback mechanism. setMethod("colAlls", "ANY", make_default_method_def("colAlls")) MatrixGenerics/R/rowAnyNAs.R0000644000175200017520000000406314710235307016732 0ustar00biocbuildbiocbuild#' Check if any elements in a row (column) of a matrix-like object is missing #' #' Check if any elements in a row (column) of a matrix-like object is missing. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowAnyNAs #' #' @templateVar rowName rowAnyNAs #' @templateVar colName colAnyNAs #' #' @template matrixStatsLink #' #' @template standardParameters #' @template useNamesParameter #' #' @template returnVectorLgl #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats:anyMissing]{rowAnyNAs}()} and #' \code{matrixStats::\link[matrixStats:anyMissing]{colAnyNAs}()} which are #' used when the input is a \code{matrix} or \code{numeric} vector. #' \item For checks if any element is equal to a value, see #' \code{\link{rowAnys}()}. #' \item \code{base::\link{is.na}()} and \code{base::\link{any}()}. #' } #' #' @template standardExamples setGeneric("rowAnyNAs", function(x, rows = NULL, cols = NULL, ..., useNames = TRUE) standardGeneric("rowAnyNAs"), signature = "x" ) .matrixStats_rowAnyNAs <- function(x, rows = NULL, cols = NULL, ..., useNames = TRUE){ matrixStats::rowAnyNAs(x, rows = rows, cols = cols, ..., useNames = useNames) } #' @export #' @rdname rowAnyNAs setMethod("rowAnyNAs", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowAnyNAs) #' @export #' @rdname rowAnyNAs ## Default method with user-friendly fallback mechanism. setMethod("rowAnyNAs", "ANY", make_default_method_def("rowAnyNAs")) #' @export #' @rdname rowAnyNAs setGeneric("colAnyNAs", function(x, rows = NULL, cols = NULL, ..., useNames = TRUE) standardGeneric("colAnyNAs"), signature = "x" ) .matrixStats_colAnyNAs <- function(x, rows = NULL, cols = NULL, ..., useNames = TRUE){ matrixStats::colAnyNAs(x, rows = rows, cols = cols, ..., useNames = useNames) } #' @export #' @rdname rowAnyNAs setMethod("colAnyNAs", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colAnyNAs) #' @export #' @rdname rowAnyNAs ## Default method with user-friendly fallback mechanism. setMethod("colAnyNAs", "ANY", make_default_method_def("colAnyNAs")) MatrixGenerics/R/rowAnys.R0000644000175200017520000000446114710235307016515 0ustar00biocbuildbiocbuild#' Check if any elements in a row (column) of a matrix-like object is equal to #' a value #' #' Check if any elements in a row (column) of a matrix-like object is equal to #' a value. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowAnys #' #' @templateVar rowName rowAnys #' @templateVar colName colAnys #' #' @template matrixStatsLink #' #' @template standardParameters #' @template valueParameter #' @template dimParameter #' @template na_rmParameter #' @template useNamesParameter #' @template returnVectorLgl #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats:rowAlls]{rowAnys}()} and #' \code{matrixStats::\link[matrixStats:rowAlls]{colAnys}()} which are #' used when the input is a \code{matrix} or \code{numeric} vector. #' \item For checks if \emph{all} elements are equal to a value, see #' \code{\link{rowAlls}()}. #' \item \code{base::\link{any}()}. #' } #' #' @template standardExamples setGeneric("rowAnys", function(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("rowAnys"), signature = "x" ) .matrixStats_rowAnys <- function(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE){ matrixStats::rowAnys(x, rows = rows, cols = cols, value = value, na.rm = na.rm, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowAnys setMethod("rowAnys", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowAnys) #' @export #' @rdname rowAnys ## Default method with user-friendly fallback mechanism. setMethod("rowAnys", "ANY", make_default_method_def("rowAnys")) #' @export #' @rdname rowAnys setGeneric("colAnys", function(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("colAnys"), signature = "x" ) .matrixStats_colAnys <- function(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE){ matrixStats::colAnys(x, rows = rows, cols = cols, value = value, na.rm = na.rm, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowAnys setMethod("colAnys", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colAnys) #' @export #' @rdname rowAnys ## Default method with user-friendly fallback mechanism. setMethod("colAnys", "ANY", make_default_method_def("colAnys")) MatrixGenerics/R/rowAvgsPerColSet.R0000644000175200017520000000734114710235307020264 0ustar00biocbuildbiocbuild#' Calculates for each row (column) a summary statistic for equally sized #' subsets of columns (rows) #' #' Calculates for each row (column) a summary statistic for equally sized #' subsets of columns (rows). #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowAvgsPerColSet #' #' @templateVar rowName rowAvgsPerColSet #' @templateVar colName colAvgsPerRowSet #' #' @template matrixStatsLink #' #' @param X An `NxM` matrix-like object. #' @param W An optional numeric `NxM` matrix of weights. #' @param rows,cols A \code{\link{vector}} indicating the subset (and/or #' columns) to operate over. If \code{\link{NULL}}, no subsetting is #' done. #' @param S An [integer] `KxJ` matrix that specifying the `J` subsets. Each #' column hold `K` column (row) indices for the corresponding subset. The #' range of values is \[1, M\] (\[1,N\]). #' @param FUN A row-by-row (column-by-column) summary statistic function. It is #' applied to to each column (row) subset of `X` that is specified by `S`. #' @param ... Additional arguments passed to `FUN`. #' @param na.rm (logical) Argument passed to `FUN()` as `na.rm = na.rm`. #' If `NA` (default), then `na.rm = TRUE` is used if `X` or `S` holds missing values, #' otherwise `na.rm = FALSE`. #' @param tFUN If `TRUE`, `X` is transposed before it is passed to `FUN`. #' #' #' @return Returns a numeric `JxN` (`MxJ`) matrix. #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats:rowAvgsPerColSet]{rowAvgsPerColSet}()} #' and \code{matrixStats::\link[matrixStats:rowAvgsPerColSet]{colAvgsPerRowSet}()} #' which are used when the input is a \code{matrix} or \code{numeric} vector. #' } #' #' @examples #' mat <- matrix(rnorm(20), nrow = 5, ncol = 4) #' mat[2, 1] <- NA #' mat[3, 3] <- Inf #' mat[4, 1] <- 0 #' #' print(mat) #' #' S <- matrix(1:ncol(mat), ncol = 2) #' print(S) #' #' rowAvgsPerColSet(mat, S = S, FUN = rowMeans) #' rowAvgsPerColSet(mat, S = S, FUN = rowVars) #' #' @keywords array iteration robust univar2 setGeneric("rowAvgsPerColSet", function(X, W = NULL, rows = NULL, S, FUN = rowMeans, ..., na.rm = NA, tFUN = FALSE) standardGeneric("rowAvgsPerColSet"), signature = "X" ) .matrixStats_rowAvgsPerColSet <- function(X, W = NULL, rows = NULL, S, FUN = rowMeans, ..., na.rm = NA, tFUN = FALSE){ matrixStats::rowAvgsPerColSet(X = X, W = W, rows = rows, S = S, FUN = FUN, ..., na.rm = na.rm, tFUN = tFUN) } #' @export #' @rdname rowAvgsPerColSet setMethod("rowAvgsPerColSet", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowAvgsPerColSet) #' @export #' @rdname rowAvgsPerColSet ## Default method with user-friendly fallback mechanism. setMethod("rowAvgsPerColSet", "ANY", function (X, W = NULL, rows = NULL, S, FUN = rowMeans, ..., na.rm = NA, tFUN = FALSE){ MatrixGenerics:::.load_next_suggested_package_to_search(X) callGeneric() }) #' @export #' @rdname rowAvgsPerColSet setGeneric("colAvgsPerRowSet", function(X, W = NULL, cols = NULL, S, FUN = colMeans, ..., na.rm = NA, tFUN = FALSE) standardGeneric("colAvgsPerRowSet"), signature = "X" ) .matrixStats_colAvgsPerRowSet <- function(X, W = NULL, cols = NULL, S, FUN = colMeans, ..., na.rm = NA, tFUN = FALSE){ matrixStats::colAvgsPerRowSet(X = X, W = W, cols = cols, S = S, FUN = FUN, ..., na.rm = na.rm, tFUN = tFUN) } #' @export #' @rdname rowAvgsPerColSet setMethod("colAvgsPerRowSet", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colAvgsPerRowSet) #' @export #' @rdname rowAvgsPerColSet ## Default method with user-friendly fallback mechanism. setMethod("colAvgsPerRowSet", "ANY", function (X, W = NULL, cols = NULL, S, FUN = colMeans, ..., na.rm = NA, tFUN = FALSE){ MatrixGenerics:::.load_next_suggested_package_to_search(X) callGeneric() }) MatrixGenerics/R/rowCollapse.R0000644000175200017520000000457614710235307017354 0ustar00biocbuildbiocbuild#' Extract one cell from each row (column) of a matrix-like object #' #' Extract one cell from each row (column) of a matrix-like object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowCollapse #' #' @templateVar rowName rowCollapse #' @templateVar colName colCollapse #' #' @template matrixStatsLink #' #' @template standardParameters #' @template dimParameter #' @param idxs An index \code{\link{vector}} with the position to extract. #' It is recycled to match the number of rows (column) #' @template useNamesParameter #' #' @template returnVector #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats:rowCollapse]{rowCollapse}()} #' and \code{matrixStats::\link[matrixStats:rowCollapse]{colCollapse}()} #' which are used when the input is a \code{matrix} or \code{numeric} vector. #' } #' #' @examples #' mat <- matrix(rnorm(15), nrow = 5, ncol = 3) #' mat[2, 1] <- NA #' mat[3, 3] <- Inf #' mat[4, 1] <- 0 #' #' print(mat) #' #' rowCollapse(mat, idxs = 2) #' rowCollapse(mat, idxs = c(1,1,2,3,2)) #' #' colCollapse (mat, idxs = 4) #' #' @keywords array iteration robust univar setGeneric("rowCollapse", function(x, idxs, rows = NULL, ..., useNames = TRUE) standardGeneric("rowCollapse"), signature = "x" ) .matrixStats_rowCollapse <- function(x, idxs, rows = NULL, dim. = dim(x), ..., useNames = TRUE){ matrixStats::rowCollapse(x, idxs = idxs, rows = rows, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowCollapse setMethod("rowCollapse", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowCollapse) #' @export #' @rdname rowCollapse ## Default method with user-friendly fallback mechanism. setMethod("rowCollapse", "ANY", make_default_method_def("rowCollapse")) #' @export #' @rdname rowCollapse setGeneric("colCollapse", function(x, idxs, cols = NULL, ..., useNames = TRUE) standardGeneric("colCollapse"), signature = "x" ) .matrixStats_colCollapse <- function(x, idxs, cols = NULL, dim. = dim(x), ..., useNames = TRUE){ matrixStats::colCollapse(x, idxs = idxs, cols = cols, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowCollapse setMethod("colCollapse", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colCollapse) #' @export #' @rdname rowCollapse ## Default method with user-friendly fallback mechanism. setMethod("colCollapse", "ANY", make_default_method_def("colCollapse")) MatrixGenerics/R/rowCounts.R0000644000175200017520000000474214710235307017060 0ustar00biocbuildbiocbuild#' Count how often an element in a row (column) of a matrix-like object is #' equal to a value #' #' Count how often an element in a row (column) of a matrix-like object is #' equal to a value. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowCounts #' #' @templateVar rowName rowCounts #' @templateVar colName colCounts #' #' @template matrixStatsLink #' #' @template standardParameters #' @template valueParameter #' @template dimParameter #' @template na_rmParameter #' @template useNamesParameter #' #' @template returnVectorInt #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats]{rowCounts}()} and #' \code{matrixStats::\link[matrixStats:rowCounts]{colCounts}()} which are #' used when the input is a \code{matrix} or \code{numeric} vector. #' \item For checks if any element is equal to a value, see #' \code{\link{rowAnys}()}. To check if all elements are equal, see #' \code{\link{rowAlls}()}. #' } #' #' @template standardExamples #' #' @examples #' rowCounts(mat, value = 0) #' colCounts(mat, value = Inf, na.rm = TRUE) setGeneric("rowCounts", function(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("rowCounts"), signature = "x" ) .matrixStats_rowCounts <- function(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE){ matrixStats::rowCounts(x, rows = rows, cols = cols, value = value, na.rm = na.rm, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowCounts setMethod("rowCounts", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowCounts) #' @export #' @rdname rowCounts ## Default method with user-friendly fallback mechanism. setMethod("rowCounts", "ANY", make_default_method_def("rowCounts")) #' @export #' @rdname rowCounts setGeneric("colCounts", function(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("colCounts"), signature = "x" ) .matrixStats_colCounts <- function(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE){ matrixStats::colCounts(x, rows = rows, cols = cols, value = value, na.rm = na.rm, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowCounts setMethod("colCounts", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colCounts) #' @export #' @rdname rowCounts ## Default method with user-friendly fallback mechanism. setMethod("colCounts", "ANY", make_default_method_def("colCounts")) MatrixGenerics/R/rowCummaxs.R0000644000175200017520000000425514710235307017221 0ustar00biocbuildbiocbuild#' Calculates the cumulative maxima for each row (column) of a matrix-like #' object #' #' Calculates the cumulative maxima for each row (column) of a matrix-like #' object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowCummaxs #' #' @templateVar rowName rowCummaxs #' @templateVar colName colCummaxs #' #' @template matrixStatsLink #' #' @template standardParameters #' @template dimParameter #' @template useNamesParameter #' #' @template returnMatrix_SameDimX #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats:rowCumsums]{rowCummaxs}()} and #' \code{matrixStats::\link[matrixStats:rowCumsums]{colCummaxs}()} which are #' used when the input is a \code{matrix} or \code{numeric} vector. #' \item For single maximum estimates, see \code{\link{rowMaxs}()}. #' \item \code{base::\link{cummax}()}. #' } #' #' @template standardExamples #' #' @keywords array iteration robust univar setGeneric("rowCummaxs", function(x, rows = NULL, cols = NULL, ..., useNames = TRUE) standardGeneric("rowCummaxs"), signature = "x" ) .matrixStats_rowCummaxs <- function(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE){ matrixStats::rowCummaxs(x, rows = rows, cols = cols, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowCummaxs setMethod("rowCummaxs", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowCummaxs) #' @export #' @rdname rowCummaxs ## Default method with user-friendly fallback mechanism. setMethod("rowCummaxs", "ANY", make_default_method_def("rowCummaxs")) #' @export #' @rdname rowCummaxs setGeneric("colCummaxs", function(x, rows = NULL, cols = NULL, ..., useNames = TRUE) standardGeneric("colCummaxs"), signature = "x" ) .matrixStats_colCummaxs <- function(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE){ matrixStats::colCummaxs(x, rows = rows, cols = cols, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowCummaxs setMethod("colCummaxs", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colCummaxs) #' @export #' @rdname rowCummaxs ## Default method with user-friendly fallback mechanism. setMethod("colCummaxs", "ANY", make_default_method_def("colCummaxs")) MatrixGenerics/R/rowCummins.R0000644000175200017520000000425514710235307017217 0ustar00biocbuildbiocbuild#' Calculates the cumulative minima for each row (column) of a matrix-like #' object #' #' Calculates the cumulative minima for each row (column) of a matrix-like #' object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowCummins #' #' @templateVar rowName rowCummins #' @templateVar colName colCummins #' #' @template matrixStatsLink #' #' @template standardParameters #' @template dimParameter #' @template useNamesParameter #' #' @template returnMatrix_SameDimX #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats:rowCumsums]{rowCummins}()} and #' \code{matrixStats::\link[matrixStats:rowCumsums]{colCummins}()} which are #' used when the input is a \code{matrix} or \code{numeric} vector. #' \item For single minimum estimates, see \code{\link{rowMins}()}. #' \item \code{base::\link{cummin}()}. #' } #' #' @template standardExamples #' #' @keywords array iteration robust univar setGeneric("rowCummins", function(x, rows = NULL, cols = NULL, ..., useNames = TRUE) standardGeneric("rowCummins"), signature = "x" ) .matrixStats_rowCummins <- function(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE){ matrixStats::rowCummins(x, rows = rows, cols = cols, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowCummins setMethod("rowCummins", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowCummins) #' @export #' @rdname rowCummins ## Default method with user-friendly fallback mechanism. setMethod("rowCummins", "ANY", make_default_method_def("rowCummins")) #' @export #' @rdname rowCummins setGeneric("colCummins", function(x, rows = NULL, cols = NULL, ..., useNames = TRUE) standardGeneric("colCummins"), signature = "x" ) .matrixStats_colCummins <- function(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE){ matrixStats::colCummins(x, rows = rows, cols = cols, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowCummins setMethod("colCummins", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colCummins) #' @export #' @rdname rowCummins ## Default method with user-friendly fallback mechanism. setMethod("colCummins", "ANY", make_default_method_def("colCummins")) MatrixGenerics/R/rowCumprods.R0000644000175200017520000000420714710235307017375 0ustar00biocbuildbiocbuild#' Calculates the cumulative product for each row (column) of a matrix-like #' object #' #' Calculates the cumulative product for each row (column) of a matrix-like #' object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowCumprods #' #' @templateVar rowName rowCumprods #' @templateVar colName colCumprods #' #' @template matrixStatsLink #' #' @template standardParameters #' @template dimParameter #' @template useNamesParameter #' #' @template returnMatrix_SameDimX #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats:rowCumsums]{rowCumprods}()} and #' \code{matrixStats::\link[matrixStats:rowCumsums]{colCumprods}()} which #' are used when the input is a \code{matrix} or \code{numeric} vector. #' \item \code{base::\link{cumprod}()}. #' } #' #' @template standardExamples #' #' @keywords array iteration robust univar setGeneric("rowCumprods", function(x, rows = NULL, cols = NULL, ..., useNames = TRUE) standardGeneric("rowCumprods"), signature = "x" ) .matrixStats_rowCumprods <- function(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE){ matrixStats::rowCumprods(x, rows = rows, cols = cols, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowCumprods setMethod("rowCumprods", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowCumprods) #' @export #' @rdname rowCumprods ## Default method with user-friendly fallback mechanism. setMethod("rowCumprods", "ANY", make_default_method_def("rowCumprods")) #' @export #' @rdname rowCumprods setGeneric("colCumprods", function(x, rows = NULL, cols = NULL, ..., useNames = TRUE) standardGeneric("colCumprods"), signature = "x" ) .matrixStats_colCumprods <- function(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE){ matrixStats::colCumprods(x, rows = rows, cols = cols, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowCumprods setMethod("colCumprods", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colCumprods) #' @export #' @rdname rowCumprods ## Default method with user-friendly fallback mechanism. setMethod("colCumprods", "ANY", make_default_method_def("colCumprods")) MatrixGenerics/R/rowCumsums.R0000644000175200017520000000412314710235307017232 0ustar00biocbuildbiocbuild#' Calculates the cumulative sum for each row (column) of a matrix-like object #' #' Calculates the cumulative sum for each row (column) of a matrix-like object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowCumsums #' #' @templateVar rowName rowCumsums #' @templateVar colName colCumsums #' #' @template matrixStatsLink #' #' @template standardParameters #' @template dimParameter #' @template useNamesParameter #' #' @template returnMatrix_SameDimX #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats]{rowCumsums}()} and #' \code{matrixStats::\link[matrixStats:rowCumsums]{colCumsums}()} which are #' used when the input is a \code{matrix} or \code{numeric} vector. #' \item \code{base::\link{cumsum}()}. #' } #' #' @template standardExamples #' #' @keywords array iteration robust univar setGeneric("rowCumsums", function(x, rows = NULL, cols = NULL, ..., useNames = TRUE) standardGeneric("rowCumsums"), signature = "x" ) .matrixStats_rowCumsums <- function(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE){ matrixStats::rowCumsums(x, rows = rows, cols = cols, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowCumsums setMethod("rowCumsums", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowCumsums) #' @export #' @rdname rowCumsums ## Default method with user-friendly fallback mechanism. setMethod("rowCumsums", "ANY", make_default_method_def("rowCumsums")) #' @export #' @rdname rowCumsums setGeneric("colCumsums", function(x, rows = NULL, cols = NULL, ..., useNames = TRUE) standardGeneric("colCumsums"), signature = "x" ) .matrixStats_colCumsums <- function(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE){ matrixStats::colCumsums(x, rows = rows, cols = cols, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowCumsums setMethod("colCumsums", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colCumsums) #' @export #' @rdname rowCumsums ## Default method with user-friendly fallback mechanism. setMethod("colCumsums", "ANY", make_default_method_def("colCumsums")) MatrixGenerics/R/rowDiffs.R0000644000175200017520000000471414710235307016637 0ustar00biocbuildbiocbuild#' Calculates the difference between each element of a row (column) of a #' matrix-like object #' #' Calculates the difference between each element of a row (column) of a #' matrix-like object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowDiffs #' #' @templateVar rowName rowDiffs #' @templateVar colName colDiffs #' #' @template matrixStatsLink #' #' @template standardParameters #' @param lag An integer specifying the lag. #' @param differences An integer specifying the order of difference. #' @template dimParameter #' @template useNamesParameter #' #' @return Returns a \code{\link{numeric}} \code{\link{matrix}} with one column #' (row) less than x: \eqn{Nx(K-1)} or \eqn{(N-1)xK}. #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats]{rowDiffs}()} and #' \code{matrixStats::\link[matrixStats:rowDiffs]{colDiffs}()} which are used #' when the input is a \code{matrix} or \code{numeric} vector. #' \item \code{base::\link{diff}()}. #' } #' #' @template standardExamples #' #' @keywords array iteration robust univar setGeneric("rowDiffs", function(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, ..., useNames = TRUE) standardGeneric("rowDiffs"), signature = "x" ) .matrixStats_rowDiffs <- function(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, dim. = dim(x), ..., useNames = TRUE){ matrixStats::rowDiffs(x, rows = rows, cols = cols, lag = lag, differences = differences, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowDiffs setMethod("rowDiffs", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowDiffs) #' @export #' @rdname rowDiffs ## Default method with user-friendly fallback mechanism. setMethod("rowDiffs", "ANY", make_default_method_def("rowDiffs")) #' @export #' @rdname rowDiffs setGeneric("colDiffs", function(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, ..., useNames = TRUE) standardGeneric("colDiffs"), signature = "x" ) .matrixStats_colDiffs <- function(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, dim. = dim(x), ..., useNames = TRUE){ matrixStats::colDiffs(x, rows = rows, cols = cols, lag = lag, differences = differences, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowDiffs setMethod("colDiffs", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colDiffs) #' @export #' @rdname rowDiffs ## Default method with user-friendly fallback mechanism. setMethod("colDiffs", "ANY", make_default_method_def("colDiffs")) MatrixGenerics/R/rowIQRDiffs.R0000644000175200017520000000464414710235307017215 0ustar00biocbuildbiocbuild#' Calculates the interquartile range of the difference between each element of #' a row (column) of a matrix-like object #' #' Calculates the interquartile range of the difference between each element of #' a row (column) of a matrix-like object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowIQRDiffs #' #' @templateVar rowName rowIQRDiffs #' @templateVar colName colIQRDiffs #' #' @template matrixStatsLink #' #' @template standardParameters #' @template diff_trimParameters #' @template na_rmParameter #' @template useNamesParameter #' #' @template returnVector #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats:varDiff]{rowIQRDiffs}()} and #' \code{matrixStats::\link[matrixStats:varDiff]{colIQRDiffs}()} which #' are used when the input is a \code{matrix} or \code{numeric} vector. #' \item For the direct interquartile range see also [rowIQRs]. #' } #' #' @template standardExamples #' #' @keywords array iteration robust univar setGeneric("rowIQRDiffs", function(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) standardGeneric("rowIQRDiffs"), signature = "x" ) .matrixStats_rowIQRDiffs <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE){ matrixStats::rowIQRDiffs(x, rows = rows, cols = cols, na.rm = na.rm, diff = diff, trim = trim, ..., useNames = useNames) } #' @export #' @rdname rowIQRDiffs setMethod("rowIQRDiffs", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowIQRDiffs) #' @export #' @rdname rowIQRDiffs ## Default method with user-friendly fallback mechanism. setMethod("rowIQRDiffs", "ANY", make_default_method_def("rowIQRDiffs")) #' @export #' @rdname rowIQRDiffs setGeneric("colIQRDiffs", function(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) standardGeneric("colIQRDiffs"), signature = "x" ) .matrixStats_colIQRDiffs <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE){ matrixStats::colIQRDiffs(x, rows = rows, cols = cols, na.rm = na.rm, diff = diff, trim = trim, ..., useNames = useNames) } #' @export #' @rdname rowIQRDiffs setMethod("colIQRDiffs", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colIQRDiffs) #' @export #' @rdname rowIQRDiffs ## Default method with user-friendly fallback mechanism. setMethod("colIQRDiffs", "ANY", make_default_method_def("colIQRDiffs")) MatrixGenerics/R/rowIQRs.R0000644000175200017520000000423514710235307016420 0ustar00biocbuildbiocbuild#' Calculates the interquartile range for each row (column) of a matrix-like #' object #' #' Calculates the interquartile range for each row (column) of a matrix-like #' object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowIQRs #' #' @templateVar rowName rowIQRs #' @templateVar colName colIQRs #' #' @template matrixStatsLink #' #' @template standardParameters #' @template na_rmParameter #' @template useNamesParameter #' #' @template returnVector #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats]{rowIQRs}()} and #' \code{matrixStats::\link[matrixStats:rowIQRs]{colIQRs}()} which are used #' when the input is a \code{matrix} or \code{numeric} vector. #' \item For a non-robust analog, see \code{\link{rowSds}()}. For a more #' robust version see [rowMads()] #' \item \code{stats::\link[stats]{IQR}()}. #' } #' #' @template standardExamples #' #' @keywords array iteration robust univar setGeneric("rowIQRs", function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("rowIQRs"), signature = "x" ) .matrixStats_rowIQRs <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE){ matrixStats::rowIQRs(x, rows = rows, cols = cols, na.rm = na.rm, ..., useNames = useNames) } #' @export #' @rdname rowIQRs setMethod("rowIQRs", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowIQRs) #' @export #' @rdname rowIQRs ## Default method with user-friendly fallback mechanism. setMethod("rowIQRs", "ANY", make_default_method_def("rowIQRs")) #' @export #' @rdname rowIQRs setGeneric("colIQRs", function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("colIQRs"), signature = "x" ) .matrixStats_colIQRs <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE){ matrixStats::colIQRs(x, rows = rows, cols = cols, na.rm = na.rm, ..., useNames = useNames) } #' @export #' @rdname rowIQRs setMethod("colIQRs", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colIQRs) #' @export #' @rdname rowIQRs ## Default method with user-friendly fallback mechanism. setMethod("colIQRs", "ANY", make_default_method_def("colIQRs")) MatrixGenerics/R/rowLogSumExps.R0000644000175200017520000000547214710235307017654 0ustar00biocbuildbiocbuild#' Accurately calculates the logarithm of the sum of exponentials for each row #' (column) of a matrix-like object #' #' Accurately calculates the logarithm of the sum of exponentials for each row #' (column) of a matrix-like object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowLogSumExps #' #' @templateVar rowName rowLogSumExps #' @templateVar colName colLogSumExps #' #' @template matrixStatsLink #' #' @param lx An NxK matrix-like object. Typically `lx` are `log(x)` values. #' @param rows,cols A \code{\link{vector}} indicating the subset (and/or #' columns) to operate over. If \code{\link{NULL}}, no subsetting is done. #' @param ... Additional arguments passed to specific methods. #' @template na_rmParameter #' @template dimParameter #' @template useNamesParameter #' #' @template returnVector #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats]{rowLogSumExps}()} and #' \code{matrixStats::\link[matrixStats:rowLogSumExps]{colLogSumExps}()} #' which are used when the input is a \code{matrix} or \code{numeric} vector. #' \item [rowSums2()] #' } #' #' @template standardExamples #' #' @keywords array iteration robust univar setGeneric("rowLogSumExps", function(lx, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("rowLogSumExps"), signature = "lx" ) .matrixStats_rowLogSumExps <- function(lx, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(lx), ..., useNames = TRUE){ matrixStats::rowLogSumExps(lx, rows = rows, cols = cols, na.rm = na.rm, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowLogSumExps setMethod("rowLogSumExps", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowLogSumExps) #' @export #' @rdname rowLogSumExps ## Default method with user-friendly fallback mechanism. setMethod("rowLogSumExps", "ANY", function (lx, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE){ MatrixGenerics:::.load_next_suggested_package_to_search(lx) callGeneric() }) #' @export #' @rdname rowLogSumExps setGeneric("colLogSumExps", function(lx, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("colLogSumExps"), signature = "lx" ) .matrixStats_colLogSumExps <- function(lx, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(lx), ..., useNames = TRUE){ matrixStats::colLogSumExps(lx, rows = rows, cols = cols, na.rm = na.rm, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowLogSumExps setMethod("colLogSumExps", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colLogSumExps) #' @export #' @rdname rowLogSumExps ## Default method with user-friendly fallback mechanism. setMethod("colLogSumExps", "ANY", function (lx, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE){ MatrixGenerics:::.load_next_suggested_package_to_search(lx) callGeneric() }) MatrixGenerics/R/rowMadDiffs.R0000644000175200017520000000455314710235307017262 0ustar00biocbuildbiocbuild#' Calculates the mean absolute deviation of the difference between each #' element of a row (column) of a matrix-like object #' #' Calculates the mean absolute deviation of the difference between each #' element of a row (column) of a matrix-like object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowMadDiffs #' #' @templateVar rowName rowMadDiffs #' @templateVar colName colMadDiffs #' #' @template matrixStatsLink #' #' @template standardParameters #' @template diff_trimParameters #' @template na_rmParameter #' @template useNamesParameter #' #' @template returnVector #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats:varDiff]{rowMadDiffs}()} and #' \code{matrixStats::\link[matrixStats:varDiff]{colMadDiffs}()} which #' are used when the input is a \code{matrix} or \code{numeric} vector. #' } #' #' @template standardExamples #' #' @keywords array iteration robust univar setGeneric("rowMadDiffs", function(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) standardGeneric("rowMadDiffs"), signature = "x" ) .matrixStats_rowMadDiffs <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE){ matrixStats::rowMadDiffs(x, rows = rows, cols = cols, na.rm = na.rm, diff = diff, trim = trim, ..., useNames = useNames) } #' @export #' @rdname rowMadDiffs setMethod("rowMadDiffs", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowMadDiffs) #' @export #' @rdname rowMadDiffs ## Default method with user-friendly fallback mechanism. setMethod("rowMadDiffs", "ANY", make_default_method_def("rowMadDiffs")) #' @export #' @rdname rowMadDiffs setGeneric("colMadDiffs", function(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) standardGeneric("colMadDiffs"), signature = "x" ) .matrixStats_colMadDiffs <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE){ matrixStats::colMadDiffs(x, rows = rows, cols = cols, na.rm = na.rm, diff =diff, trim = trim, ..., useNames = useNames) } #' @export #' @rdname rowMadDiffs setMethod("colMadDiffs", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colMadDiffs) #' @export #' @rdname rowMadDiffs ## Default method with user-friendly fallback mechanism. setMethod("colMadDiffs", "ANY", make_default_method_def("colMadDiffs")) MatrixGenerics/R/rowMads.R0000644000175200017520000000541414710235307016466 0ustar00biocbuildbiocbuild#' Calculates the median absolute deviation for each row (column) of a #' matrix-like object #' #' Calculates the median absolute deviation for each row (column) of a #' matrix-like object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowMads #' #' @templateVar rowName rowMads #' @templateVar colName colMads #' #' @template matrixStatsLink #' #' @template standardParameters #' @template na_rmParameter #' @param center (optional) the center, defaults to the row means #' @param constant A scale factor. See \code{stats::\link[stats]{mad}()} for #' details. #' @template dimParameter #' @template useNamesParameter #' #' @template returnVector #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats:rowSds]{rowMads}()} and #' \code{matrixStats::\link[matrixStats:rowSds]{colMads}()} which are used #' when the input is a \code{matrix} or \code{numeric} vector. #' \item For mean estimates, see \code{\link{rowMeans2}()} and #' \code{\link[base:colSums]{rowMeans}()}. #' \item For non-robust standard deviation estimates, see #' \code{\link{rowSds}()}. #' } #' #' @template standardExamples #' #' @keywords array iteration robust univar setGeneric("rowMads", function(x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("rowMads"), signature = "x" ) .matrixStats_rowMads <- function(x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE){ center <- normarg_center(center, nrow(x), "nrow(x)") matrixStats::rowMads(x, rows = rows, cols = cols, center = center, constant = constant, na.rm = na.rm, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowMads setMethod("rowMads", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowMads) #' @export #' @rdname rowMads ## Default method with user-friendly fallback mechanism. setMethod("rowMads", "ANY", make_default_method_def("rowMads")) #' @export #' @rdname rowMads setGeneric("colMads", function(x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("colMads"), signature = "x" ) .matrixStats_colMads <- function(x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE){ center <- normarg_center(center, ncol(x), "ncol(x)") matrixStats::colMads(x, rows = rows, cols = cols, center = center, constant = constant, na.rm = na.rm, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowMads setMethod("colMads", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colMads) #' @export #' @rdname rowMads ## Default method with user-friendly fallback mechanism. setMethod("colMads", "ANY", make_default_method_def("colMads")) MatrixGenerics/R/rowMaxs.R0000644000175200017520000000417614710235307016516 0ustar00biocbuildbiocbuild#' Calculates the maximum for each row (column) of a matrix-like object #' #' Calculates the maximum for each row (column) of a matrix-like object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowMaxs #' #' @templateVar rowName rowMaxs #' @templateVar colName colMaxs #' #' @template matrixStatsLink #' #' @template standardParameters #' @template na_rmParameter #' @template dimParameter #' @template useNamesParameter #' #' @template returnVector #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats:rowRanges]{rowMaxs}()} and #' \code{matrixStats::\link[matrixStats:rowRanges]{colMaxs}()} which are used #' when the input is a \code{matrix} or \code{numeric} vector. #' \item For min estimates, see \code{\link{rowMins}()}. #' } #' #' @template standardExamples #' #' @keywords array iteration robust univar setGeneric("rowMaxs", function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("rowMaxs"), signature = "x" ) .matrixStats_rowMaxs <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE){ matrixStats::rowMaxs(x, rows = rows, cols = cols, na.rm = na.rm, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowMaxs setMethod("rowMaxs", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowMaxs) #' @export #' @rdname rowMaxs ## Default method with user-friendly fallback mechanism. setMethod("rowMaxs", "ANY", make_default_method_def("rowMaxs")) #' @export #' @rdname rowMaxs setGeneric("colMaxs", function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("colMaxs"), signature = "x" ) .matrixStats_colMaxs <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE){ matrixStats::colMaxs(x, rows = rows, cols = cols, na.rm = na.rm, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowMaxs setMethod("colMaxs", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colMaxs) #' @export #' @rdname rowMaxs ## Default method with user-friendly fallback mechanism. setMethod("colMaxs", "ANY", make_default_method_def("colMaxs")) MatrixGenerics/R/rowMeans.R0000644000175200017520000001002214710235307016634 0ustar00biocbuildbiocbuild## IMPORTANT NOTE: We don't provide a user-friendly fallback mechanism for ## rowMeans() and colMeans(). Here is why: ## The method package defines **implicit generics** for the rowMeans() ## and colMeans() functions and this is what we get when we call ## setGeneric("rowMeans") and setGeneric("colMeans") below. These implicit ## generics introduce 2 surprises: ## 1. Their argument list (x, na.rm=FALSE, dims=1, ...) differs slightly from ## base::rowMeans and base::colMeans. This means that we need to be careful ## to use this same exact argument list in the rowMeans() and colMeans() ## methods that we define below. ## 2. They define their own default method that basically calls base::rowMeans() ## or base::colMeans(). Unfortunately, trying to override these default ## methods with our own doesn't work. Even if selectMethod("rowMeans", "ANY") ## and selectMethod("colMeans", "ANY") return our methods right after ## loading MatrixGenerics in a fresh R session, this is no longer the case ## if we then load the DelayedArray package. Then the default methods get ## replaced with the original default methods defined by the implicit ## generics. VERY NASTY! This is why our attempts at providing user-friendly ## fallback mechanisms for rowMeans() and colMeans() are commented out below. #' Calculates the mean for each row (column) of a matrix-like object #' #' Calculates the mean for each row (column) of a matrix-like object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowMeans #' #' @templateVar rowName rowMeans #' @templateVar colName colMeans #' #' @param x An NxK matrix-like object, a numeric data frame, or an array-like #' object of two or more dimensions. #' @template na_rmParameter #' @param dims A single integer indicating which dimensions are regarded #' as rows or columns to mean over. For \code{rowMeans}, the mean is over #' dimensions \code{dims+1, ...}; for \code{colMeans} it is over #' dimensions \code{1:dims}. #' @param ... Additional arguments passed to specific methods. #' #' @details This man page documents the \code{rowMeans} and \code{colMeans} #' \emph{S4 generic functions} defined in the \pkg{MatrixGenerics} package. #' See \code{?base::\link[base]{colMeans}} for the default methods (defined #' in the \pkg{base} package). # #' The S4 methods for \code{x} of type \code{\link{matrix}}, # #' \code{\link{array}}, \code{\link{table}}, \code{\link{numeric}}, or # #' \code{\link{data.frame}} call \code{base::\link[base]{rowMeans}} / # #' \code{base::\link[base]{colMeans}}. #' #' @template returnVector #' #' @seealso #' \itemize{ #' \item \code{base::\link[base]{colMeans}} for the default #' \code{rowMeans} and \code{colMeans} methods. #' \item \code{Matrix::\link[Matrix]{colMeans}} in the \pkg{Matrix} package #' for \code{rowMeans} and \code{colMeans} methods defined for #' CsparseMatrix derivatives (e.g. dgCMatrix objects). #' } #' #' @template standardExamples #' #' @keywords array algebra arith iteration robust univar setGeneric("rowMeans") # .base_rowMeans <- function(x, na.rm=FALSE, dims=1, ...) # { # base::rowMeans(x, na.rm=na.rm, dims=dims, ...) # } # # #' @export # #' @rdname rowMeans # setMethod("rowMeans", "matrix_OR_array_OR_table_OR_numeric", .base_rowMeans) # # #' @export # #' @rdname rowMeans # setMethod("rowMeans", "data.frame", .base_rowMeans) # # #' @export # #' @rdname rowMeans # ## Default method with user-friendly fallback mechanism. # setMethod("rowMeans", "ANY", make_default_method_def("rowMeans")) #' @export #' @rdname rowMeans setGeneric("colMeans") # .base_colMeans <- function(x, na.rm=FALSE, dims=1, ...) # { # base::colMeans(x, na.rm=na.rm, dims=dims, ...) # } # # #' @export # #' @rdname rowMeans # setMethod("colMeans", "matrix_OR_array_OR_table_OR_numeric", .base_colMeans) # # #' @export # #' @rdname rowMeans # setMethod("colMeans", "data.frame", .base_colMeans) # # #' @export # #' @rdname rowMeans # ## Default method with user-friendly fallback mechanism. # setMethod("colMeans", "ANY", make_default_method_def("colMeans")) MatrixGenerics/R/rowMeans2.R0000644000175200017520000000452714710235307016733 0ustar00biocbuildbiocbuild#' Calculates the mean for each row (column) of a matrix-like object #' #' Calculates the mean for each row (column) of a matrix-like object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowMeans2 #' #' @templateVar rowName rowMeans2 #' @templateVar colName colMeans2 #' #' @template matrixStatsLink #' #' @template standardParameters #' @template na_rmParameter #' @template dimParameter #' @template useNamesParameter #' #' @template returnVector #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats]{rowMeans2}()} and #' \code{matrixStats::\link[matrixStats:rowMeans2]{colMeans2}()} which are #' used when the input is a \code{matrix} or \code{numeric} vector. #' \item See also \code{\link[base:colSums]{rowMeans}()} for the #' corresponding function in base R. #' \item For variance estimates, see \code{\link{rowVars}()}. #' \item See also the base R version \code{base::\link{rowMeans}()}. #' } #' #' @template standardExamples #' #' #' @keywords array iteration robust univar setGeneric("rowMeans2", function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("rowMeans2"), signature = "x" ) .matrixStats_rowMeans2 <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE){ matrixStats::rowMeans2(x, rows = rows, cols = cols, na.rm = na.rm, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowMeans2 setMethod("rowMeans2", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowMeans2) #' @export #' @rdname rowMeans2 ## Default method with user-friendly fallback mechanism. setMethod("rowMeans2", "ANY", make_default_method_def("rowMeans2")) #' @export #' @rdname rowMeans2 setGeneric("colMeans2", function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("colMeans2"), signature = "x" ) .matrixStats_colMeans2 <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE){ matrixStats::colMeans2(x, rows = rows, cols = cols, na.rm = na.rm, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowMeans2 setMethod("colMeans2", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colMeans2) #' @export #' @rdname rowMeans2 ## Default method with user-friendly fallback mechanism. setMethod("colMeans2", "ANY", make_default_method_def("colMeans2")) MatrixGenerics/R/rowMedians.R0000644000175200017520000000436414710235307017165 0ustar00biocbuildbiocbuild#' Calculates the median for each row (column) of a matrix-like object #' #' Calculates the median for each row (column) of a matrix-like object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowMedians #' #' @templateVar rowName rowMedians #' @templateVar colName colMedians #' #' @template matrixStatsLink #' #' @template standardParameters #' @template na_rmParameter #' @template dimParameter #' @template useNamesParameter #' #' @template returnVector #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats]{rowMedians}()} and #' \code{matrixStats::\link[matrixStats:rowMedians]{colMedians}()} which are #' used when the input is a \code{matrix} or \code{numeric} vector. #' \item For mean estimates, see \code{\link{rowMeans2}()} and #' \code{\link[base:colSums]{rowMeans}()}. #' } #' #' @template standardExamples #' #' @keywords array iteration robust univar setGeneric("rowMedians", function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("rowMedians"), signature = "x" ) .matrixStats_rowMedians <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE){ matrixStats::rowMedians(x, rows = rows, cols = cols, na.rm = na.rm, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowMedians setMethod("rowMedians", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowMedians) #' @export #' @rdname rowMedians ## Default method with user-friendly fallback mechanism. setMethod("rowMedians", "ANY", make_default_method_def("rowMedians")) #' @export #' @rdname rowMedians setGeneric("colMedians", function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("colMedians"), signature = "x" ) .matrixStats_colMedians <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE){ matrixStats::colMedians(x, rows = rows, cols = cols, na.rm = na.rm, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowMedians setMethod("colMedians", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colMedians) #' @export #' @rdname rowMedians ## Default method with user-friendly fallback mechanism. setMethod("colMedians", "ANY", make_default_method_def("colMedians")) MatrixGenerics/R/rowMins.R0000644000175200017520000000417614710235307016514 0ustar00biocbuildbiocbuild#' Calculates the minimum for each row (column) of a matrix-like object #' #' Calculates the minimum for each row (column) of a matrix-like object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowMins #' #' @templateVar rowName rowMins #' @templateVar colName colMins #' #' @template matrixStatsLink #' #' @template standardParameters #' @template na_rmParameter #' @template dimParameter #' @template useNamesParameter #' #' @template returnVector #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats:rowRanges]{rowMins}()} and #' \code{matrixStats::\link[matrixStats:rowRanges]{colMins}()} which are used #' when the input is a \code{matrix} or \code{numeric} vector. #' \item For max estimates, see \code{\link{rowMaxs}()}. #' } #' #' @template standardExamples #' #' @keywords array iteration robust univar setGeneric("rowMins", function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("rowMins"), signature = "x" ) .matrixStats_rowMins <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE){ matrixStats::rowMins(x, rows = rows, cols = cols, na.rm = na.rm, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowMins setMethod("rowMins", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowMins) #' @export #' @rdname rowMins ## Default method with user-friendly fallback mechanism. setMethod("rowMins", "ANY", make_default_method_def("rowMins")) #' @export #' @rdname rowMins setGeneric("colMins", function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("colMins"), signature = "x" ) .matrixStats_colMins <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE){ matrixStats::colMins(x, rows = rows, cols = cols, na.rm = na.rm, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowMins setMethod("colMins", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colMins) #' @export #' @rdname rowMins ## Default method with user-friendly fallback mechanism. setMethod("colMins", "ANY", make_default_method_def("colMins")) MatrixGenerics/R/rowOrderStats.R0000644000175200017520000000474114710235307017676 0ustar00biocbuildbiocbuild#' Calculates an order statistic for each row (column) of a matrix-like object #' #' Calculates an order statistic for each row (column) of a matrix-like object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowOrderStats #' #' @templateVar rowName rowOrderStats #' @templateVar colName colOrderStats #' #' @template matrixStatsLink #' #' @template standardParameters #' @param which An integer index in \[1,K\] (\[1,N\]) indicating which order #' statistic to be returned #' @template dimParameter #' @template useNamesParameter #' #' @template returnVector #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats]{rowOrderStats}()} and #' \code{matrixStats::\link[matrixStats:rowOrderStats]{colOrderStats}()} #' which are used when the input is a \code{matrix} or \code{numeric} vector. #' } #' #' @examples #' mat <- matrix(rnorm(15), nrow = 5, ncol = 3) #' mat[2, 1] <- 2 #' mat[3, 3] <- Inf #' mat[4, 1] <- 0 #' #' print(mat) #' #' rowOrderStats(mat, which = 1) #' colOrderStats(mat, which = 3) #' #' @keywords array iteration robust univar setGeneric("rowOrderStats", function(x, rows = NULL, cols = NULL, which, ..., useNames = TRUE) standardGeneric("rowOrderStats"), signature = "x" ) .matrixStats_rowOrderStats <- function(x, rows = NULL, cols = NULL, which, dim. = dim(x), ..., useNames = TRUE){ matrixStats::rowOrderStats(x, rows = rows, cols = cols, which = which, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowOrderStats setMethod("rowOrderStats", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowOrderStats) #' @export #' @rdname rowOrderStats ## Default method with user-friendly fallback mechanism. setMethod("rowOrderStats", "ANY", make_default_method_def("rowOrderStats")) #' @export #' @rdname rowOrderStats setGeneric("colOrderStats", function(x, rows = NULL, cols = NULL, which, ..., useNames = TRUE) standardGeneric("colOrderStats"), signature = "x" ) .matrixStats_colOrderStats <- function(x, rows = NULL, cols = NULL, which, dim. = dim(x), ..., useNames = TRUE){ matrixStats::colOrderStats(x, rows = rows, cols = cols, which = which, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowOrderStats setMethod("colOrderStats", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colOrderStats) #' @export #' @rdname rowOrderStats ## Default method with user-friendly fallback mechanism. setMethod("colOrderStats", "ANY", make_default_method_def("colOrderStats")) MatrixGenerics/R/rowProds.R0000644000175200017520000000466014710235307016673 0ustar00biocbuildbiocbuild#' Calculates the product for each row (column) of a matrix-like object #' #' Calculates the product for each row (column) of a matrix-like object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowProds #' #' @templateVar rowName rowProds #' @templateVar colName colProds #' #' @template matrixStatsLink #' #' @template standardParameters #' @template na_rmParameter #' @param method A character vector of length one that specifies the #' how the product is calculated. Note, that this is not a generic #' argument and not all implementation have to provide it. #' @template useNamesParameter #' #' @template returnVector #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats]{rowProds}()} and #' \code{matrixStats::\link[matrixStats:rowProds]{colProds}()} which are used #' when the input is a \code{matrix} or \code{numeric} vector. #' \item For sums across rows (columns), see #' \code{\link{rowSums2}()} ([colSums2()]) #' \item \code{base::\link{prod}()}. #' } #' #' @template standardExamples #' #' @keywords array iteration robust univar setGeneric("rowProds", function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("rowProds"), signature = "x" ) .matrixStats_rowProds <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, method = c("direct", "expSumLog"), ..., useNames = TRUE){ matrixStats::rowProds(x, rows = rows, cols = cols, na.rm = na.rm, method = method, ..., useNames = useNames) } #' @export #' @rdname rowProds setMethod("rowProds", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowProds) #' @export #' @rdname rowProds ## Default method with user-friendly fallback mechanism. setMethod("rowProds", "ANY", make_default_method_def("rowProds")) #' @export #' @rdname rowProds setGeneric("colProds", function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("colProds"), signature = "x" ) .matrixStats_colProds <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, method = c("direct", "expSumLog"), ..., useNames = TRUE){ matrixStats::colProds(x, rows = rows, cols = cols, na.rm = na.rm, method = method, ..., useNames = useNames) } #' @export #' @rdname rowProds setMethod("colProds", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colProds) #' @export #' @rdname rowProds ## Default method with user-friendly fallback mechanism. setMethod("colProds", "ANY", make_default_method_def("colProds")) MatrixGenerics/R/rowQuantiles.R0000644000175200017520000000571414710235307017552 0ustar00biocbuildbiocbuild#' Calculates quantiles for each row (column) of a matrix-like object #' #' Calculates quantiles for each row (column) of a matrix-like object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowQuantiles #' #' @templateVar rowName rowQuantiles #' @templateVar colName colQuantiles #' #' @template matrixStatsLink #' #' @template standardParameters #' @param probs A numeric vector of J probabilities in \[0, 1\]. #' @template na_rmParameter #' @param type An integer specifying the type of estimator. See #' \code{stats::\link[stats]{quantile}()} for more details. #' @param digits An integer specifying the precision of the formatted #' percentages. See \code{stats::\link[stats]{quantile}()} for more details. #' @param drop If `TRUE` a vector is returned if `J == 1`. #' @template useNamesParameter #' #' @template returnMatrix_JDim #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats]{rowQuantiles}()} and #' \code{matrixStats::\link[matrixStats:rowQuantiles]{colQuantiles}()} which #' are used when the input is a \code{matrix} or \code{numeric} vector. #' \item [stats::quantile] #' } #' #' @template standardExamples #' #' @keywords array iteration robust setGeneric("rowQuantiles", function(x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, digits = 7L, ..., useNames = TRUE, drop = TRUE) standardGeneric("rowQuantiles"), signature = "x" ) .matrixStats_rowQuantiles <- function(x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, digits = 7L, ..., useNames = TRUE, drop = TRUE) { matrixStats::rowQuantiles(x = x, rows = rows, cols = cols, probs = probs, na.rm = na.rm, type = type, digits = digits, ..., useNames = useNames, drop = drop) } #' @export #' @rdname rowQuantiles setMethod("rowQuantiles", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowQuantiles) #' @export #' @rdname rowQuantiles ## Default method with user-friendly fallback mechanism. setMethod("rowQuantiles", "ANY", make_default_method_def("rowQuantiles")) #' @export #' @rdname rowQuantiles setGeneric("colQuantiles", function(x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, digits = 7L, ..., useNames = TRUE, drop = TRUE) standardGeneric("colQuantiles"), signature = "x" ) .matrixStats_colQuantiles <- function(x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, digits = 7L, ..., useNames = TRUE, drop = TRUE) { matrixStats::colQuantiles(x = x, rows = rows, cols = cols, probs = probs, na.rm = na.rm, type = type, digits = digits, ..., useNames = useNames, drop = drop) } #' @export #' @rdname rowQuantiles setMethod("colQuantiles", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colQuantiles) #' @export #' @rdname rowQuantiles ## Default method with user-friendly fallback mechanism. setMethod("colQuantiles", "ANY", make_default_method_def("colQuantiles")) MatrixGenerics/R/rowRanges.R0000644000175200017520000000735514710235307017027 0ustar00biocbuildbiocbuild#' Calculates the minimum and maximum for each row (column) of a matrix-like #' object #' #' Calculates the minimum and maximum for each row (column) of a matrix-like #' object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowRanges #' #' @templateVar rowName rowRanges #' @templateVar colName colRanges #' #' @template matrixStatsLink #' #' @template standardParameters #' @template na_rmParameter #' @template dimParameter #' @template useNamesParameter #' #' @return a \code{\link{numeric}} \code{Nx2} (\code{Kx2}) #' \code{\link{matrix}}, where N (K) is the number of rows (columns) for #' which the ranges are calculated. #' #' @note Unfortunately for the argument list of the \code{rowRanges()} #' generic function we cannot follow the scheme used for the other #' row/column matrix summarization generic functions. This is because #' we need to be compatible with the historic \code{rowRanges()} getter #' for \link[SummarizedExperiment]{RangedSummarizedExperiment} objects. #' See \code{?SummarizedExperiment::\link[SummarizedExperiment]{rowRanges}}. #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats]{rowRanges}()} and #' \code{matrixStats::\link[matrixStats:rowRanges]{colRanges}()} which are #' used when the input is a \code{matrix} or \code{numeric} vector. #' \item For max estimates, see \code{\link{rowMaxs}()}. #' \item For min estimates, see \code{\link{rowMins}()}. #' \item \code{base::\link{range}()}. #' } #' #' @template standardExamples #' #' @keywords array iteration robust setGeneric("rowRanges", function(x, ...) standardGeneric("rowRanges")) .matrixStats_rowRanges <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE){ matrixStats::rowRanges(x, rows = rows, cols = cols, na.rm = na.rm, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowRanges setMethod("rowRanges", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowRanges) ## Note that because the rowRanges() accessor for SummarizedExperiment ## objects (and other objects in Bioconductor) is implemented as a method ## for the MatrixGenerics::rowRanges() generic, the user-friendly fallback ## mechanism for rowRanges() could produce an error message like: ## ## Error in MatrixGenerics:::.load_next_suggested_package_to_search(x) : ## Failed to find a rowRanges() method for objects. ## However, the following package is likely to contain the missing ## method but is not installed: sparseMatrixStats. ## Please install it (with 'BiocManager::install("sparseMatrixStats")') ## and try again. ## ## in the (admittedly rare) situations where the user tries to call the ## accessor on a SummarizedExperiment or RaggedExperiment object etc.. but ## doesn't have the SummarizedExperiment or RaggedExperiment package loaded. ## Not clear that this can even happen, but if it did, the error message ## would be quite misleading. #' @export #' @rdname rowRanges ## Default method with user-friendly fallback mechanism. setMethod("rowRanges", "ANY", make_default_method_def("rowRanges")) #' @export #' @rdname rowRanges setGeneric("colRanges", function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("colRanges"), signature = "x" ) .matrixStats_colRanges <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE){ matrixStats::colRanges(x, rows = rows, cols = cols, na.rm = na.rm, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowRanges setMethod("colRanges", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colRanges) #' @export #' @rdname rowRanges ## Default method with user-friendly fallback mechanism. setMethod("colRanges", "ANY", make_default_method_def("colRanges")) MatrixGenerics/R/rowRanks.R0000644000175200017520000000775714740010125016664 0ustar00biocbuildbiocbuild#' Calculates the rank of the elements for each row (column) of a matrix-like #' object #' #' Calculates the rank of the elements for each row (column) of a matrix-like #' object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowRanks #' #' @templateVar rowName rowRanks #' @templateVar colName colRanks #' #' @template matrixStatsLink #' #' @template standardParameters #' @param ties.method A character string specifying how ties are treated. Note #' that the default specifies fewer options than the original matrixStats #' package. #' @template dimParameter #' @param preserveShape If `TRUE` the output matrix has the same shape as the #' input x. Note, that this is not a generic argument and not all #' implementation of this function have to provide it. #' @template useNamesParameter #' #' @return A \code{\link[base]{matrix}} of type \code{\link[base]{integer}} is #' returned, unless \code{ties.method = "average"} when it is of type #' \code{\link[base]{numeric}}. #' #' The \code{rowRanks()} function always returns an NxK #' \code{\link[base]{matrix}}, where N (K) is the number of rows (columns) #' whose ranks are calculated. #' #' The \code{colRanks()} function returns an NxK \code{\link[base]{matrix}}, if #' \code{preserveShape = TRUE}, otherwise a KxN \code{\link[base]{matrix}}. #' #' Any \code{\link[base]{names}} of \code{x} are ignored and absent in the #' result. #' #' @details #' The `matrixStats::rowRanks()` function can handle a lot of different #' values for the `ties.method` argument. Users of the generic function #' should however only rely on `max` and `average` because the other ones #' are not guaranteed to be implemented: #' \describe{ #' \item{`max`}{for values with identical values the maximum rank is #' returned} #' \item{`average`}{for values with identical values the average of the #' ranks they cover is returned. Note, that in this case the return #' value is of type `numeric`.} #' } #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats]{rowRanks}()} and #' \code{matrixStats::\link[matrixStats:rowRanks]{colRanks}()} which are used #' when the input is a \code{matrix} or \code{numeric} vector. #' \item [base::rank] #' } #' #' @template standardExamples #' #' @keywords array iteration robust setGeneric("rowRanks", function(x, rows = NULL, cols = NULL, ties.method = c("max", "average"), ..., useNames = TRUE) standardGeneric("rowRanks"), signature = "x" ) .matrixStats_rowRanks <- function(x, rows = NULL, cols = NULL, ties.method = c("max", "average", "first", "last", "random", "max", "min", "dense"), dim. = dim(x), ..., useNames = TRUE){ matrixStats::rowRanks(x = x, rows = rows, cols = cols, ties.method = ties.method, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowRanks setMethod("rowRanks", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowRanks) #' @export #' @rdname rowRanks ## Default method with user-friendly fallback mechanism. setMethod("rowRanks", "ANY", make_default_method_def("rowRanks")) #' @export #' @rdname rowRanks setGeneric("colRanks", function(x, rows = NULL, cols = NULL, ties.method = c("max", "average"), ..., useNames = TRUE) standardGeneric("colRanks"), signature = "x" ) .matrixStats_colRanks <- function(x, rows = NULL, cols = NULL, ties.method = c("max", "average", "first", "last", "random", "max", "min", "dense"), dim. = dim(x), preserveShape = FALSE, ..., useNames = TRUE){ matrixStats::colRanks(x = x, rows = rows, cols = cols, ties.method = ties.method, dim. = dim., preserveShape = preserveShape, ..., useNames = useNames) } #' @export #' @rdname rowRanks setMethod("colRanks", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colRanks) #' @export #' @rdname rowRanks ## Default method with user-friendly fallback mechanism. setMethod("colRanks", "ANY", make_default_method_def("colRanks")) MatrixGenerics/R/rowSdDiffs.R0000644000175200017520000000460414710235307017124 0ustar00biocbuildbiocbuild#' Calculates the standard deviation of the difference between each element of #' a row (column) of a matrix-like object #' #' Calculates the standard deviation of the difference between each element of #' a row (column) of a matrix-like object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowSdDiffs #' #' @templateVar rowName rowSdDiffs #' @templateVar colName colSdDiffs #' #' @template matrixStatsLink #' #' @template standardParameters #' @template diff_trimParameters #' @template na_rmParameter #' @template useNamesParameter #' #' @template returnVector #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats:varDiff]{rowSdDiffs}()} and #' \code{matrixStats::\link[matrixStats:varDiff]{colSdDiffs}()} which are #' used when the input is a \code{matrix} or \code{numeric} vector. #' \item for the direct standard deviation see [rowSds()]. #' } #' #' @template standardExamples #' #' @keywords array iteration robust univar setGeneric("rowSdDiffs", function(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) standardGeneric("rowSdDiffs"), signature = "x" ) .matrixStats_rowSdDiffs <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE){ matrixStats::rowSdDiffs(x, rows = rows, cols = cols, na.rm = na.rm, diff = diff, trim = trim, ..., useNames = useNames) } #' @export #' @rdname rowSdDiffs setMethod("rowSdDiffs", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowSdDiffs) #' @export #' @rdname rowSdDiffs ## Default method with user-friendly fallback mechanism. setMethod("rowSdDiffs", "ANY", make_default_method_def("rowSdDiffs")) #' @export #' @rdname rowSdDiffs setGeneric("colSdDiffs", function(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) standardGeneric("colSdDiffs"), signature = "x" ) .matrixStats_colSdDiffs <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE){ matrixStats::colSdDiffs(x, rows = rows, cols = cols, na.rm = na.rm, diff = diff, trim = trim, ..., useNames = useNames) } #' @export #' @rdname rowSdDiffs setMethod("colSdDiffs", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colSdDiffs) #' @export #' @rdname rowSdDiffs ## Default method with user-friendly fallback mechanism. setMethod("colSdDiffs", "ANY", make_default_method_def("colSdDiffs")) MatrixGenerics/R/rowSds.R0000644000175200017520000000476214710235307016340 0ustar00biocbuildbiocbuild#' Calculates the standard deviation for each row (column) of a matrix-like #' object #' #' Calculates the standard deviation for each row (column) of a matrix-like #' object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowSds #' #' @templateVar rowName rowSds #' @templateVar colName colSds #' #' @template matrixStatsLink #' #' @template standardParameters #' @template na_rmParameter #' @param center (optional) the center, defaults to the row means #' @template dimParameter #' @template useNamesParameter #' #' @template returnVector #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats]{rowSds}()} and #' \code{matrixStats::\link[matrixStats:rowSds]{colSds}()} which are used when #' the input is a \code{matrix} or \code{numeric} vector. #' \item For mean estimates, see \code{\link{rowMeans2}()} and #' \code{\link[base:colSums]{rowMeans}()}. #' \item For variance estimates, see \code{\link{rowVars}()}. #' } #' #' @template standardExamples #' #' @keywords array iteration robust univar setGeneric("rowSds", function(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE) standardGeneric("rowSds"), signature = "x" ) .matrixStats_rowSds <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, dim. = dim(x), ..., useNames = TRUE){ center <- normarg_center(center, nrow(x), "nrow(x)") matrixStats::rowSds(x, rows = rows, cols = cols, na.rm = na.rm, center = center, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowSds setMethod("rowSds", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowSds) #' @export #' @rdname rowSds ## Default method with user-friendly fallback mechanism. setMethod("rowSds", "ANY", make_default_method_def("rowSds")) #' @export #' @rdname rowSds setGeneric("colSds", function(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE) standardGeneric("colSds"), signature = "x" ) .matrixStats_colSds <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, dim. = dim(x), ..., useNames = TRUE){ center <- normarg_center(center, ncol(x), "ncol(x)") matrixStats::colSds(x, rows = rows, cols = cols, na.rm = na.rm, center = center, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowSds setMethod("colSds", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colSds) #' @export #' @rdname rowSds ## Default method with user-friendly fallback mechanism. setMethod("colSds", "ANY", make_default_method_def("colSds")) MatrixGenerics/R/rowSums.R0000644000175200017520000001003214710235307016521 0ustar00biocbuildbiocbuild## IMPORTANT NOTE: We don't provide a user-friendly fallback mechanism for ## rowSums() and colSums(). Here is why: ## The method package defines **implicit generics** for the rowSums() ## and colSums() functions and this is what we get when we call ## setGeneric("rowSums") and setGeneric("colSums") below. These implicit ## generics introduce 2 surprises: ## 1. Their argument list (x, na.rm=FALSE, dims=1, ...) differs slightly from ## base::rowSums and base::colSums. This means that we need to be careful ## to use this same exact argument list in the rowSums() and colSums() ## methods that we define below. ## 2. They define their own default method that basically calls base::rowSums() ## or base::colSums(). Unfortunately, trying to override these default ## methods with our own doesn't work. Even if selectMethod("rowSums", "ANY") ## and selectMethod("colSums", "ANY") return our methods right after ## loading MatrixGenerics in a fresh R session, this is no longer the case ## if we then load the DelayedArray package. Then the default methods get ## replaced with the original default methods defined by the implicit ## generics. VERY NASTY! This is why our attempts at providing user-friendly ## fallback mechanisms for rowSums() and colSums() are commented out below. #' Calculates the sum for each row (column) of a matrix-like object #' #' Calculates the sum for each row (column) of a matrix-like object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowSums #' #' @templateVar rowName rowSums #' @templateVar colName colSums #' #' @param x An NxK matrix-like object, a numeric data frame, or an array-like #' object of two or more dimensions. #' @template na_rmParameter #' @param dims A single integer indicating which dimensions are regarded #' as rows or columns to sum over. For \code{rowSums}, the sum is over #' dimensions \code{dims+1, ...}; for \code{colSums} it is over #' dimensions \code{1:dims}. #' @param ... Additional arguments passed to specific methods. #' #' @details This man page documents the \code{rowSums} and \code{colSums} #' \emph{S4 generic functions} defined in the \pkg{MatrixGenerics} package. #' See \code{?base::\link[base]{colSums}} for the default methods (defined #' in the \pkg{base} package). # #' The S4 methods for \code{x} of type \code{\link{matrix}}, # #' \code{\link{array}}, \code{\link{table}}, \code{\link{numeric}}, or # #' \code{\link{data.frame}} call \code{base::\link[base]{rowSums}} / # #' \code{base::\link[base]{colSums}}. #' #' @template returnVector #' #' @seealso #' \itemize{ #' \item \code{base::\link[base]{colSums}} for the default #' \code{rowSums} and \code{colSums} methods. #' \item \code{Matrix::\link[Matrix]{colSums}} in the \pkg{Matrix} package #' for \code{rowSums} and \code{colSums} methods defined for #' CsparseMatrix derivatives (e.g. dgCMatrix objects). #' } #' #' @template standardExamples #' #' @keywords array algebra arith iteration robust univar setGeneric("rowSums") # .base_rowSums <- function(x, na.rm=FALSE, dims=1, ...) # { # base::rowSums(x, na.rm=na.rm, dims=dims, ...) # } # # #' @export # #' @rdname rowSums # setMethod("rowSums", "matrix_OR_array_OR_table_OR_numeric", .base_rowSums) # # #' @export # #' @rdname rowSums # setMethod("rowSums", "data.frame", .base_rowSums) # # #' @export # #' @rdname rowSums # ## Override default method of implicit generic with user-friendly fallback # ## mechanism. # setMethod("rowSums", "ANY", make_default_method_def("rowSums")) #' @export #' @rdname rowSums setGeneric("colSums") # .base_colSums <- function(x, na.rm=FALSE, dims=1, ...) # { # base::colSums(x, na.rm=na.rm, dims=dims, ...) # } # # #' @export # #' @rdname rowSums # setMethod("colSums", "matrix_OR_array_OR_table_OR_numeric", .base_colSums) # # #' @export # #' @rdname rowSums # setMethod("colSums", "data.frame", .base_colSums) # # #' @export # #' @rdname rowSums # ## Override default method of implicit generic with user-friendly fallback # ## mechanism. # setMethod("colSums", "ANY", make_default_method_def("colSums")) MatrixGenerics/R/rowSums2.R0000644000175200017520000000433414710235307016613 0ustar00biocbuildbiocbuild#' Calculates the sum for each row (column) of a matrix-like object #' #' Calculates the sum for each row (column) of a matrix-like object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowSums2 #' #' @templateVar rowName rowSums2 #' @templateVar colName colSums2 #' #' @template matrixStatsLink #' #' @template standardParameters #' @template na_rmParameter #' @template dimParameter #' @template useNamesParameter #' #' @template returnVector #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats]{rowSums2}()} and #' \code{matrixStats::\link[matrixStats:rowSums2]{colSums2}()} which are used #' when the input is a \code{matrix} or \code{numeric} vector. #' \item For mean estimates, see \code{\link{rowMeans2}()} and #' \code{\link[base:colSums]{rowMeans}()}. #' \item \code{base::\link{sum}()}. #' } #' #' @template standardExamples #' #' @keywords array iteration robust univar setGeneric("rowSums2", function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("rowSums2"), signature = "x" ) .matrixStats_rowSums2 <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE){ matrixStats::rowSums2(x, rows = rows, cols = cols, na.rm = na.rm, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowSums2 setMethod("rowSums2", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowSums2) #' @export #' @rdname rowSums2 ## Default method with user-friendly fallback mechanism. setMethod("rowSums2", "ANY", make_default_method_def("rowSums2")) #' @export #' @rdname rowSums2 setGeneric("colSums2", function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("colSums2"), signature = "x" ) .matrixStats_colSums2 <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE){ matrixStats::colSums2(x, rows = rows, cols = cols, na.rm = na.rm, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowSums2 setMethod("colSums2", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colSums2) #' @export #' @rdname rowSums2 ## Default method with user-friendly fallback mechanism. setMethod("colSums2", "ANY", make_default_method_def("colSums2")) MatrixGenerics/R/rowTabulates.R0000644000175200017520000000463514710235307017532 0ustar00biocbuildbiocbuild#' Tabulates the values in a matrix-like object by row (column) #' #' Tabulates the values in a matrix-like object by row (column). #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowTabulates #' #' @templateVar rowName rowTabulates #' @templateVar colName colTabulates #' #' @template matrixStatsLink #' #' @template standardParameters #' @param values the values to search for. #' @template useNamesParameter #' #' @template returnMatrix_JDim #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats]{rowTabulates}()} and #' \code{matrixStats::\link[matrixStats:rowTabulates]{colTabulates}()} which #' are used when the input is a \code{matrix} or \code{numeric} vector. #' \item \code{base::\link{table}()} #' } #' #' @examples #' mat <- matrix(rpois(15, lambda = 3), nrow = 5, ncol = 3) #' mat[2, 1] <- NA_integer_ #' mat[3, 3] <- 0L #' mat[4, 1] <- 0L #' #' print(mat) #' #' rowTabulates(mat) #' colTabulates(mat) #' #' rowTabulates(mat, values = 0) #' colTabulates(mat, values = 0) #' #' @keywords array iteration robust univar setGeneric("rowTabulates", function(x, rows = NULL, cols = NULL, values = NULL, ..., useNames = TRUE) standardGeneric("rowTabulates"), signature = "x" ) .matrixStats_rowTabulates <- function(x, rows = NULL, cols = NULL, values = NULL, ..., useNames = TRUE){ matrixStats::rowTabulates(x, rows = rows, cols = cols, values = values, ..., useNames = useNames) } #' @export #' @rdname rowTabulates setMethod("rowTabulates", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowTabulates) #' @export #' @rdname rowTabulates ## Default method with user-friendly fallback mechanism. setMethod("rowTabulates", "ANY", make_default_method_def("rowTabulates")) #' @export #' @rdname rowTabulates setGeneric("colTabulates", function(x, rows = NULL, cols = NULL, values = NULL, ..., useNames = TRUE) standardGeneric("colTabulates"), signature = "x" ) .matrixStats_colTabulates <- function(x, rows = NULL, cols = NULL, values = NULL, ..., useNames = TRUE){ matrixStats::colTabulates(x, rows = rows, cols = cols, values = values, ..., useNames = useNames) } #' @export #' @rdname rowTabulates setMethod("colTabulates", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colTabulates) #' @export #' @rdname rowTabulates ## Default method with user-friendly fallback mechanism. setMethod("colTabulates", "ANY", make_default_method_def("colTabulates")) MatrixGenerics/R/rowVarDiffs.R0000644000175200017520000000460014710235307017302 0ustar00biocbuildbiocbuild#' Calculates the variance of the difference between each element of a row #' (column) of a matrix-like object #' #' Calculates the variance of the difference between each element of a row #' (column) of a matrix-like object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowVarDiffs #' #' @templateVar rowName rowVarDiffs #' @templateVar colName colVarDiffs #' #' @template matrixStatsLink #' #' @template standardParameters #' @template diff_trimParameters #' @template na_rmParameter #' @template useNamesParameter #' #' @template returnVector #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats:varDiff]{rowVarDiffs}()} and #' \code{matrixStats::\link[matrixStats:varDiff]{colVarDiffs}()} which #' are used when the input is a \code{matrix} or \code{numeric} vector. #' \item for the direct variance see [rowVars()]. #' } #' #' @template standardExamples #' #' @keywords array iteration robust univar setGeneric("rowVarDiffs", function(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) standardGeneric("rowVarDiffs"), signature = "x" ) .matrixStats_rowVarDiffs <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE){ matrixStats::rowVarDiffs(x, rows = rows, cols = cols, na.rm = na.rm, diff = diff, trim = trim, ..., useNames = useNames) } #' @export #' @rdname rowVarDiffs setMethod("rowVarDiffs", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowVarDiffs) #' @export #' @rdname rowVarDiffs ## Default method with user-friendly fallback mechanism. setMethod("rowVarDiffs", "ANY", make_default_method_def("rowVarDiffs")) #' @export #' @rdname rowVarDiffs setGeneric("colVarDiffs", function(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) standardGeneric("colVarDiffs"), signature = "x" ) .matrixStats_colVarDiffs <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE){ matrixStats::colVarDiffs(x, rows = rows, cols = cols, na.rm = na.rm, diff = diff, trim = trim, ..., useNames = useNames) } #' @export #' @rdname rowVarDiffs setMethod("colVarDiffs", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colVarDiffs) #' @export #' @rdname rowVarDiffs ## Default method with user-friendly fallback mechanism. setMethod("colVarDiffs", "ANY", make_default_method_def("colVarDiffs")) MatrixGenerics/R/rowVars.R0000644000175200017520000000505514710235307016516 0ustar00biocbuildbiocbuild#' Calculates the variance for each row (column) of a matrix-like object #' #' Calculates the variance for each row (column) of a matrix-like object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowVars #' #' @templateVar rowName rowVars #' @templateVar colName colVars #' #' @template matrixStatsLink #' #' @template standardParameters #' @template na_rmParameter #' @param center (optional) the center, defaults to the row means. #' @template dimParameter #' @template useNamesParameter #' #' @template returnVector #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats]{rowVars}()} and #' \code{matrixStats::\link[matrixStats:rowVars]{colVars}()} which are used #' when the input is a \code{matrix} or \code{numeric} vector. #' \item For mean estimates, see \code{\link{rowMeans2}()} and #' \code{\link[base:colSums]{rowMeans}()}. #' \item For standard deviation estimates, see \code{\link{rowSds}()}. #' \item \code{stats::\link[stats:cor]{var}()}. #' } #' #' @template standardExamples #' #' @keywords array iteration robust univar setGeneric("rowVars", function(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE) standardGeneric("rowVars"), signature = "x" ) .matrixStats_rowVars <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, dim. = dim(x), ..., useNames = TRUE){ center <- normarg_center(center, nrow(x), "nrow(x)") matrixStats::rowVars(x, rows = rows, cols = cols, na.rm = na.rm, center = center, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowVars setMethod("rowVars", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowVars) #' @export #' @rdname rowVars ## Default method with user-friendly fallback mechanism. setMethod("rowVars", "ANY", make_default_method_def("rowVars")) #' @export #' @rdname rowVars setGeneric("colVars", function(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE) standardGeneric("colVars"), signature = "x" ) .matrixStats_colVars <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, dim. = dim(x), ..., useNames = TRUE){ center <- normarg_center(center, ncol(x), "ncol(x)") matrixStats::colVars(x, rows = rows, cols = cols, na.rm = na.rm, center = center, dim. = dim., ..., useNames = useNames) } #' @export #' @rdname rowVars setMethod("colVars", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colVars) #' @export #' @rdname rowVars ## Default method with user-friendly fallback mechanism. setMethod("colVars", "ANY", make_default_method_def("colVars")) MatrixGenerics/R/rowWeightedMads.R0000644000175200017520000000563214710235307020151 0ustar00biocbuildbiocbuild#' Calculates the weighted median absolute deviation for each row (column) of a #' matrix-like object #' #' Calculates the weighted median absolute deviation for each row (column) of #' a matrix-like object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowWeightedMads #' #' @templateVar rowName rowWeightedMads #' @templateVar colName colWeightedMads #' #' @template matrixStatsLink #' #' @template standardParameters #' @template weightParam #' @template na_rmParameter #' @template useNamesParameter #' @param center (optional) the center, defaults to the row means #' @param constant A scale factor. See \code{stats::\link[stats]{mad}()} for #' details. #' @template useNamesParameter #' #' @template returnVector #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats:weightedMad]{rowWeightedMads}()} and #' \code{matrixStats::\link[matrixStats:weightedMad]{colWeightedMads}()} #' which are used when the input is a \code{matrix} or \code{numeric} vector. #' \item See also [rowMads] for the corresponding unweighted function. #' } #' #' @template weightedExamples #' #' @keywords array iteration robust univar setGeneric("rowWeightedMads", function(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, ..., useNames = TRUE) standardGeneric("rowWeightedMads"), signature = "x" ) .matrixStats_rowWeightedMads <- function(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, ..., useNames = TRUE){ center <- normarg_center(center, nrow(x), "nrow(x)") matrixStats::rowWeightedMads(x, w = w, rows = rows, cols = cols, na.rm = na.rm, constant = constant, center = center, ..., useNames = useNames) } #' @export #' @rdname rowWeightedMads setMethod("rowWeightedMads", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowWeightedMads) #' @export #' @rdname rowWeightedMads ## Default method with user-friendly fallback mechanism. setMethod("rowWeightedMads", "ANY", make_default_method_def("rowWeightedMads")) #' @export #' @rdname rowWeightedMads setGeneric("colWeightedMads", function(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, ..., useNames = TRUE) standardGeneric("colWeightedMads"), signature = "x" ) .matrixStats_colWeightedMads <- function(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, ..., useNames = TRUE){ center <- normarg_center(center, ncol(x), "ncol(x)") matrixStats::colWeightedMads(x, w = w, rows = rows, cols = cols, na.rm = na.rm, constant = constant, center = center, ..., useNames = useNames) } #' @export #' @rdname rowWeightedMads setMethod("colWeightedMads", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colWeightedMads) #' @export #' @rdname rowWeightedMads ## Default method with user-friendly fallback mechanism. setMethod("colWeightedMads", "ANY", make_default_method_def("colWeightedMads")) MatrixGenerics/R/rowWeightedMeans.R0000644000175200017520000000460214710235307020324 0ustar00biocbuildbiocbuild#' Calculates the weighted mean for each row (column) of a matrix-like object #' #' Calculates the weighted mean for each row (column) of a matrix-like object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowWeightedMeans #' #' @templateVar rowName rowWeightedMeans #' @templateVar colName colWeightedMeans #' #' @template matrixStatsLink #' #' @template standardParameters #' @template weightParam #' @template na_rmParameter #' @template useNamesParameter #' #' @template returnVector #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats]{rowWeightedMeans}()} and #' \code{matrixStats::\link[matrixStats:rowWeightedMeans]{colWeightedMeans}()} #' which are used when the input is a \code{matrix} or \code{numeric} vector. #' \item See also [rowMeans2] for the corresponding unweighted function. #' } #' #' @template weightedExamples #' #' #' @keywords array iteration robust univar setGeneric("rowWeightedMeans", function(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("rowWeightedMeans"), signature = "x" ) .matrixStats_rowWeightedMeans <- function(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE){ matrixStats::rowWeightedMeans(x, w = w, rows = rows, cols = cols, na.rm = na.rm, ..., useNames = useNames) } #' @export #' @rdname rowWeightedMeans setMethod("rowWeightedMeans", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowWeightedMeans) #' @export #' @rdname rowWeightedMeans ## Default method with user-friendly fallback mechanism. setMethod("rowWeightedMeans", "ANY", make_default_method_def("rowWeightedMeans")) #' @export #' @rdname rowWeightedMeans setGeneric("colWeightedMeans", function(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("colWeightedMeans"), signature = "x" ) .matrixStats_colWeightedMeans <- function(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE){ matrixStats::colWeightedMeans(x, w = w, rows = rows, cols = cols, na.rm = na.rm, ..., useNames = useNames) } #' @export #' @rdname rowWeightedMeans setMethod("colWeightedMeans", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colWeightedMeans) #' @export #' @rdname rowWeightedMeans ## Default method with user-friendly fallback mechanism. setMethod("colWeightedMeans", "ANY", make_default_method_def("colWeightedMeans")) MatrixGenerics/R/rowWeightedMedians.R0000644000175200017520000000467414710235307020652 0ustar00biocbuildbiocbuild#' Calculates the weighted median for each row (column) of a matrix-like object #' #' Calculates the weighted median for each row (column) of a matrix-like object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowWeightedMedians #' #' @templateVar rowName rowWeightedMedians #' @templateVar colName colWeightedMedians #' #' @template matrixStatsLink #' #' @template standardParameters #' @template weightParam #' @template na_rmParameter #' @template useNamesParameter #' #' #' @template returnVector #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats]{rowWeightedMedians}()} and #' \code{matrixStats::\link[matrixStats:rowWeightedMedians]{colWeightedMedians}()} #' which are used when the input is a \code{matrix} or \code{numeric} vector. #' \item See also [rowMedians] for the corresponding unweighted function. #' } #' #' @template weightedExamples #' #' @keywords array iteration robust univar setGeneric("rowWeightedMedians", function(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("rowWeightedMedians"), signature = "x" ) .matrixStats_rowWeightedMedians <- function(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE){ matrixStats::rowWeightedMedians(x, w = w, rows = rows, cols = cols, na.rm = na.rm, ..., useNames = useNames) } #' @export #' @rdname rowWeightedMedians setMethod("rowWeightedMedians", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowWeightedMedians) #' @export #' @rdname rowWeightedMedians ## Default method with user-friendly fallback mechanism. setMethod("rowWeightedMedians", "ANY", make_default_method_def("rowWeightedMedians")) #' @export #' @rdname rowWeightedMedians setGeneric("colWeightedMedians", function(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("colWeightedMedians"), signature = "x" ) .matrixStats_colWeightedMedians <- function(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE){ matrixStats::colWeightedMedians(x, w = w, rows = rows, cols = cols, na.rm = na.rm, ..., useNames = useNames) } #' @export #' @rdname rowWeightedMedians setMethod("colWeightedMedians", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colWeightedMedians) #' @export #' @rdname rowWeightedMedians ## Default method with user-friendly fallback mechanism. setMethod("colWeightedMedians", "ANY", make_default_method_def("colWeightedMedians")) MatrixGenerics/R/rowWeightedSds.R0000644000175200017520000000456014710235307020015 0ustar00biocbuildbiocbuild#' Calculates the weighted standard deviation for each row (column) of a #' matrix-like object #' #' Calculates the weighted standard deviation for each row (column) of a #' matrix-like object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowWeightedSds #' #' @templateVar rowName rowWeightedSds #' @templateVar colName colWeightedSds #' #' @template matrixStatsLink #' #' @template standardParameters #' @template weightParam #' @template na_rmParameter #' @template useNamesParameter #' #' @template returnVector #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats:weightedVar]{rowWeightedSds}()} and #' \code{matrixStats::\link[matrixStats:weightedVar]{colWeightedSds}()} #' which are used when the input is a \code{matrix} or \code{numeric} vector. #' \item See also [rowSds] for the corresponding unweighted function. #' } #' #' @template weightedExamples #' #' @keywords array iteration robust univar setGeneric("rowWeightedSds", function(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("rowWeightedSds"), signature = "x" ) .matrixStats_rowWeightedSds <- function(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE){ matrixStats::rowWeightedSds(x, w = w, rows = rows, cols = cols, na.rm = na.rm, ..., useNames = useNames) } #' @export #' @rdname rowWeightedSds setMethod("rowWeightedSds", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowWeightedSds) #' @export #' @rdname rowWeightedSds ## Default method with user-friendly fallback mechanism. setMethod("rowWeightedSds", "ANY", make_default_method_def("rowWeightedSds")) #' @export #' @rdname rowWeightedSds setGeneric("colWeightedSds", function(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("colWeightedSds"), signature = "x" ) .matrixStats_colWeightedSds <- function(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE){ matrixStats::colWeightedSds(x, w = w, rows = rows, cols = cols, na.rm = na.rm, ..., useNames = useNames) } #' @export #' @rdname rowWeightedSds setMethod("colWeightedSds", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colWeightedSds) #' @export #' @rdname rowWeightedSds ## Default method with user-friendly fallback mechanism. setMethod("colWeightedSds", "ANY", make_default_method_def("colWeightedSds")) MatrixGenerics/R/rowWeightedVars.R0000644000175200017520000000456714710235307020206 0ustar00biocbuildbiocbuild#' Calculates the weighted variance for each row (column) of a matrix-like #' object #' #' Calculates the weighted variance for each row (column) of a matrix-like #' object. #' #' @include MatrixGenerics-package.R #' #' @export #' @name rowWeightedVars #' #' @templateVar rowName rowWeightedVars #' @templateVar colName colWeightedVars #' #' @template matrixStatsLink #' #' @template standardParameters #' @template weightParam #' @template na_rmParameter #' @template useNamesParameter #' #' @template returnVector #' #' @seealso #' \itemize{ #' \item \code{matrixStats::\link[matrixStats:weightedVar]{rowWeightedVars}()} and #' \code{matrixStats::\link[matrixStats:weightedVar]{colWeightedVars}()} #' which are used when the input is a \code{matrix} or \code{numeric} vector. #' \item See also [rowVars] for the corresponding unweighted function. #' } #' #' @template weightedExamples #' #' @keywords array iteration robust univar setGeneric("rowWeightedVars", function(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("rowWeightedVars"), signature = "x" ) .matrixStats_rowWeightedVars <- function(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE){ matrixStats::rowWeightedVars(x, w = w, rows = rows, cols = cols, na.rm = na.rm, ..., useNames = useNames) } #' @export #' @rdname rowWeightedVars setMethod("rowWeightedVars", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_rowWeightedVars) #' @export #' @rdname rowWeightedVars ## Default method with user-friendly fallback mechanism. setMethod("rowWeightedVars", "ANY", make_default_method_def("rowWeightedVars")) #' @export #' @rdname rowWeightedVars setGeneric("colWeightedVars", function(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) standardGeneric("colWeightedVars"), signature = "x" ) .matrixStats_colWeightedVars <- function(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE){ matrixStats::colWeightedVars(x, w = w, rows = rows, cols = cols, na.rm = na.rm, ..., useNames = useNames) } #' @export #' @rdname rowWeightedVars setMethod("colWeightedVars", "matrix_OR_array_OR_table_OR_numeric", .matrixStats_colWeightedVars) #' @export #' @rdname rowWeightedVars ## Default method with user-friendly fallback mechanism. setMethod("colWeightedVars", "ANY", make_default_method_def("colWeightedVars")) MatrixGenerics/README.md0000644000175200017520000000403214710235307016000 0ustar00biocbuildbiocbuild[](https://bioconductor.org/) **MatrixGenerics** is an R/Bioconductor package that provides the S4 generics for popular row and column aggregation functions for matrices (e.g. `colVars()`, `rowMedians()`). It follows the API developed by the [**matrixStats**](https://cran.r-project.org/package=matrixStats) package. The target audience for **MatrixGenerics** are R package developers that want to write code that can automatically handle different kind of matrix implementations: for example base R `matrix`, the S4 `Matrix` (including sparse representations), and `DelayedMatrix` objects. A prerequisite to handle these matrix objects is that a package with the corresponding implementation is available. So far, there are six packages: * [**matrixStats**](https://cran.r-project.org/package=matrixStats) for base R `matrix` objects * [**Matrix**](https://cran.r-project.org/package=Matrix) and [**sparseMatrixStats**](https://github.com/const-ae/sparseMatrixStats) for `dgCMatrix` (sparse matrix) objects from the **Matrix** package * [**SparseArray**](https://bioconductor.org/packages/SparseArray) for `SVT_SparseMatrix` objects from the same package * [**DelayedArray**](https://bioconductor.org/packages/DelayedArray) and [**DelayedMatrixStats**](https://bioconductor.org/packages/DelayedMatrixStats) for `DelayedMatrix` objects from the **DelayedArray** package. This package imports **matrixStats** and automatically forwards all function calls on `matrix`, `array`, or `numeric` objects to **matrixStats**. To handle other matrix-like objects, the user must manually install the package that implements row and column aggregation methods for those objects (e.g. the **sparseMatrixStats**, **SparseArray**, **DelayedArray**, or **DelayedMatrixStats** package). See https://bioconductor.org/packages/MatrixGenerics for more information including how to install the release version of the package (please refrain from installing directly from GitHub). MatrixGenerics/inst/0000755000175200017520000000000014710235307015477 5ustar00biocbuildbiocbuildMatrixGenerics/inst/NEWS.Rd0000644000175200017520000000517214710235307016547 0ustar00biocbuildbiocbuild\name{NEWS} \title{News for Package \pkg{MatrixGenerics}} \encoding{UTF-8} \section{Version 1.13.1}{\itemize{ \item Apply matrixStats 1.0.0 breaking change for \code{useNames}'s default: All generic functions and methods defined in \pkg{MatrixGenerics} now set the \code{useNames} argument to \code{TRUE} instead of \code{NA} by default. See https://github.com/Bioconductor/MatrixGenerics/issues/31 for a discussion of this change. }} \section{Version 1.11.3}{\itemize{ \item Add \pkg{SparseArray} to Suggests. }} \section{Version 1.11.1}{\itemize{ \item Move \code{row/colSums()} and \code{row/colMeans()} generics from \pkg{BiocGenerics}. }} \section{Version 1.9.1}{\itemize{ \item Fix for functions whose first argument is not \code{x} (\url{https://github.com/Bioconductor/MatrixGenerics/issues/28} and \url{https://github.com/Bioconductor/MatrixGenerics/pull/29}). }} \section{Version 1.5.4}{\itemize{ \item Sync API with \pkg{matrixStats} \code{v0.60.1}. }} \section{Version 1.5.2}{\itemize{ \item Sync API with \pkg{matrixStats} \code{v0.60.0}. }} \section{Version 1.5.1}{\itemize{ \item Fix problem with function environment of fallback mechanism (\url{https://github.com/Bioconductor/MatrixGenerics/issues/25} and \url{https://github.com/Bioconductor/MatrixGenerics/pull/26}). Make sure that packages can use \pkg{MatrixGenerics} with the \code{::} notation to call functions from \pkg{sparseMatrixStats} and \pkg{DelayedMatrixStats}. }} \section{Version 1.2.1}{\itemize{ \item Sync API with \pkg{matrixStats} \code{v0.58.0}. }} \section{Version 1.2.0}{\itemize{ \item Add \code{drop} and \code{type} to generic signature of \code{[row|col]Quantiles} (\url{https://github.com/Bioconductor/MatrixGenerics/pull/14}). \item Sync API with \pkg{matrixStats} \code{v0.57.0} (\url{https://github.com/Bioconductor/MatrixGenerics/issues/17}). \item Add default methods with user-friendly fallback mechanism (\url{https://github.com/Bioconductor/MatrixGenerics/pull/16}). Suggested packages are now loaded the first time a \pkg{MatrixGenerics}' generic is called (e.g. the first time \code{MatrixGenerics::colVars()} is called). With this new approach, if the user passes a \emph{dgCMatrix} object and if \pkg{sparseMatrixStats} is already loaded, will 'just work' and the fallback mechanism won't try to load anything. \item Dispatch on methods for matrix objects when table objects are supplied (\url{https://github.com/Bioconductor/MatrixGenerics/pull/15}) }} \section{Version 1.0.0}{\itemize{ \item New package \pkg{MatrixGenerics}, providing S4 generic functions modeled after the 'matrixStats' API for alternative matrix implementations. }} MatrixGenerics/man/0000755000175200017520000000000014740010125015265 5ustar00biocbuildbiocbuildMatrixGenerics/man/MatrixGenerics-package.Rd0000644000175200017520000000075414710235307022107 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/MatrixGenerics-package.R \docType{class} \name{MatrixGenerics-package} \alias{MatrixGenerics-package} \alias{class:matrix_OR_array_OR_table_OR_numeric} \alias{matrix_OR_array_OR_table_OR_numeric-class} \alias{matrix_OR_array_OR_table_OR_numeric} \title{The MatrixGenerics package} \description{ The \pkg{MatrixGenerics} package defines S4 generic summary statistic functions that operate on matrix-Like objects. } MatrixGenerics/man/internal-helpers.Rd0000644000175200017520000000047314710235307021044 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/MatrixGenerics-package.R \name{internal-helpers} \alias{internal-helpers} \alias{normarg_center} \title{Internal helpers} \usage{ normarg_center(center, n, what) } \description{ Not for end users } \keyword{internal} \keyword{utilities} MatrixGenerics/man/rowAlls.Rd0000644000175200017520000000546614710235307017222 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowAlls.R \name{rowAlls} \alias{rowAlls} \alias{rowAlls,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowAlls,ANY-method} \alias{colAlls} \alias{colAlls,matrix_OR_array_OR_table_OR_numeric-method} \alias{colAlls,ANY-method} \title{Check if all elements in a row (column) of a matrix-like object are equal to a value} \usage{ rowAlls(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) \S4method{rowAlls}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) \S4method{rowAlls}{ANY}(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) colAlls(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) \S4method{colAlls}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) \S4method{colAlls}{ANY}(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{value}{The value to search for.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} \item{dim.}{An \code{\link{integer}} \code{\link{vector}} of length two specifying the dimension of \code{x}, essential when x is a \code{\link{numeric}} vector. Note, that this is not a generic argument and not all methods need provide it.} } \value{ Returns a \code{\link{logical}} \code{\link{vector}} of length N (K). } \description{ Check if all elements in a row (column) of a matrix-like object are equal to a value. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowAlls}} / \code{matrixStats::\link[matrixStats]{colAlls}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowAlls(mat) colAlls(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats:rowAlls]{rowAlls}()} and \code{matrixStats::\link[matrixStats:rowAlls]{colAlls}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item For checks if \emph{any} element is equal to a value, see \code{\link{rowAnys}()}. \item \code{base::\link{all}()}. } } MatrixGenerics/man/rowAnyNAs.Rd0000644000175200017520000000435014710235307017447 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowAnyNAs.R \name{rowAnyNAs} \alias{rowAnyNAs} \alias{rowAnyNAs,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowAnyNAs,ANY-method} \alias{colAnyNAs} \alias{colAnyNAs,matrix_OR_array_OR_table_OR_numeric-method} \alias{colAnyNAs,ANY-method} \title{Check if any elements in a row (column) of a matrix-like object is missing} \usage{ rowAnyNAs(x, rows = NULL, cols = NULL, ..., useNames = TRUE) \S4method{rowAnyNAs}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, ..., useNames = TRUE) \S4method{rowAnyNAs}{ANY}(x, rows = NULL, cols = NULL, ..., useNames = TRUE) colAnyNAs(x, rows = NULL, cols = NULL, ..., useNames = TRUE) \S4method{colAnyNAs}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, ..., useNames = TRUE) \S4method{colAnyNAs}{ANY}(x, rows = NULL, cols = NULL, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} } \value{ Returns a \code{\link{logical}} \code{\link{vector}} of length N (K). } \description{ Check if any elements in a row (column) of a matrix-like object is missing. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowAnyNAs}} / \code{matrixStats::\link[matrixStats]{colAnyNAs}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowAnyNAs(mat) colAnyNAs(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats:anyMissing]{rowAnyNAs}()} and \code{matrixStats::\link[matrixStats:anyMissing]{colAnyNAs}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item For checks if any element is equal to a value, see \code{\link{rowAnys}()}. \item \code{base::\link{is.na}()} and \code{base::\link{any}()}. } } MatrixGenerics/man/rowAnys.Rd0000644000175200017520000000546614710235307017241 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowAnys.R \name{rowAnys} \alias{rowAnys} \alias{rowAnys,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowAnys,ANY-method} \alias{colAnys} \alias{colAnys,matrix_OR_array_OR_table_OR_numeric-method} \alias{colAnys,ANY-method} \title{Check if any elements in a row (column) of a matrix-like object is equal to a value} \usage{ rowAnys(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) \S4method{rowAnys}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) \S4method{rowAnys}{ANY}(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) colAnys(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) \S4method{colAnys}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) \S4method{colAnys}{ANY}(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{value}{The value to search for.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} \item{dim.}{An \code{\link{integer}} \code{\link{vector}} of length two specifying the dimension of \code{x}, essential when x is a \code{\link{numeric}} vector. Note, that this is not a generic argument and not all methods need provide it.} } \value{ Returns a \code{\link{logical}} \code{\link{vector}} of length N (K). } \description{ Check if any elements in a row (column) of a matrix-like object is equal to a value. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowAnys}} / \code{matrixStats::\link[matrixStats]{colAnys}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowAnys(mat) colAnys(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats:rowAlls]{rowAnys}()} and \code{matrixStats::\link[matrixStats:rowAlls]{colAnys}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item For checks if \emph{all} elements are equal to a value, see \code{\link{rowAlls}()}. \item \code{base::\link{any}()}. } } MatrixGenerics/man/rowAvgsPerColSet.Rd0000644000175200017520000000623314710235307021001 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowAvgsPerColSet.R \name{rowAvgsPerColSet} \alias{rowAvgsPerColSet} \alias{rowAvgsPerColSet,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowAvgsPerColSet,ANY-method} \alias{colAvgsPerRowSet} \alias{colAvgsPerRowSet,matrix_OR_array_OR_table_OR_numeric-method} \alias{colAvgsPerRowSet,ANY-method} \title{Calculates for each row (column) a summary statistic for equally sized subsets of columns (rows)} \usage{ rowAvgsPerColSet(X, W = NULL, rows = NULL, S, FUN = rowMeans, ..., na.rm = NA, tFUN = FALSE) \S4method{rowAvgsPerColSet}{matrix_OR_array_OR_table_OR_numeric}(X, W = NULL, rows = NULL, S, FUN = rowMeans, ..., na.rm = NA, tFUN = FALSE) \S4method{rowAvgsPerColSet}{ANY}(X, W = NULL, rows = NULL, S, FUN = rowMeans, ..., na.rm = NA, tFUN = FALSE) colAvgsPerRowSet(X, W = NULL, cols = NULL, S, FUN = colMeans, ..., na.rm = NA, tFUN = FALSE) \S4method{colAvgsPerRowSet}{matrix_OR_array_OR_table_OR_numeric}(X, W = NULL, cols = NULL, S, FUN = colMeans, ..., na.rm = NA, tFUN = FALSE) \S4method{colAvgsPerRowSet}{ANY}(X, W = NULL, cols = NULL, S, FUN = colMeans, ..., na.rm = NA, tFUN = FALSE) } \arguments{ \item{X}{An \code{NxM} matrix-like object.} \item{W}{An optional numeric \code{NxM} matrix of weights.} \item{rows, cols}{A \code{\link{vector}} indicating the subset (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{S}{An \link{integer} \code{KxJ} matrix that specifying the \code{J} subsets. Each column hold \code{K} column (row) indices for the corresponding subset. The range of values is [1, M] ([1,N]).} \item{FUN}{A row-by-row (column-by-column) summary statistic function. It is applied to to each column (row) subset of \code{X} that is specified by \code{S}.} \item{...}{Additional arguments passed to \code{FUN}.} \item{na.rm}{(logical) Argument passed to \code{FUN()} as \code{na.rm = na.rm}. If \code{NA} (default), then \code{na.rm = TRUE} is used if \code{X} or \code{S} holds missing values, otherwise \code{na.rm = FALSE}.} \item{tFUN}{If \code{TRUE}, \code{X} is transposed before it is passed to \code{FUN}.} } \value{ Returns a numeric \code{JxN} (\code{MxJ}) matrix. } \description{ Calculates for each row (column) a summary statistic for equally sized subsets of columns (rows). } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowAvgsPerColSet}} / \code{matrixStats::\link[matrixStats]{colAvgsPerRowSet}}. } \examples{ mat <- matrix(rnorm(20), nrow = 5, ncol = 4) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) S <- matrix(1:ncol(mat), ncol = 2) print(S) rowAvgsPerColSet(mat, S = S, FUN = rowMeans) rowAvgsPerColSet(mat, S = S, FUN = rowVars) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats:rowAvgsPerColSet]{rowAvgsPerColSet}()} and \code{matrixStats::\link[matrixStats:rowAvgsPerColSet]{colAvgsPerRowSet}()} which are used when the input is a \code{matrix} or \code{numeric} vector. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar2} MatrixGenerics/man/rowCollapse.Rd0000644000175200017520000000513514710235307020062 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowCollapse.R \name{rowCollapse} \alias{rowCollapse} \alias{rowCollapse,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowCollapse,ANY-method} \alias{colCollapse} \alias{colCollapse,matrix_OR_array_OR_table_OR_numeric-method} \alias{colCollapse,ANY-method} \title{Extract one cell from each row (column) of a matrix-like object} \usage{ rowCollapse(x, idxs, rows = NULL, ..., useNames = TRUE) \S4method{rowCollapse}{matrix_OR_array_OR_table_OR_numeric}(x, idxs, rows = NULL, dim. = dim(x), ..., useNames = TRUE) \S4method{rowCollapse}{ANY}(x, idxs, rows = NULL, ..., useNames = TRUE) colCollapse(x, idxs, cols = NULL, ..., useNames = TRUE) \S4method{colCollapse}{matrix_OR_array_OR_table_OR_numeric}(x, idxs, cols = NULL, dim. = dim(x), ..., useNames = TRUE) \S4method{colCollapse}{ANY}(x, idxs, cols = NULL, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{idxs}{An index \code{\link{vector}} with the position to extract. It is recycled to match the number of rows (column)} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} \item{dim.}{An \code{\link{integer}} \code{\link{vector}} of length two specifying the dimension of \code{x}, essential when x is a \code{\link{numeric}} vector. Note, that this is not a generic argument and not all methods need provide it.} } \value{ Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K). } \description{ Extract one cell from each row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowCollapse}} / \code{matrixStats::\link[matrixStats]{colCollapse}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowCollapse(mat, idxs = 2) rowCollapse(mat, idxs = c(1,1,2,3,2)) colCollapse (mat, idxs = 4) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats:rowCollapse]{rowCollapse}()} and \code{matrixStats::\link[matrixStats:rowCollapse]{colCollapse}()} which are used when the input is a \code{matrix} or \code{numeric} vector. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowCounts.Rd0000644000175200017520000000570114710235307017572 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowCounts.R \name{rowCounts} \alias{rowCounts} \alias{rowCounts,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowCounts,ANY-method} \alias{colCounts} \alias{colCounts,matrix_OR_array_OR_table_OR_numeric-method} \alias{colCounts,ANY-method} \title{Count how often an element in a row (column) of a matrix-like object is equal to a value} \usage{ rowCounts(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) \S4method{rowCounts}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) \S4method{rowCounts}{ANY}(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) colCounts(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) \S4method{colCounts}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) \S4method{colCounts}{ANY}(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{value}{The value to search for.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} \item{dim.}{An \code{\link{integer}} \code{\link{vector}} of length two specifying the dimension of \code{x}, essential when x is a \code{\link{numeric}} vector. Note, that this is not a generic argument and not all methods need provide it.} } \value{ Returns a \code{\link{integer}} \code{\link{vector}} of length N (K). } \description{ Count how often an element in a row (column) of a matrix-like object is equal to a value. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowCounts}} / \code{matrixStats::\link[matrixStats]{colCounts}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowCounts(mat) colCounts(mat) rowCounts(mat, value = 0) colCounts(mat, value = Inf, na.rm = TRUE) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats]{rowCounts}()} and \code{matrixStats::\link[matrixStats:rowCounts]{colCounts}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item For checks if any element is equal to a value, see \code{\link{rowAnys}()}. To check if all elements are equal, see \code{\link{rowAlls}()}. } } MatrixGenerics/man/rowCummaxs.Rd0000644000175200017520000000510114710235307017726 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowCummaxs.R \name{rowCummaxs} \alias{rowCummaxs} \alias{rowCummaxs,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowCummaxs,ANY-method} \alias{colCummaxs} \alias{colCummaxs,matrix_OR_array_OR_table_OR_numeric-method} \alias{colCummaxs,ANY-method} \title{Calculates the cumulative maxima for each row (column) of a matrix-like object} \usage{ rowCummaxs(x, rows = NULL, cols = NULL, ..., useNames = TRUE) \S4method{rowCummaxs}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE) \S4method{rowCummaxs}{ANY}(x, rows = NULL, cols = NULL, ..., useNames = TRUE) colCummaxs(x, rows = NULL, cols = NULL, ..., useNames = TRUE) \S4method{colCummaxs}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE) \S4method{colCummaxs}{ANY}(x, rows = NULL, cols = NULL, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} \item{dim.}{An \code{\link{integer}} \code{\link{vector}} of length two specifying the dimension of \code{x}, essential when x is a \code{\link{numeric}} vector. Note, that this is not a generic argument and not all methods need provide it.} } \value{ Returns a \code{\link{numeric}} \code{\link{matrix}}with the same dimensions as \code{x}. } \description{ Calculates the cumulative maxima for each row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowCummaxs}} / \code{matrixStats::\link[matrixStats]{colCummaxs}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowCummaxs(mat) colCummaxs(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats:rowCumsums]{rowCummaxs}()} and \code{matrixStats::\link[matrixStats:rowCumsums]{colCummaxs}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item For single maximum estimates, see \code{\link{rowMaxs}()}. \item \code{base::\link{cummax}()}. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowCummins.Rd0000644000175200017520000000510114710235307017724 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowCummins.R \name{rowCummins} \alias{rowCummins} \alias{rowCummins,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowCummins,ANY-method} \alias{colCummins} \alias{colCummins,matrix_OR_array_OR_table_OR_numeric-method} \alias{colCummins,ANY-method} \title{Calculates the cumulative minima for each row (column) of a matrix-like object} \usage{ rowCummins(x, rows = NULL, cols = NULL, ..., useNames = TRUE) \S4method{rowCummins}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE) \S4method{rowCummins}{ANY}(x, rows = NULL, cols = NULL, ..., useNames = TRUE) colCummins(x, rows = NULL, cols = NULL, ..., useNames = TRUE) \S4method{colCummins}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE) \S4method{colCummins}{ANY}(x, rows = NULL, cols = NULL, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} \item{dim.}{An \code{\link{integer}} \code{\link{vector}} of length two specifying the dimension of \code{x}, essential when x is a \code{\link{numeric}} vector. Note, that this is not a generic argument and not all methods need provide it.} } \value{ Returns a \code{\link{numeric}} \code{\link{matrix}}with the same dimensions as \code{x}. } \description{ Calculates the cumulative minima for each row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowCummins}} / \code{matrixStats::\link[matrixStats]{colCummins}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowCummins(mat) colCummins(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats:rowCumsums]{rowCummins}()} and \code{matrixStats::\link[matrixStats:rowCumsums]{colCummins}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item For single minimum estimates, see \code{\link{rowMins}()}. \item \code{base::\link{cummin}()}. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowCumprods.Rd0000644000175200017520000000502714710235307020114 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowCumprods.R \name{rowCumprods} \alias{rowCumprods} \alias{rowCumprods,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowCumprods,ANY-method} \alias{colCumprods} \alias{colCumprods,matrix_OR_array_OR_table_OR_numeric-method} \alias{colCumprods,ANY-method} \title{Calculates the cumulative product for each row (column) of a matrix-like object} \usage{ rowCumprods(x, rows = NULL, cols = NULL, ..., useNames = TRUE) \S4method{rowCumprods}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE) \S4method{rowCumprods}{ANY}(x, rows = NULL, cols = NULL, ..., useNames = TRUE) colCumprods(x, rows = NULL, cols = NULL, ..., useNames = TRUE) \S4method{colCumprods}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE) \S4method{colCumprods}{ANY}(x, rows = NULL, cols = NULL, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} \item{dim.}{An \code{\link{integer}} \code{\link{vector}} of length two specifying the dimension of \code{x}, essential when x is a \code{\link{numeric}} vector. Note, that this is not a generic argument and not all methods need provide it.} } \value{ Returns a \code{\link{numeric}} \code{\link{matrix}}with the same dimensions as \code{x}. } \description{ Calculates the cumulative product for each row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowCumprods}} / \code{matrixStats::\link[matrixStats]{colCumprods}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowCumprods(mat) colCumprods(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats:rowCumsums]{rowCumprods}()} and \code{matrixStats::\link[matrixStats:rowCumsums]{colCumprods}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item \code{base::\link{cumprod}()}. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowCumsums.Rd0000644000175200017520000000475714710235307017765 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowCumsums.R \name{rowCumsums} \alias{rowCumsums} \alias{rowCumsums,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowCumsums,ANY-method} \alias{colCumsums} \alias{colCumsums,matrix_OR_array_OR_table_OR_numeric-method} \alias{colCumsums,ANY-method} \title{Calculates the cumulative sum for each row (column) of a matrix-like object} \usage{ rowCumsums(x, rows = NULL, cols = NULL, ..., useNames = TRUE) \S4method{rowCumsums}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE) \S4method{rowCumsums}{ANY}(x, rows = NULL, cols = NULL, ..., useNames = TRUE) colCumsums(x, rows = NULL, cols = NULL, ..., useNames = TRUE) \S4method{colCumsums}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, dim. = dim(x), ..., useNames = TRUE) \S4method{colCumsums}{ANY}(x, rows = NULL, cols = NULL, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} \item{dim.}{An \code{\link{integer}} \code{\link{vector}} of length two specifying the dimension of \code{x}, essential when x is a \code{\link{numeric}} vector. Note, that this is not a generic argument and not all methods need provide it.} } \value{ Returns a \code{\link{numeric}} \code{\link{matrix}}with the same dimensions as \code{x}. } \description{ Calculates the cumulative sum for each row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowCumsums}} / \code{matrixStats::\link[matrixStats]{colCumsums}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowCumsums(mat) colCumsums(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats]{rowCumsums}()} and \code{matrixStats::\link[matrixStats:rowCumsums]{colCumsums}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item \code{base::\link{cumsum}()}. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowDiffs.Rd0000644000175200017520000000543314710235307017354 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowDiffs.R \name{rowDiffs} \alias{rowDiffs} \alias{rowDiffs,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowDiffs,ANY-method} \alias{colDiffs} \alias{colDiffs,matrix_OR_array_OR_table_OR_numeric-method} \alias{colDiffs,ANY-method} \title{Calculates the difference between each element of a row (column) of a matrix-like object} \usage{ rowDiffs(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, ..., useNames = TRUE) \S4method{rowDiffs}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, dim. = dim(x), ..., useNames = TRUE) \S4method{rowDiffs}{ANY}(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, ..., useNames = TRUE) colDiffs(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, ..., useNames = TRUE) \S4method{colDiffs}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, dim. = dim(x), ..., useNames = TRUE) \S4method{colDiffs}{ANY}(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{lag}{An integer specifying the lag.} \item{differences}{An integer specifying the order of difference.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} \item{dim.}{An \code{\link{integer}} \code{\link{vector}} of length two specifying the dimension of \code{x}, essential when x is a \code{\link{numeric}} vector. Note, that this is not a generic argument and not all methods need provide it.} } \value{ Returns a \code{\link{numeric}} \code{\link{matrix}} with one column (row) less than x: \eqn{Nx(K-1)} or \eqn{(N-1)xK}. } \description{ Calculates the difference between each element of a row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowDiffs}} / \code{matrixStats::\link[matrixStats]{colDiffs}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowDiffs(mat) colDiffs(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats]{rowDiffs}()} and \code{matrixStats::\link[matrixStats:rowDiffs]{colDiffs}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item \code{base::\link{diff}()}. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowIQRDiffs.Rd0000644000175200017520000000560714710235307017733 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowIQRDiffs.R \name{rowIQRDiffs} \alias{rowIQRDiffs} \alias{rowIQRDiffs,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowIQRDiffs,ANY-method} \alias{colIQRDiffs} \alias{colIQRDiffs,matrix_OR_array_OR_table_OR_numeric-method} \alias{colIQRDiffs,ANY-method} \title{Calculates the interquartile range of the difference between each element of a row (column) of a matrix-like object} \usage{ rowIQRDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) \S4method{rowIQRDiffs}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) \S4method{rowIQRDiffs}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) colIQRDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) \S4method{colIQRDiffs}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) \S4method{colIQRDiffs}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{diff}{An integer specifying the order of difference.} \item{trim}{A double in [0,1/2] specifying the fraction of observations to be trimmed from each end of (sorted) x before estimation.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} } \value{ Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K). } \description{ Calculates the interquartile range of the difference between each element of a row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowIQRDiffs}} / \code{matrixStats::\link[matrixStats]{colIQRDiffs}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowIQRDiffs(mat) colIQRDiffs(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats:varDiff]{rowIQRDiffs}()} and \code{matrixStats::\link[matrixStats:varDiff]{colIQRDiffs}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item For the direct interquartile range see also \link{rowIQRs}. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowIQRs.Rd0000644000175200017520000000500514710235307017132 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowIQRs.R \name{rowIQRs} \alias{rowIQRs} \alias{rowIQRs,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowIQRs,ANY-method} \alias{colIQRs} \alias{colIQRs,matrix_OR_array_OR_table_OR_numeric-method} \alias{colIQRs,ANY-method} \title{Calculates the interquartile range for each row (column) of a matrix-like object} \usage{ rowIQRs(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{rowIQRs}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{rowIQRs}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colIQRs(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{colIQRs}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{colIQRs}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} } \value{ Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K). } \description{ Calculates the interquartile range for each row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowIQRs}} / \code{matrixStats::\link[matrixStats]{colIQRs}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowIQRs(mat) colIQRs(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats]{rowIQRs}()} and \code{matrixStats::\link[matrixStats:rowIQRs]{colIQRs}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item For a non-robust analog, see \code{\link{rowSds}()}. For a more robust version see \code{\link[=rowMads]{rowMads()}} \item \code{stats::\link[stats]{IQR}()}. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowLogSumExps.Rd0000644000175200017520000000560514710235307020370 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowLogSumExps.R \name{rowLogSumExps} \alias{rowLogSumExps} \alias{rowLogSumExps,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowLogSumExps,ANY-method} \alias{colLogSumExps} \alias{colLogSumExps,matrix_OR_array_OR_table_OR_numeric-method} \alias{colLogSumExps,ANY-method} \title{Accurately calculates the logarithm of the sum of exponentials for each row (column) of a matrix-like object} \usage{ rowLogSumExps(lx, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{rowLogSumExps}{matrix_OR_array_OR_table_OR_numeric}(lx, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(lx), ..., useNames = TRUE) \S4method{rowLogSumExps}{ANY}(lx, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colLogSumExps(lx, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{colLogSumExps}{matrix_OR_array_OR_table_OR_numeric}(lx, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(lx), ..., useNames = TRUE) \S4method{colLogSumExps}{ANY}(lx, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) } \arguments{ \item{lx}{An NxK matrix-like object. Typically \code{lx} are \code{log(x)} values.} \item{rows, cols}{A \code{\link{vector}} indicating the subset (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} \item{dim.}{An \code{\link{integer}} \code{\link{vector}} of length two specifying the dimension of \code{x}, essential when x is a \code{\link{numeric}} vector. Note, that this is not a generic argument and not all methods need provide it.} } \value{ Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K). } \description{ Accurately calculates the logarithm of the sum of exponentials for each row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowLogSumExps}} / \code{matrixStats::\link[matrixStats]{colLogSumExps}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowLogSumExps(mat) colLogSumExps(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats]{rowLogSumExps}()} and \code{matrixStats::\link[matrixStats:rowLogSumExps]{colLogSumExps}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item \code{\link[=rowSums2]{rowSums2()}} } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowMadDiffs.Rd0000644000175200017520000000551514710235307017777 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowMadDiffs.R \name{rowMadDiffs} \alias{rowMadDiffs} \alias{rowMadDiffs,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowMadDiffs,ANY-method} \alias{colMadDiffs} \alias{colMadDiffs,matrix_OR_array_OR_table_OR_numeric-method} \alias{colMadDiffs,ANY-method} \title{Calculates the mean absolute deviation of the difference between each element of a row (column) of a matrix-like object} \usage{ rowMadDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) \S4method{rowMadDiffs}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) \S4method{rowMadDiffs}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) colMadDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) \S4method{colMadDiffs}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) \S4method{colMadDiffs}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{diff}{An integer specifying the order of difference.} \item{trim}{A double in [0,1/2] specifying the fraction of observations to be trimmed from each end of (sorted) x before estimation.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} } \value{ Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K). } \description{ Calculates the mean absolute deviation of the difference between each element of a row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowMadDiffs}} / \code{matrixStats::\link[matrixStats]{colMadDiffs}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowMadDiffs(mat) colMadDiffs(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats:varDiff]{rowMadDiffs}()} and \code{matrixStats::\link[matrixStats:varDiff]{colMadDiffs}()} which are used when the input is a \code{matrix} or \code{numeric} vector. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowMads.Rd0000644000175200017520000000623614710235307017207 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowMads.R \name{rowMads} \alias{rowMads} \alias{rowMads,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowMads,ANY-method} \alias{colMads} \alias{colMads,matrix_OR_array_OR_table_OR_numeric-method} \alias{colMads,ANY-method} \title{Calculates the median absolute deviation for each row (column) of a matrix-like object} \usage{ rowMads(x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, ..., useNames = TRUE) \S4method{rowMads}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) \S4method{rowMads}{ANY}(x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, ..., useNames = TRUE) colMads(x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, ..., useNames = TRUE) \S4method{colMads}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) \S4method{colMads}{ANY}(x, rows = NULL, cols = NULL, center = NULL, constant = 1.4826, na.rm = FALSE, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{center}{(optional) the center, defaults to the row means} \item{constant}{A scale factor. See \code{stats::\link[stats]{mad}()} for details.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} \item{dim.}{An \code{\link{integer}} \code{\link{vector}} of length two specifying the dimension of \code{x}, essential when x is a \code{\link{numeric}} vector. Note, that this is not a generic argument and not all methods need provide it.} } \value{ Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K). } \description{ Calculates the median absolute deviation for each row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowMads}} / \code{matrixStats::\link[matrixStats]{colMads}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowMads(mat) colMads(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats:rowSds]{rowMads}()} and \code{matrixStats::\link[matrixStats:rowSds]{colMads}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item For mean estimates, see \code{\link{rowMeans2}()} and \code{\link[base:colSums]{rowMeans}()}. \item For non-robust standard deviation estimates, see \code{\link{rowSds}()}. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowMaxs.Rd0000644000175200017520000000523414710235307017230 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowMaxs.R \name{rowMaxs} \alias{rowMaxs} \alias{rowMaxs,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowMaxs,ANY-method} \alias{colMaxs} \alias{colMaxs,matrix_OR_array_OR_table_OR_numeric-method} \alias{colMaxs,ANY-method} \title{Calculates the maximum for each row (column) of a matrix-like object} \usage{ rowMaxs(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{rowMaxs}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) \S4method{rowMaxs}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colMaxs(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{colMaxs}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) \S4method{colMaxs}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} \item{dim.}{An \code{\link{integer}} \code{\link{vector}} of length two specifying the dimension of \code{x}, essential when x is a \code{\link{numeric}} vector. Note, that this is not a generic argument and not all methods need provide it.} } \value{ Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K). } \description{ Calculates the maximum for each row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowMaxs}} / \code{matrixStats::\link[matrixStats]{colMaxs}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowMaxs(mat) colMaxs(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats:rowRanges]{rowMaxs}()} and \code{matrixStats::\link[matrixStats:rowRanges]{colMaxs}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item For min estimates, see \code{\link{rowMins}()}. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowMeans.Rd0000644000175200017520000000346614710235307017370 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowMeans.R \name{rowMeans} \alias{rowMeans} \alias{colMeans} \title{Calculates the mean for each row (column) of a matrix-like object} \usage{ rowMeans(x, na.rm = FALSE, dims = 1, ...) colMeans(x, na.rm = FALSE, dims = 1, ...) } \arguments{ \item{x}{An NxK matrix-like object, a numeric data frame, or an array-like object of two or more dimensions.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{dims}{A single integer indicating which dimensions are regarded as rows or columns to mean over. For \code{rowMeans}, the mean is over dimensions \code{dims+1, ...}; for \code{colMeans} it is over dimensions \code{1:dims}.} \item{...}{Additional arguments passed to specific methods.} } \value{ Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K). } \description{ Calculates the mean for each row (column) of a matrix-like object. } \details{ This man page documents the \code{rowMeans} and \code{colMeans} \emph{S4 generic functions} defined in the \pkg{MatrixGenerics} package. See \code{?base::\link[base]{colMeans}} for the default methods (defined in the \pkg{base} package). } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowMeans(mat) colMeans(mat) } \seealso{ \itemize{ \item \code{base::\link[base]{colMeans}} for the default \code{rowMeans} and \code{colMeans} methods. \item \code{Matrix::\link[Matrix]{colMeans}} in the \pkg{Matrix} package for \code{rowMeans} and \code{colMeans} methods defined for CsparseMatrix derivatives (e.g. dgCMatrix objects). } } \keyword{algebra} \keyword{arith} \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowMeans2.Rd0000644000175200017520000000553314710235307017447 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowMeans2.R \name{rowMeans2} \alias{rowMeans2} \alias{rowMeans2,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowMeans2,ANY-method} \alias{colMeans2} \alias{colMeans2,matrix_OR_array_OR_table_OR_numeric-method} \alias{colMeans2,ANY-method} \title{Calculates the mean for each row (column) of a matrix-like object} \usage{ rowMeans2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{rowMeans2}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) \S4method{rowMeans2}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colMeans2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{colMeans2}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) \S4method{colMeans2}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} \item{dim.}{An \code{\link{integer}} \code{\link{vector}} of length two specifying the dimension of \code{x}, essential when x is a \code{\link{numeric}} vector. Note, that this is not a generic argument and not all methods need provide it.} } \value{ Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K). } \description{ Calculates the mean for each row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowMeans2}} / \code{matrixStats::\link[matrixStats]{colMeans2}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowMeans2(mat) colMeans2(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats]{rowMeans2}()} and \code{matrixStats::\link[matrixStats:rowMeans2]{colMeans2}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item See also \code{\link[base:colSums]{rowMeans}()} for the corresponding function in base R. \item For variance estimates, see \code{\link{rowVars}()}. \item See also the base R version \code{base::\link{rowMeans}()}. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowMedians.Rd0000644000175200017520000000537314710235307017704 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowMedians.R \name{rowMedians} \alias{rowMedians} \alias{rowMedians,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowMedians,ANY-method} \alias{colMedians} \alias{colMedians,matrix_OR_array_OR_table_OR_numeric-method} \alias{colMedians,ANY-method} \title{Calculates the median for each row (column) of a matrix-like object} \usage{ rowMedians(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{rowMedians}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) \S4method{rowMedians}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colMedians(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{colMedians}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) \S4method{colMedians}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} \item{dim.}{An \code{\link{integer}} \code{\link{vector}} of length two specifying the dimension of \code{x}, essential when x is a \code{\link{numeric}} vector. Note, that this is not a generic argument and not all methods need provide it.} } \value{ Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K). } \description{ Calculates the median for each row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowMedians}} / \code{matrixStats::\link[matrixStats]{colMedians}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowMedians(mat) colMedians(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats]{rowMedians}()} and \code{matrixStats::\link[matrixStats:rowMedians]{colMedians}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item For mean estimates, see \code{\link{rowMeans2}()} and \code{\link[base:colSums]{rowMeans}()}. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowMins.Rd0000644000175200017520000000523414710235307017226 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowMins.R \name{rowMins} \alias{rowMins} \alias{rowMins,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowMins,ANY-method} \alias{colMins} \alias{colMins,matrix_OR_array_OR_table_OR_numeric-method} \alias{colMins,ANY-method} \title{Calculates the minimum for each row (column) of a matrix-like object} \usage{ rowMins(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{rowMins}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) \S4method{rowMins}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colMins(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{colMins}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) \S4method{colMins}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} \item{dim.}{An \code{\link{integer}} \code{\link{vector}} of length two specifying the dimension of \code{x}, essential when x is a \code{\link{numeric}} vector. Note, that this is not a generic argument and not all methods need provide it.} } \value{ Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K). } \description{ Calculates the minimum for each row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowMins}} / \code{matrixStats::\link[matrixStats]{colMins}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowMins(mat) colMins(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats:rowRanges]{rowMins}()} and \code{matrixStats::\link[matrixStats:rowRanges]{colMins}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item For max estimates, see \code{\link{rowMaxs}()}. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowOrderStats.Rd0000644000175200017520000000526314710235307020414 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowOrderStats.R \name{rowOrderStats} \alias{rowOrderStats} \alias{rowOrderStats,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowOrderStats,ANY-method} \alias{colOrderStats} \alias{colOrderStats,matrix_OR_array_OR_table_OR_numeric-method} \alias{colOrderStats,ANY-method} \title{Calculates an order statistic for each row (column) of a matrix-like object} \usage{ rowOrderStats(x, rows = NULL, cols = NULL, which, ..., useNames = TRUE) \S4method{rowOrderStats}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, which, dim. = dim(x), ..., useNames = TRUE) \S4method{rowOrderStats}{ANY}(x, rows = NULL, cols = NULL, which, ..., useNames = TRUE) colOrderStats(x, rows = NULL, cols = NULL, which, ..., useNames = TRUE) \S4method{colOrderStats}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, which, dim. = dim(x), ..., useNames = TRUE) \S4method{colOrderStats}{ANY}(x, rows = NULL, cols = NULL, which, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{which}{An integer index in [1,K] ([1,N]) indicating which order statistic to be returned} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} \item{dim.}{An \code{\link{integer}} \code{\link{vector}} of length two specifying the dimension of \code{x}, essential when x is a \code{\link{numeric}} vector. Note, that this is not a generic argument and not all methods need provide it.} } \value{ Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K). } \description{ Calculates an order statistic for each row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowOrderStats}} / \code{matrixStats::\link[matrixStats]{colOrderStats}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- 2 mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowOrderStats(mat, which = 1) colOrderStats(mat, which = 3) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats]{rowOrderStats}()} and \code{matrixStats::\link[matrixStats:rowOrderStats]{colOrderStats}()} which are used when the input is a \code{matrix} or \code{numeric} vector. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowProds.Rd0000644000175200017520000000535714710235307017415 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowProds.R \name{rowProds} \alias{rowProds} \alias{rowProds,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowProds,ANY-method} \alias{colProds} \alias{colProds,matrix_OR_array_OR_table_OR_numeric-method} \alias{colProds,ANY-method} \title{Calculates the product for each row (column) of a matrix-like object} \usage{ rowProds(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{rowProds}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, method = c("direct", "expSumLog"), ..., useNames = TRUE) \S4method{rowProds}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colProds(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{colProds}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, method = c("direct", "expSumLog"), ..., useNames = TRUE) \S4method{colProds}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} \item{method}{A character vector of length one that specifies the how the product is calculated. Note, that this is not a generic argument and not all implementation have to provide it.} } \value{ Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K). } \description{ Calculates the product for each row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowProds}} / \code{matrixStats::\link[matrixStats]{colProds}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowProds(mat) colProds(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats]{rowProds}()} and \code{matrixStats::\link[matrixStats:rowProds]{colProds}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item For sums across rows (columns), see \code{\link{rowSums2}()} (\code{\link[=colSums2]{colSums2()}}) \item \code{base::\link{prod}()}. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowQuantiles.Rd0000644000175200017520000000661414710235307020270 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowQuantiles.R \name{rowQuantiles} \alias{rowQuantiles} \alias{rowQuantiles,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowQuantiles,ANY-method} \alias{colQuantiles} \alias{colQuantiles,matrix_OR_array_OR_table_OR_numeric-method} \alias{colQuantiles,ANY-method} \title{Calculates quantiles for each row (column) of a matrix-like object} \usage{ rowQuantiles(x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, digits = 7L, ..., useNames = TRUE, drop = TRUE) \S4method{rowQuantiles}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, digits = 7L, ..., useNames = TRUE, drop = TRUE) \S4method{rowQuantiles}{ANY}(x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, digits = 7L, ..., useNames = TRUE, drop = TRUE) colQuantiles(x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, digits = 7L, ..., useNames = TRUE, drop = TRUE) \S4method{colQuantiles}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, digits = 7L, ..., useNames = TRUE, drop = TRUE) \S4method{colQuantiles}{ANY}(x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = FALSE, type = 7L, digits = 7L, ..., useNames = TRUE, drop = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{probs}{A numeric vector of J probabilities in [0, 1].} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{type}{An integer specifying the type of estimator. See \code{stats::\link[stats]{quantile}()} for more details.} \item{digits}{An integer specifying the precision of the formatted percentages. See \code{stats::\link[stats]{quantile}()} for more details.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} \item{drop}{If \code{TRUE} a vector is returned if \code{J == 1}.} } \value{ a \code{\link{numeric}} \code{NxJ} (\code{KxJ}) \code{\link{matrix}}, where N (K) is the number of rows (columns) for which the J values are calculated. } \description{ Calculates quantiles for each row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowQuantiles}} / \code{matrixStats::\link[matrixStats]{colQuantiles}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowQuantiles(mat) colQuantiles(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats]{rowQuantiles}()} and \code{matrixStats::\link[matrixStats:rowQuantiles]{colQuantiles}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item \link[stats:quantile]{stats::quantile} } } \keyword{array} \keyword{iteration} \keyword{robust} MatrixGenerics/man/rowRanges.Rd0000644000175200017520000000622114710235307017534 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowRanges.R \name{rowRanges} \alias{rowRanges} \alias{rowRanges,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowRanges,ANY-method} \alias{colRanges} \alias{colRanges,matrix_OR_array_OR_table_OR_numeric-method} \alias{colRanges,ANY-method} \title{Calculates the minimum and maximum for each row (column) of a matrix-like object} \usage{ rowRanges(x, ...) \S4method{rowRanges}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) \S4method{rowRanges}{ANY}(x, ...) colRanges(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{colRanges}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) \S4method{colRanges}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{...}{Additional arguments passed to specific methods.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{dim.}{An \code{\link{integer}} \code{\link{vector}} of length two specifying the dimension of \code{x}, essential when x is a \code{\link{numeric}} vector. Note, that this is not a generic argument and not all methods need provide it.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} } \value{ a \code{\link{numeric}} \code{Nx2} (\code{Kx2}) \code{\link{matrix}}, where N (K) is the number of rows (columns) for which the ranges are calculated. } \description{ Calculates the minimum and maximum for each row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowRanges}} / \code{matrixStats::\link[matrixStats]{colRanges}}. } \note{ Unfortunately for the argument list of the \code{rowRanges()} generic function we cannot follow the scheme used for the other row/column matrix summarization generic functions. This is because we need to be compatible with the historic \code{rowRanges()} getter for \link[SummarizedExperiment]{RangedSummarizedExperiment} objects. See \code{?SummarizedExperiment::\link[SummarizedExperiment]{rowRanges}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowRanges(mat) colRanges(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats]{rowRanges}()} and \code{matrixStats::\link[matrixStats:rowRanges]{colRanges}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item For max estimates, see \code{\link{rowMaxs}()}. \item For min estimates, see \code{\link{rowMins}()}. \item \code{base::\link{range}()}. } } \keyword{array} \keyword{iteration} \keyword{robust} MatrixGenerics/man/rowRanks.Rd0000644000175200017520000001013414740010125017361 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowRanks.R \name{rowRanks} \alias{rowRanks} \alias{rowRanks,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowRanks,ANY-method} \alias{colRanks} \alias{colRanks,matrix_OR_array_OR_table_OR_numeric-method} \alias{colRanks,ANY-method} \title{Calculates the rank of the elements for each row (column) of a matrix-like object} \usage{ rowRanks(x, rows = NULL, cols = NULL, ties.method = c("max", "average"), ..., useNames = TRUE) \S4method{rowRanks}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, ties.method = c("max", "average", "first", "last", "random", "max", "min", "dense"), dim. = dim(x), ..., useNames = TRUE) \S4method{rowRanks}{ANY}(x, rows = NULL, cols = NULL, ties.method = c("max", "average"), ..., useNames = TRUE) colRanks(x, rows = NULL, cols = NULL, ties.method = c("max", "average"), ..., useNames = TRUE) \S4method{colRanks}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, ties.method = c("max", "average", "first", "last", "random", "max", "min", "dense"), dim. = dim(x), preserveShape = FALSE, ..., useNames = TRUE) \S4method{colRanks}{ANY}(x, rows = NULL, cols = NULL, ties.method = c("max", "average"), ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{ties.method}{A character string specifying how ties are treated. Note that the default specifies fewer options than the original matrixStats package.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} \item{dim.}{An \code{\link{integer}} \code{\link{vector}} of length two specifying the dimension of \code{x}, essential when x is a \code{\link{numeric}} vector. Note, that this is not a generic argument and not all methods need provide it.} \item{preserveShape}{If \code{TRUE} the output matrix has the same shape as the input x. Note, that this is not a generic argument and not all implementation of this function have to provide it.} } \value{ A \code{\link[base]{matrix}} of type \code{\link[base]{integer}} is returned, unless \code{ties.method = "average"} when it is of type \code{\link[base]{numeric}}. The \code{rowRanks()} function always returns an NxK \code{\link[base]{matrix}}, where N (K) is the number of rows (columns) whose ranks are calculated. The \code{colRanks()} function returns an NxK \code{\link[base]{matrix}}, if \code{preserveShape = TRUE}, otherwise a KxN \code{\link[base]{matrix}}. Any \code{\link[base]{names}} of \code{x} are ignored and absent in the result. } \description{ Calculates the rank of the elements for each row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowRanks}} / \code{matrixStats::\link[matrixStats]{colRanks}}. The \code{matrixStats::rowRanks()} function can handle a lot of different values for the \code{ties.method} argument. Users of the generic function should however only rely on \code{max} and \code{average} because the other ones are not guaranteed to be implemented: \describe{ \item{\code{max}}{for values with identical values the maximum rank is returned} \item{\code{average}}{for values with identical values the average of the ranks they cover is returned. Note, that in this case the return value is of type \code{numeric}.} } } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowRanks(mat) colRanks(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats]{rowRanks}()} and \code{matrixStats::\link[matrixStats:rowRanks]{colRanks}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item \link[base:rank]{base::rank} } } \keyword{array} \keyword{iteration} \keyword{robust} MatrixGenerics/man/rowSdDiffs.Rd0000644000175200017520000000557414710235307017651 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowSdDiffs.R \name{rowSdDiffs} \alias{rowSdDiffs} \alias{rowSdDiffs,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowSdDiffs,ANY-method} \alias{colSdDiffs} \alias{colSdDiffs,matrix_OR_array_OR_table_OR_numeric-method} \alias{colSdDiffs,ANY-method} \title{Calculates the standard deviation of the difference between each element of a row (column) of a matrix-like object} \usage{ rowSdDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) \S4method{rowSdDiffs}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) \S4method{rowSdDiffs}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) colSdDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) \S4method{colSdDiffs}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) \S4method{colSdDiffs}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{diff}{An integer specifying the order of difference.} \item{trim}{A double in [0,1/2] specifying the fraction of observations to be trimmed from each end of (sorted) x before estimation.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} } \value{ Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K). } \description{ Calculates the standard deviation of the difference between each element of a row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowSdDiffs}} / \code{matrixStats::\link[matrixStats]{colSdDiffs}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowSdDiffs(mat) colSdDiffs(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats:varDiff]{rowSdDiffs}()} and \code{matrixStats::\link[matrixStats:varDiff]{colSdDiffs}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item for the direct standard deviation see \code{\link[=rowSds]{rowSds()}}. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowSds.Rd0000644000175200017520000000563114710235307017052 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowSds.R \name{rowSds} \alias{rowSds} \alias{rowSds,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowSds,ANY-method} \alias{colSds} \alias{colSds,matrix_OR_array_OR_table_OR_numeric-method} \alias{colSds,ANY-method} \title{Calculates the standard deviation for each row (column) of a matrix-like object} \usage{ rowSds(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE) \S4method{rowSds}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, dim. = dim(x), ..., useNames = TRUE) \S4method{rowSds}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE) colSds(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE) \S4method{colSds}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, dim. = dim(x), ..., useNames = TRUE) \S4method{colSds}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{center}{(optional) the center, defaults to the row means} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} \item{dim.}{An \code{\link{integer}} \code{\link{vector}} of length two specifying the dimension of \code{x}, essential when x is a \code{\link{numeric}} vector. Note, that this is not a generic argument and not all methods need provide it.} } \value{ Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K). } \description{ Calculates the standard deviation for each row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowSds}} / \code{matrixStats::\link[matrixStats]{colSds}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowSds(mat) colSds(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats]{rowSds}()} and \code{matrixStats::\link[matrixStats:rowSds]{colSds}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item For mean estimates, see \code{\link{rowMeans2}()} and \code{\link[base:colSums]{rowMeans}()}. \item For variance estimates, see \code{\link{rowVars}()}. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowSums.Rd0000644000175200017520000000343714710235307017252 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowSums.R \name{rowSums} \alias{rowSums} \alias{colSums} \title{Calculates the sum for each row (column) of a matrix-like object} \usage{ rowSums(x, na.rm = FALSE, dims = 1, ...) colSums(x, na.rm = FALSE, dims = 1, ...) } \arguments{ \item{x}{An NxK matrix-like object, a numeric data frame, or an array-like object of two or more dimensions.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{dims}{A single integer indicating which dimensions are regarded as rows or columns to sum over. For \code{rowSums}, the sum is over dimensions \code{dims+1, ...}; for \code{colSums} it is over dimensions \code{1:dims}.} \item{...}{Additional arguments passed to specific methods.} } \value{ Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K). } \description{ Calculates the sum for each row (column) of a matrix-like object. } \details{ This man page documents the \code{rowSums} and \code{colSums} \emph{S4 generic functions} defined in the \pkg{MatrixGenerics} package. See \code{?base::\link[base]{colSums}} for the default methods (defined in the \pkg{base} package). } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowSums(mat) colSums(mat) } \seealso{ \itemize{ \item \code{base::\link[base]{colSums}} for the default \code{rowSums} and \code{colSums} methods. \item \code{Matrix::\link[Matrix]{colSums}} in the \pkg{Matrix} package for \code{rowSums} and \code{colSums} methods defined for CsparseMatrix derivatives (e.g. dgCMatrix objects). } } \keyword{algebra} \keyword{arith} \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowSums2.Rd0000644000175200017520000000535414710235307017334 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowSums2.R \name{rowSums2} \alias{rowSums2} \alias{rowSums2,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowSums2,ANY-method} \alias{colSums2} \alias{colSums2,matrix_OR_array_OR_table_OR_numeric-method} \alias{colSums2,ANY-method} \title{Calculates the sum for each row (column) of a matrix-like object} \usage{ rowSums2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{rowSums2}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) \S4method{rowSums2}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colSums2(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{colSums2}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ..., useNames = TRUE) \S4method{colSums2}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} \item{dim.}{An \code{\link{integer}} \code{\link{vector}} of length two specifying the dimension of \code{x}, essential when x is a \code{\link{numeric}} vector. Note, that this is not a generic argument and not all methods need provide it.} } \value{ Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K). } \description{ Calculates the sum for each row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowSums2}} / \code{matrixStats::\link[matrixStats]{colSums2}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowSums2(mat) colSums2(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats]{rowSums2}()} and \code{matrixStats::\link[matrixStats:rowSums2]{colSums2}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item For mean estimates, see \code{\link{rowMeans2}()} and \code{\link[base:colSums]{rowMeans}()}. \item \code{base::\link{sum}()}. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowTabulates.Rd0000644000175200017520000000502414710235307020241 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowTabulates.R \name{rowTabulates} \alias{rowTabulates} \alias{rowTabulates,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowTabulates,ANY-method} \alias{colTabulates} \alias{colTabulates,matrix_OR_array_OR_table_OR_numeric-method} \alias{colTabulates,ANY-method} \title{Tabulates the values in a matrix-like object by row (column)} \usage{ rowTabulates(x, rows = NULL, cols = NULL, values = NULL, ..., useNames = TRUE) \S4method{rowTabulates}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, values = NULL, ..., useNames = TRUE) \S4method{rowTabulates}{ANY}(x, rows = NULL, cols = NULL, values = NULL, ..., useNames = TRUE) colTabulates(x, rows = NULL, cols = NULL, values = NULL, ..., useNames = TRUE) \S4method{colTabulates}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, values = NULL, ..., useNames = TRUE) \S4method{colTabulates}{ANY}(x, rows = NULL, cols = NULL, values = NULL, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{values}{the values to search for.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} } \value{ a \code{\link{numeric}} \code{NxJ} (\code{KxJ}) \code{\link{matrix}}, where N (K) is the number of rows (columns) for which the J values are calculated. } \description{ Tabulates the values in a matrix-like object by row (column). } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowTabulates}} / \code{matrixStats::\link[matrixStats]{colTabulates}}. } \examples{ mat <- matrix(rpois(15, lambda = 3), nrow = 5, ncol = 3) mat[2, 1] <- NA_integer_ mat[3, 3] <- 0L mat[4, 1] <- 0L print(mat) rowTabulates(mat) colTabulates(mat) rowTabulates(mat, values = 0) colTabulates(mat, values = 0) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats]{rowTabulates}()} and \code{matrixStats::\link[matrixStats:rowTabulates]{colTabulates}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item \code{base::\link{table}()} } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowVarDiffs.Rd0000644000175200017520000000556414710235307020032 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowVarDiffs.R \name{rowVarDiffs} \alias{rowVarDiffs} \alias{rowVarDiffs,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowVarDiffs,ANY-method} \alias{colVarDiffs} \alias{colVarDiffs,matrix_OR_array_OR_table_OR_numeric-method} \alias{colVarDiffs,ANY-method} \title{Calculates the variance of the difference between each element of a row (column) of a matrix-like object} \usage{ rowVarDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) \S4method{rowVarDiffs}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) \S4method{rowVarDiffs}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) colVarDiffs(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) \S4method{colVarDiffs}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) \S4method{colVarDiffs}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{diff}{An integer specifying the order of difference.} \item{trim}{A double in [0,1/2] specifying the fraction of observations to be trimmed from each end of (sorted) x before estimation.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} } \value{ Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K). } \description{ Calculates the variance of the difference between each element of a row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowVarDiffs}} / \code{matrixStats::\link[matrixStats]{colVarDiffs}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowVarDiffs(mat) colVarDiffs(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats:varDiff]{rowVarDiffs}()} and \code{matrixStats::\link[matrixStats:varDiff]{colVarDiffs}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item for the direct variance see \code{\link[=rowVars]{rowVars()}}. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowVars.Rd0000644000175200017520000000572114710235307017234 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowVars.R \name{rowVars} \alias{rowVars} \alias{rowVars,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowVars,ANY-method} \alias{colVars} \alias{colVars,matrix_OR_array_OR_table_OR_numeric-method} \alias{colVars,ANY-method} \title{Calculates the variance for each row (column) of a matrix-like object} \usage{ rowVars(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE) \S4method{rowVars}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, dim. = dim(x), ..., useNames = TRUE) \S4method{rowVars}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE) colVars(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE) \S4method{colVars}{matrix_OR_array_OR_table_OR_numeric}(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, dim. = dim(x), ..., useNames = TRUE) \S4method{colVars}{ANY}(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{center}{(optional) the center, defaults to the row means.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} \item{dim.}{An \code{\link{integer}} \code{\link{vector}} of length two specifying the dimension of \code{x}, essential when x is a \code{\link{numeric}} vector. Note, that this is not a generic argument and not all methods need provide it.} } \value{ Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K). } \description{ Calculates the variance for each row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowVars}} / \code{matrixStats::\link[matrixStats]{colVars}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) rowVars(mat) colVars(mat) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats]{rowVars}()} and \code{matrixStats::\link[matrixStats:rowVars]{colVars}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item For mean estimates, see \code{\link{rowMeans2}()} and \code{\link[base:colSums]{rowMeans}()}. \item For standard deviation estimates, see \code{\link{rowSds}()}. \item \code{stats::\link[stats:cor]{var}()}. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowWeightedMads.Rd0000644000175200017520000000627414710235307020672 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowWeightedMads.R \name{rowWeightedMads} \alias{rowWeightedMads} \alias{rowWeightedMads,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowWeightedMads,ANY-method} \alias{colWeightedMads} \alias{colWeightedMads,matrix_OR_array_OR_table_OR_numeric-method} \alias{colWeightedMads,ANY-method} \title{Calculates the weighted median absolute deviation for each row (column) of a matrix-like object} \usage{ rowWeightedMads(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, ..., useNames = TRUE) \S4method{rowWeightedMads}{matrix_OR_array_OR_table_OR_numeric}(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, ..., useNames = TRUE) \S4method{rowWeightedMads}{ANY}(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, ..., useNames = TRUE) colWeightedMads(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, ..., useNames = TRUE) \S4method{colWeightedMads}{matrix_OR_array_OR_table_OR_numeric}(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, ..., useNames = TRUE) \S4method{colWeightedMads}{ANY}(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, constant = 1.4826, center = NULL, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{w}{A \code{\link{numeric}} vector of length K (N) that specifies by how much each element is weighted.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{constant}{A scale factor. See \code{stats::\link[stats]{mad}()} for details.} \item{center}{(optional) the center, defaults to the row means} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} } \value{ Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K). } \description{ Calculates the weighted median absolute deviation for each row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowWeightedMads}} / \code{matrixStats::\link[matrixStats]{colWeightedMads}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) w <- rnorm(n = 5, mean = 3) rowWeightedMads(mat, w = w[1:3]) colWeightedMads(mat, w = w) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats:weightedMad]{rowWeightedMads}()} and \code{matrixStats::\link[matrixStats:weightedMad]{colWeightedMads}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item See also \link{rowMads} for the corresponding unweighted function. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowWeightedMeans.Rd0000644000175200017520000000546714710235307021054 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowWeightedMeans.R \name{rowWeightedMeans} \alias{rowWeightedMeans} \alias{rowWeightedMeans,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowWeightedMeans,ANY-method} \alias{colWeightedMeans} \alias{colWeightedMeans,matrix_OR_array_OR_table_OR_numeric-method} \alias{colWeightedMeans,ANY-method} \title{Calculates the weighted mean for each row (column) of a matrix-like object} \usage{ rowWeightedMeans(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{rowWeightedMeans}{matrix_OR_array_OR_table_OR_numeric}(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{rowWeightedMeans}{ANY}(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colWeightedMeans(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{colWeightedMeans}{matrix_OR_array_OR_table_OR_numeric}(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{colWeightedMeans}{ANY}(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{w}{A \code{\link{numeric}} vector of length K (N) that specifies by how much each element is weighted.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} } \value{ Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K). } \description{ Calculates the weighted mean for each row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowWeightedMeans}} / \code{matrixStats::\link[matrixStats]{colWeightedMeans}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) w <- rnorm(n = 5, mean = 3) rowWeightedMeans(mat, w = w[1:3]) colWeightedMeans(mat, w = w) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats]{rowWeightedMeans}()} and \code{matrixStats::\link[matrixStats:rowWeightedMeans]{colWeightedMeans}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item See also \link{rowMeans2} for the corresponding unweighted function. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowWeightedMedians.Rd0000644000175200017520000000555114710235307021363 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowWeightedMedians.R \name{rowWeightedMedians} \alias{rowWeightedMedians} \alias{rowWeightedMedians,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowWeightedMedians,ANY-method} \alias{colWeightedMedians} \alias{colWeightedMedians,matrix_OR_array_OR_table_OR_numeric-method} \alias{colWeightedMedians,ANY-method} \title{Calculates the weighted median for each row (column) of a matrix-like object} \usage{ rowWeightedMedians(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{rowWeightedMedians}{matrix_OR_array_OR_table_OR_numeric}(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{rowWeightedMedians}{ANY}(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colWeightedMedians(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{colWeightedMedians}{matrix_OR_array_OR_table_OR_numeric}(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{colWeightedMedians}{ANY}(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{w}{A \code{\link{numeric}} vector of length K (N) that specifies by how much each element is weighted.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} } \value{ Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K). } \description{ Calculates the weighted median for each row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowWeightedMedians}} / \code{matrixStats::\link[matrixStats]{colWeightedMedians}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) w <- rnorm(n = 5, mean = 3) rowWeightedMedians(mat, w = w[1:3]) colWeightedMedians(mat, w = w) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats]{rowWeightedMedians}()} and \code{matrixStats::\link[matrixStats:rowWeightedMedians]{colWeightedMedians}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item See also \link{rowMedians} for the corresponding unweighted function. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowWeightedSds.Rd0000644000175200017520000000545614710235307020540 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowWeightedSds.R \name{rowWeightedSds} \alias{rowWeightedSds} \alias{rowWeightedSds,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowWeightedSds,ANY-method} \alias{colWeightedSds} \alias{colWeightedSds,matrix_OR_array_OR_table_OR_numeric-method} \alias{colWeightedSds,ANY-method} \title{Calculates the weighted standard deviation for each row (column) of a matrix-like object} \usage{ rowWeightedSds(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{rowWeightedSds}{matrix_OR_array_OR_table_OR_numeric}(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{rowWeightedSds}{ANY}(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colWeightedSds(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{colWeightedSds}{matrix_OR_array_OR_table_OR_numeric}(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{colWeightedSds}{ANY}(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{w}{A \code{\link{numeric}} vector of length K (N) that specifies by how much each element is weighted.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} } \value{ Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K). } \description{ Calculates the weighted standard deviation for each row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowWeightedSds}} / \code{matrixStats::\link[matrixStats]{colWeightedSds}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) w <- rnorm(n = 5, mean = 3) rowWeightedSds(mat, w = w[1:3]) colWeightedSds(mat, w = w) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats:weightedVar]{rowWeightedSds}()} and \code{matrixStats::\link[matrixStats:weightedVar]{colWeightedSds}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item See also \link{rowSds} for the corresponding unweighted function. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/man/rowWeightedVars.Rd0000644000175200017520000000545714710235307020723 0ustar00biocbuildbiocbuild% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rowWeightedVars.R \name{rowWeightedVars} \alias{rowWeightedVars} \alias{rowWeightedVars,matrix_OR_array_OR_table_OR_numeric-method} \alias{rowWeightedVars,ANY-method} \alias{colWeightedVars} \alias{colWeightedVars,matrix_OR_array_OR_table_OR_numeric-method} \alias{colWeightedVars,ANY-method} \title{Calculates the weighted variance for each row (column) of a matrix-like object} \usage{ rowWeightedVars(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{rowWeightedVars}{matrix_OR_array_OR_table_OR_numeric}(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{rowWeightedVars}{ANY}(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) colWeightedVars(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{colWeightedVars}{matrix_OR_array_OR_table_OR_numeric}(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) \S4method{colWeightedVars}{ANY}(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) } \arguments{ \item{x}{An NxK matrix-like object.} \item{w}{A \code{\link{numeric}} vector of length K (N) that specifies by how much each element is weighted.} \item{rows, cols}{A \code{\link{vector}} indicating the subset of rows (and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is done.} \item{na.rm}{If \code{\link[base]{TRUE}}, missing values (\code{\link[base]{NA}} or \code{\link[base]{NaN}}) are omitted from the calculations.} \item{...}{Additional arguments passed to specific methods.} \item{useNames}{If \code{\link{TRUE}} (default), names attributes of result are set. Else if \code{\link{FALSE}}, no naming support is done.} } \value{ Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K). } \description{ Calculates the weighted variance for each row (column) of a matrix-like object. } \details{ The S4 methods for \code{x} of type \code{\link{matrix}}, \code{\link{array}}, \code{\link{table}}, or \code{\link{numeric}} call \code{matrixStats::\link[matrixStats]{rowWeightedVars}} / \code{matrixStats::\link[matrixStats]{colWeightedVars}}. } \examples{ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) mat[2, 1] <- NA mat[3, 3] <- Inf mat[4, 1] <- 0 print(mat) w <- rnorm(n = 5, mean = 3) rowWeightedVars(mat, w = w[1:3]) colWeightedVars(mat, w = w) } \seealso{ \itemize{ \item \code{matrixStats::\link[matrixStats:weightedVar]{rowWeightedVars}()} and \code{matrixStats::\link[matrixStats:weightedVar]{colWeightedVars}()} which are used when the input is a \code{matrix} or \code{numeric} vector. \item See also \link{rowVars} for the corresponding unweighted function. } } \keyword{array} \keyword{iteration} \keyword{robust} \keyword{univar} MatrixGenerics/tests/0000755000175200017520000000000014710235307015664 5ustar00biocbuildbiocbuildMatrixGenerics/tests/testthat/0000755000175200017520000000000014740053113017520 5ustar00biocbuildbiocbuildMatrixGenerics/tests/testthat.R0000644000175200017520000000011014710235307017637 0ustar00biocbuildbiocbuildlibrary(testthat) library(MatrixGenerics) test_check("MatrixGenerics") MatrixGenerics/tests/testthat/test-api_compatibility.R0000644000175200017520000016741614710235307024345 0ustar00biocbuildbiocbuild# Generated by tests/testthat/generate_tests_helper_script.R # do not edit by hand # Make a matrix with different features mat <- matrix(rnorm(16 * 6), nrow = 16, ncol = 6, dimnames = list(letters[1:16], LETTERS[1:6])) mat[1,1] <- 0 mat[2,3] <- NA mat[3,3] <- -Inf mat[5,4] <- NaN mat[5,1] <- Inf mat[6,2] <- 0 mat[6,5] <- 0 .check_formals <- function(fnc_name) { if (fnc_name == "rowRanges") return(invisible(NULL)) matrixStats_fun <- eval(parse(text=paste0("matrixStats::", fnc_name))) MatrixGenerics_fun <- eval(parse(text=paste0("MatrixGenerics::", fnc_name))) MatrixGenerics_matrixStats_method <- eval(parse(text=paste0("MatrixGenerics:::.matrixStats_", fnc_name))) matrixStats_formals <- formals(matrixStats_fun) MatrixGenerics_matrixStats_method_formals <- formals(MatrixGenerics_matrixStats_method) if (fnc_name %in% c("rowMeans2", "colMeans2", "rowVars", "colVars", "rowSds", "colSds")) matrixStats_formals$refine <- NULL expect_identical(MatrixGenerics_matrixStats_method_formals, matrixStats_formals) MatrixGenerics_formals <- formals(MatrixGenerics_fun) MatrixGenerics_matrixStats_method_formals <- formals(MatrixGenerics_matrixStats_method) MatrixGenerics_matrixStats_method_formals$dim. <- NULL if (fnc_name %in% c("rowProds", "colProds")) MatrixGenerics_matrixStats_method_formals$method <- NULL if (fnc_name %in% c("rowRanks", "colRanks")) MatrixGenerics_matrixStats_method_formals$ties.method <- MatrixGenerics_formals$ties.method <- NULL if (fnc_name == "colRanks") MatrixGenerics_matrixStats_method_formals$preserveShape <- NULL expect_identical(MatrixGenerics_matrixStats_method_formals, MatrixGenerics_formals) invisible(NULL) } test_that("colAlls works", { .check_formals("colAlls") mg_res_def_1 <- colAlls(x = mat) ms_res_def_1 <- matrixStats::colAlls(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colAlls(x = mat, rows = NULL, cols = NULL, value = TRUE, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::colAlls(x = mat, rows = NULL, cols = NULL, value = TRUE, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colAlls(x = mat, rows = 1:3, cols = 2, value = FALSE, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::colAlls(x = mat, rows = 1:3, cols = 2, value = FALSE, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) mg_res_3 <- colAlls(x = mat, rows = NULL, cols = NULL, value = 0, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_3 <- matrixStats::colAlls(x = mat, rows = NULL, cols = NULL, value = 0, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_3, ms_res_3) }) test_that("colAnyNAs works", { .check_formals("colAnyNAs") mg_res_def_1 <- colAnyNAs(x = mat) ms_res_def_1 <- matrixStats::colAnyNAs(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colAnyNAs(x = mat, rows = NULL, cols = NULL, useNames = TRUE) ms_res_1 <- matrixStats::colAnyNAs(x = mat, rows = NULL, cols = NULL, useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colAnyNAs(x = mat, rows = 1:3, cols = 2, useNames = FALSE) ms_res_2 <- matrixStats::colAnyNAs(x = mat, rows = 1:3, cols = 2, useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colAnys works", { .check_formals("colAnys") mg_res_def_1 <- colAnys(x = mat) ms_res_def_1 <- matrixStats::colAnys(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colAnys(x = mat, rows = NULL, cols = NULL, value = TRUE, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::colAnys(x = mat, rows = NULL, cols = NULL, value = TRUE, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colAnys(x = mat, rows = 1:3, cols = 2, value = FALSE, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::colAnys(x = mat, rows = 1:3, cols = 2, value = FALSE, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) mg_res_3 <- colAnys(x = mat, rows = NULL, cols = NULL, value = 0, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_3 <- matrixStats::colAnys(x = mat, rows = NULL, cols = NULL, value = 0, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_3, ms_res_3) }) test_that("colAvgsPerRowSet works", { .check_formals("colAvgsPerRowSet") S <- matrix(1:nrow(mat), ncol = 2) mg_res_def_1 <- colAvgsPerRowSet(X = mat, S = S, FUN = colMeans) ms_res_def_1 <- matrixStats::colAvgsPerRowSet(X = mat, S = S, FUN = colMeans) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_def_2 <- colAvgsPerRowSet(X = mat, S = S, FUN = colVars) ms_res_def_2 <- matrixStats::colAvgsPerRowSet(X = mat, S = S, FUN = colVars) expect_equal(mg_res_def_2, ms_res_def_2) mg_res_1 <- colAvgsPerRowSet(X = mat, W = NULL, cols = NULL, S = S, FUN = colMeans, na.rm = TRUE, tFUN = FALSE) ms_res_1 <- matrixStats::colAvgsPerRowSet(X = mat, W = NULL, cols = NULL, S = S, FUN = colMeans, na.rm = TRUE, tFUN = FALSE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colAvgsPerRowSet(X = mat, W = NULL, cols = 1:2, S = S, FUN = colVars, na.rm = FALSE, tFUN = FALSE) ms_res_2 <- matrixStats::colAvgsPerRowSet(X = mat, W = NULL, cols = 1:2, S = S, FUN = colVars, na.rm = FALSE, tFUN = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colCollapse works", { .check_formals("colCollapse") mg_res_def_1 <- colCollapse(x = mat, idxs = 1) ms_res_def_1 <- matrixStats::colCollapse(x = mat, idxs = 1) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_def_2 <- colCollapse(x = mat, idxs = 2:3) ms_res_def_2 <- matrixStats::colCollapse(x = mat, idxs = 2:3) expect_equal(mg_res_def_2, ms_res_def_2) mg_res_1 <- colCollapse(x = mat, idxs = 1, cols = NULL, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::colCollapse(x = mat, idxs = 1, cols = NULL, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colCollapse(x = mat, idxs = 2:3, cols = 2, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::colCollapse(x = mat, idxs = 2:3, cols = 2, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colCounts works", { .check_formals("colCounts") mg_res_def_1 <- colCounts(x = mat) ms_res_def_1 <- matrixStats::colCounts(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colCounts(x = mat, rows = NULL, cols = NULL, value = TRUE, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::colCounts(x = mat, rows = NULL, cols = NULL, value = TRUE, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colCounts(x = mat, rows = 1:3, cols = 2, value = FALSE, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::colCounts(x = mat, rows = 1:3, cols = 2, value = FALSE, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) mg_res_3 <- colCounts(x = mat, rows = NULL, cols = NULL, value = 0, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_3 <- matrixStats::colCounts(x = mat, rows = NULL, cols = NULL, value = 0, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_3, ms_res_3) }) test_that("colCummaxs works", { .check_formals("colCummaxs") mg_res_def_1 <- colCummaxs(x = mat) ms_res_def_1 <- matrixStats::colCummaxs(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colCummaxs(x = mat, rows = NULL, cols = NULL, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::colCummaxs(x = mat, rows = NULL, cols = NULL, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colCummaxs(x = mat, rows = 1:3, cols = 2, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::colCummaxs(x = mat, rows = 1:3, cols = 2, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colCummins works", { .check_formals("colCummins") mg_res_def_1 <- colCummins(x = mat) ms_res_def_1 <- matrixStats::colCummins(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colCummins(x = mat, rows = NULL, cols = NULL, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::colCummins(x = mat, rows = NULL, cols = NULL, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colCummins(x = mat, rows = 1:3, cols = 2, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::colCummins(x = mat, rows = 1:3, cols = 2, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colCumprods works", { .check_formals("colCumprods") mg_res_def_1 <- colCumprods(x = mat) ms_res_def_1 <- matrixStats::colCumprods(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colCumprods(x = mat, rows = NULL, cols = NULL, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::colCumprods(x = mat, rows = NULL, cols = NULL, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colCumprods(x = mat, rows = 1:3, cols = 2, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::colCumprods(x = mat, rows = 1:3, cols = 2, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colCumsums works", { .check_formals("colCumsums") mg_res_def_1 <- colCumsums(x = mat) ms_res_def_1 <- matrixStats::colCumsums(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colCumsums(x = mat, rows = NULL, cols = NULL, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::colCumsums(x = mat, rows = NULL, cols = NULL, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colCumsums(x = mat, rows = 1:3, cols = 2, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::colCumsums(x = mat, rows = 1:3, cols = 2, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colDiffs works", { .check_formals("colDiffs") mg_res_def_1 <- colDiffs(x = mat) ms_res_def_1 <- matrixStats::colDiffs(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colDiffs(x = mat, rows = NULL, cols = NULL, lag = 1, differences = 1, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::colDiffs(x = mat, rows = NULL, cols = NULL, lag = 1, differences = 1, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colDiffs(x = mat, rows = 1:3, cols = 2, lag = 3, differences = 2, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::colDiffs(x = mat, rows = 1:3, cols = 2, lag = 3, differences = 2, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colIQRDiffs works", { .check_formals("colIQRDiffs") mg_res_def_1 <- colIQRDiffs(x = mat) ms_res_def_1 <- matrixStats::colIQRDiffs(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colIQRDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0, useNames = TRUE) ms_res_1 <- matrixStats::colIQRDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0, useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colIQRDiffs(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, diff = 2, trim = 0.333333333333333, useNames = FALSE) ms_res_2 <- matrixStats::colIQRDiffs(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, diff = 2, trim = 0.333333333333333, useNames = FALSE) expect_equal(mg_res_2, ms_res_2) mg_res_3 <- colIQRDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0.5, useNames = TRUE) ms_res_3 <- matrixStats::colIQRDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0.5, useNames = TRUE) expect_equal(mg_res_3, ms_res_3) }) test_that("colIQRs works", { .check_formals("colIQRs") mg_res_def_1 <- colIQRs(x = mat) ms_res_def_1 <- matrixStats::colIQRs(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colIQRs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, useNames = TRUE) ms_res_1 <- matrixStats::colIQRs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colIQRs(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, useNames = FALSE) ms_res_2 <- matrixStats::colIQRs(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colLogSumExps works", { .check_formals("colLogSumExps") mg_res_def_1 <- colLogSumExps(lx = mat) ms_res_def_1 <- matrixStats::colLogSumExps(lx = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colLogSumExps(lx = mat, rows = NULL, cols = NULL, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::colLogSumExps(lx = mat, rows = NULL, cols = NULL, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colLogSumExps(lx = mat, rows = 1:3, cols = 2, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::colLogSumExps(lx = mat, rows = 1:3, cols = 2, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colMadDiffs works", { .check_formals("colMadDiffs") mg_res_def_1 <- colMadDiffs(x = mat) ms_res_def_1 <- matrixStats::colMadDiffs(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colMadDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0, useNames = TRUE) ms_res_1 <- matrixStats::colMadDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0, useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colMadDiffs(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, diff = 2, trim = 0.333333333333333, useNames = FALSE) ms_res_2 <- matrixStats::colMadDiffs(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, diff = 2, trim = 0.333333333333333, useNames = FALSE) expect_equal(mg_res_2, ms_res_2) mg_res_3 <- colMadDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0.5, useNames = TRUE) ms_res_3 <- matrixStats::colMadDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0.5, useNames = TRUE) expect_equal(mg_res_3, ms_res_3) }) test_that("colMads works", { .check_formals("colMads") mg_res_def_1 <- colMads(x = mat) ms_res_def_1 <- matrixStats::colMads(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colMads(x = mat, rows = NULL, cols = NULL, center = colMeans2(mat, na.rm=TRUE), constant = 1.4826, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::colMads(x = mat, rows = NULL, cols = NULL, center = colMeans2(mat, na.rm=TRUE), constant = 1.4826, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colMads(x = mat, rows = 1:3, cols = 2, center = NULL, constant = 5, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::colMads(x = mat, rows = 1:3, cols = 2, center = NULL, constant = 5, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colMaxs works", { .check_formals("colMaxs") mg_res_def_1 <- colMaxs(x = mat) ms_res_def_1 <- matrixStats::colMaxs(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colMaxs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::colMaxs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colMaxs(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::colMaxs(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colMeans2 works", { .check_formals("colMeans2") mg_res_def_1 <- colMeans2(x = mat) ms_res_def_1 <- matrixStats::colMeans2(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colMeans2(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, refine = , dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::colMeans2(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, refine = , dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colMeans2(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, refine = , dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::colMeans2(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, refine = , dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colMedians works", { .check_formals("colMedians") mg_res_def_1 <- colMedians(x = mat) ms_res_def_1 <- matrixStats::colMedians(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colMedians(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::colMedians(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colMedians(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::colMedians(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colMins works", { .check_formals("colMins") mg_res_def_1 <- colMins(x = mat) ms_res_def_1 <- matrixStats::colMins(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colMins(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::colMins(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colMins(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::colMins(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colOrderStats works", { .check_formals("colOrderStats") mat[is.na(mat)] <- 4.1 mg_res_def_1 <- colOrderStats(x = mat, which = 2) ms_res_def_1 <- matrixStats::colOrderStats(x = mat, which = 2) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_def_2 <- colOrderStats(x = mat, which = 1) ms_res_def_2 <- matrixStats::colOrderStats(x = mat, which = 1) expect_equal(mg_res_def_2, ms_res_def_2) mg_res_1 <- colOrderStats(x = mat, rows = NULL, cols = NULL, which = 2, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::colOrderStats(x = mat, rows = NULL, cols = NULL, which = 2, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colOrderStats(x = mat, rows = 1:3, cols = 2, which = 1, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::colOrderStats(x = mat, rows = 1:3, cols = 2, which = 1, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colProds works", { .check_formals("colProds") mg_res_def_1 <- colProds(x = mat) ms_res_def_1 <- matrixStats::colProds(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colProds(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, method = 'direct', useNames = TRUE) ms_res_1 <- matrixStats::colProds(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, method = 'direct', useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colProds(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, method = 'expSumLog', useNames = FALSE) ms_res_2 <- matrixStats::colProds(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, method = 'expSumLog', useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colQuantiles works", { .check_formals("colQuantiles") mg_res_def_1 <- colQuantiles(x = mat) ms_res_def_1 <- matrixStats::colQuantiles(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colQuantiles(x = mat, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = TRUE, type = 7, digits = 7, useNames = TRUE, drop = TRUE) ms_res_1 <- matrixStats::colQuantiles(x = mat, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = TRUE, type = 7, digits = 7, useNames = TRUE, drop = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colQuantiles(x = mat, rows = 1:3, cols = 2, probs = 0.1, na.rm = FALSE, type = 3, digits = 7, useNames = FALSE, drop = FALSE) ms_res_2 <- matrixStats::colQuantiles(x = mat, rows = 1:3, cols = 2, probs = 0.1, na.rm = FALSE, type = 3, digits = 7, useNames = FALSE, drop = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colRanges works", { .check_formals("colRanges") mg_res_def_1 <- colRanges(x = mat) ms_res_def_1 <- matrixStats::colRanges(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colRanges(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::colRanges(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colRanges(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::colRanges(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colRanks works", { .check_formals("colRanks") mg_res_def_1 <- colRanks(x = mat) ms_res_def_1 <- matrixStats::colRanks(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colRanks(x = mat, rows = NULL, cols = NULL, ties.method = 'max', dim. = dim(mat), preserveShape = FALSE, useNames = TRUE) ms_res_1 <- matrixStats::colRanks(x = mat, rows = NULL, cols = NULL, ties.method = 'max', dim. = dim(mat), preserveShape = FALSE, useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colRanks(x = mat, rows = 1:3, cols = 2, ties.method = 'first', dim. = c(12L, 8L), preserveShape = TRUE, useNames = FALSE) ms_res_2 <- matrixStats::colRanks(x = mat, rows = 1:3, cols = 2, ties.method = 'first', dim. = c(12L, 8L), preserveShape = TRUE, useNames = FALSE) expect_equal(mg_res_2, ms_res_2) mg_res_3 <- colRanks(x = mat, rows = NULL, cols = NULL, ties.method = 'dense', dim. = dim(mat), preserveShape = FALSE, useNames = TRUE) ms_res_3 <- matrixStats::colRanks(x = mat, rows = NULL, cols = NULL, ties.method = 'dense', dim. = dim(mat), preserveShape = FALSE, useNames = TRUE) expect_equal(mg_res_3, ms_res_3) }) test_that("colSdDiffs works", { .check_formals("colSdDiffs") mg_res_def_1 <- colSdDiffs(x = mat) ms_res_def_1 <- matrixStats::colSdDiffs(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colSdDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0, useNames = TRUE) ms_res_1 <- matrixStats::colSdDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0, useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colSdDiffs(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, diff = 2, trim = 0.333333333333333, useNames = FALSE) ms_res_2 <- matrixStats::colSdDiffs(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, diff = 2, trim = 0.333333333333333, useNames = FALSE) expect_equal(mg_res_2, ms_res_2) mg_res_3 <- colSdDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0.5, useNames = TRUE) ms_res_3 <- matrixStats::colSdDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0.5, useNames = TRUE) expect_equal(mg_res_3, ms_res_3) }) test_that("colSds works", { .check_formals("colSds") mg_res_def_1 <- colSds(x = mat) ms_res_def_1 <- matrixStats::colSds(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colSds(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, refine = , center = colMeans2(mat, na.rm=TRUE), dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::colSds(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, refine = , center = colMeans2(mat, na.rm=TRUE), dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colSds(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, refine = , center = NULL, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::colSds(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, refine = , center = NULL, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colSums2 works", { .check_formals("colSums2") mg_res_def_1 <- colSums2(x = mat) ms_res_def_1 <- matrixStats::colSums2(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colSums2(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::colSums2(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colSums2(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::colSums2(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colTabulates works", { .check_formals("colTabulates") mat <- array(suppressWarnings(as.integer(mat)), dim(mat)) mg_res_def_1 <- colTabulates(x = mat) ms_res_def_1 <- matrixStats::colTabulates(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colTabulates(x = mat, rows = NULL, cols = NULL, values = 0, useNames = TRUE) ms_res_1 <- matrixStats::colTabulates(x = mat, rows = NULL, cols = NULL, values = 0, useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colTabulates(x = mat, rows = 1:3, cols = 2, values = c(0, 1), useNames = FALSE) ms_res_2 <- matrixStats::colTabulates(x = mat, rows = 1:3, cols = 2, values = c(0, 1), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colVarDiffs works", { .check_formals("colVarDiffs") mg_res_def_1 <- colVarDiffs(x = mat) ms_res_def_1 <- matrixStats::colVarDiffs(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colVarDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0, useNames = TRUE) ms_res_1 <- matrixStats::colVarDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0, useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colVarDiffs(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, diff = 2, trim = 0.333333333333333, useNames = FALSE) ms_res_2 <- matrixStats::colVarDiffs(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, diff = 2, trim = 0.333333333333333, useNames = FALSE) expect_equal(mg_res_2, ms_res_2) mg_res_3 <- colVarDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0.5, useNames = TRUE) ms_res_3 <- matrixStats::colVarDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0.5, useNames = TRUE) expect_equal(mg_res_3, ms_res_3) }) test_that("colVars works", { .check_formals("colVars") mg_res_def_1 <- colVars(x = mat) ms_res_def_1 <- matrixStats::colVars(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colVars(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, refine = , center = colMeans2(mat, na.rm=TRUE), dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::colVars(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, refine = , center = colMeans2(mat, na.rm=TRUE), dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colVars(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, refine = , center = NULL, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::colVars(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, refine = , center = NULL, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colWeightedMads works", { .check_formals("colWeightedMads") mg_res_def_1 <- colWeightedMads(x = mat) ms_res_def_1 <- matrixStats::colWeightedMads(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colWeightedMads(x = mat, w = 1:16, rows = NULL, cols = NULL, na.rm = TRUE, constant = 1.4826, center = colMeans2(mat, na.rm=TRUE), useNames = TRUE) ms_res_1 <- matrixStats::colWeightedMads(x = mat, w = 1:16, rows = NULL, cols = NULL, na.rm = TRUE, constant = 1.4826, center = colMeans2(mat, na.rm=TRUE), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colWeightedMads(x = mat, w = NULL, rows = 1:3, cols = 2, na.rm = FALSE, constant = 5, center = rep(6, ncol(mat)), useNames = FALSE) ms_res_2 <- matrixStats::colWeightedMads(x = mat, w = NULL, rows = 1:3, cols = 2, na.rm = FALSE, constant = 5, center = rep(6, ncol(mat)), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colWeightedMeans works", { .check_formals("colWeightedMeans") mg_res_def_1 <- colWeightedMeans(x = mat) ms_res_def_1 <- matrixStats::colWeightedMeans(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colWeightedMeans(x = mat, w = 1:16, rows = NULL, cols = NULL, na.rm = TRUE, useNames = TRUE) ms_res_1 <- matrixStats::colWeightedMeans(x = mat, w = 1:16, rows = NULL, cols = NULL, na.rm = TRUE, useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colWeightedMeans(x = mat, w = NULL, rows = 1:3, cols = 2, na.rm = FALSE, useNames = FALSE) ms_res_2 <- matrixStats::colWeightedMeans(x = mat, w = NULL, rows = 1:3, cols = 2, na.rm = FALSE, useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colWeightedMedians works", { .check_formals("colWeightedMedians") mg_res_def_1 <- colWeightedMedians(x = mat) ms_res_def_1 <- matrixStats::colWeightedMedians(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colWeightedMedians(x = mat, w = 1:16, rows = NULL, cols = NULL, na.rm = TRUE, useNames = TRUE) ms_res_1 <- matrixStats::colWeightedMedians(x = mat, w = 1:16, rows = NULL, cols = NULL, na.rm = TRUE, useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colWeightedMedians(x = mat, w = NULL, rows = 1:3, cols = 2, na.rm = FALSE, useNames = FALSE) ms_res_2 <- matrixStats::colWeightedMedians(x = mat, w = NULL, rows = 1:3, cols = 2, na.rm = FALSE, useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colWeightedSds works", { .check_formals("colWeightedSds") mg_res_def_1 <- colWeightedSds(x = mat) ms_res_def_1 <- matrixStats::colWeightedSds(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colWeightedSds(x = mat, w = 1:16, rows = NULL, cols = NULL, na.rm = TRUE, useNames = TRUE) ms_res_1 <- matrixStats::colWeightedSds(x = mat, w = 1:16, rows = NULL, cols = NULL, na.rm = TRUE, useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colWeightedSds(x = mat, w = NULL, rows = 1:3, cols = 2, na.rm = FALSE, useNames = FALSE) ms_res_2 <- matrixStats::colWeightedSds(x = mat, w = NULL, rows = 1:3, cols = 2, na.rm = FALSE, useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("colWeightedVars works", { .check_formals("colWeightedVars") mg_res_def_1 <- colWeightedVars(x = mat) ms_res_def_1 <- matrixStats::colWeightedVars(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- colWeightedVars(x = mat, w = 1:16, rows = NULL, cols = NULL, na.rm = TRUE, useNames = TRUE) ms_res_1 <- matrixStats::colWeightedVars(x = mat, w = 1:16, rows = NULL, cols = NULL, na.rm = TRUE, useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- colWeightedVars(x = mat, w = NULL, rows = 1:3, cols = 2, na.rm = FALSE, useNames = FALSE) ms_res_2 <- matrixStats::colWeightedVars(x = mat, w = NULL, rows = 1:3, cols = 2, na.rm = FALSE, useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowAlls works", { .check_formals("rowAlls") mg_res_def_1 <- rowAlls(x = mat) ms_res_def_1 <- matrixStats::rowAlls(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowAlls(x = mat, rows = NULL, cols = NULL, value = TRUE, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::rowAlls(x = mat, rows = NULL, cols = NULL, value = TRUE, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowAlls(x = mat, rows = 1:3, cols = 2, value = FALSE, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::rowAlls(x = mat, rows = 1:3, cols = 2, value = FALSE, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) mg_res_3 <- rowAlls(x = mat, rows = NULL, cols = NULL, value = 0, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_3 <- matrixStats::rowAlls(x = mat, rows = NULL, cols = NULL, value = 0, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_3, ms_res_3) }) test_that("rowAnyNAs works", { .check_formals("rowAnyNAs") mg_res_def_1 <- rowAnyNAs(x = mat) ms_res_def_1 <- matrixStats::rowAnyNAs(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowAnyNAs(x = mat, rows = NULL, cols = NULL, useNames = TRUE) ms_res_1 <- matrixStats::rowAnyNAs(x = mat, rows = NULL, cols = NULL, useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowAnyNAs(x = mat, rows = 1:3, cols = 2, useNames = FALSE) ms_res_2 <- matrixStats::rowAnyNAs(x = mat, rows = 1:3, cols = 2, useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowAnys works", { .check_formals("rowAnys") mg_res_def_1 <- rowAnys(x = mat) ms_res_def_1 <- matrixStats::rowAnys(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowAnys(x = mat, rows = NULL, cols = NULL, value = TRUE, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::rowAnys(x = mat, rows = NULL, cols = NULL, value = TRUE, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowAnys(x = mat, rows = 1:3, cols = 2, value = FALSE, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::rowAnys(x = mat, rows = 1:3, cols = 2, value = FALSE, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) mg_res_3 <- rowAnys(x = mat, rows = NULL, cols = NULL, value = 0, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_3 <- matrixStats::rowAnys(x = mat, rows = NULL, cols = NULL, value = 0, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_3, ms_res_3) }) test_that("rowAvgsPerColSet works", { .check_formals("rowAvgsPerColSet") S <- matrix(1:ncol(mat), ncol = 2) mg_res_def_1 <- rowAvgsPerColSet(X = mat, S = S, FUN = rowMeans) ms_res_def_1 <- matrixStats::rowAvgsPerColSet(X = mat, S = S, FUN = rowMeans) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_def_2 <- rowAvgsPerColSet(X = mat, S = S, FUN = rowVars) ms_res_def_2 <- matrixStats::rowAvgsPerColSet(X = mat, S = S, FUN = rowVars) expect_equal(mg_res_def_2, ms_res_def_2) mg_res_1 <- rowAvgsPerColSet(X = mat, W = NULL, rows = NULL, S = S, FUN = rowMeans, na.rm = TRUE, tFUN = FALSE) ms_res_1 <- matrixStats::rowAvgsPerColSet(X = mat, W = NULL, rows = NULL, S = S, FUN = rowMeans, na.rm = TRUE, tFUN = FALSE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowAvgsPerColSet(X = mat, W = NULL, rows = 1:3, S = S, FUN = rowVars, na.rm = FALSE, tFUN = FALSE) ms_res_2 <- matrixStats::rowAvgsPerColSet(X = mat, W = NULL, rows = 1:3, S = S, FUN = rowVars, na.rm = FALSE, tFUN = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowCollapse works", { .check_formals("rowCollapse") mg_res_def_1 <- rowCollapse(x = mat, idxs = 1) ms_res_def_1 <- matrixStats::rowCollapse(x = mat, idxs = 1) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_def_2 <- rowCollapse(x = mat, idxs = 2:3) ms_res_def_2 <- matrixStats::rowCollapse(x = mat, idxs = 2:3) expect_equal(mg_res_def_2, ms_res_def_2) mg_res_1 <- rowCollapse(x = mat, idxs = 1, rows = NULL, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::rowCollapse(x = mat, idxs = 1, rows = NULL, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowCollapse(x = mat, idxs = 2:3, rows = 1:3, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::rowCollapse(x = mat, idxs = 2:3, rows = 1:3, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowCounts works", { .check_formals("rowCounts") mg_res_def_1 <- rowCounts(x = mat) ms_res_def_1 <- matrixStats::rowCounts(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowCounts(x = mat, rows = NULL, cols = NULL, value = TRUE, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::rowCounts(x = mat, rows = NULL, cols = NULL, value = TRUE, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowCounts(x = mat, rows = 1:3, cols = 2, value = FALSE, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::rowCounts(x = mat, rows = 1:3, cols = 2, value = FALSE, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) mg_res_3 <- rowCounts(x = mat, rows = NULL, cols = NULL, value = 0, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_3 <- matrixStats::rowCounts(x = mat, rows = NULL, cols = NULL, value = 0, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_3, ms_res_3) }) test_that("rowCummaxs works", { .check_formals("rowCummaxs") mg_res_def_1 <- rowCummaxs(x = mat) ms_res_def_1 <- matrixStats::rowCummaxs(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowCummaxs(x = mat, rows = NULL, cols = NULL, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::rowCummaxs(x = mat, rows = NULL, cols = NULL, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowCummaxs(x = mat, rows = 1:3, cols = 2, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::rowCummaxs(x = mat, rows = 1:3, cols = 2, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowCummins works", { .check_formals("rowCummins") mg_res_def_1 <- rowCummins(x = mat) ms_res_def_1 <- matrixStats::rowCummins(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowCummins(x = mat, rows = NULL, cols = NULL, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::rowCummins(x = mat, rows = NULL, cols = NULL, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowCummins(x = mat, rows = 1:3, cols = 2, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::rowCummins(x = mat, rows = 1:3, cols = 2, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowCumprods works", { .check_formals("rowCumprods") mg_res_def_1 <- rowCumprods(x = mat) ms_res_def_1 <- matrixStats::rowCumprods(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowCumprods(x = mat, rows = NULL, cols = NULL, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::rowCumprods(x = mat, rows = NULL, cols = NULL, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowCumprods(x = mat, rows = 1:3, cols = 2, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::rowCumprods(x = mat, rows = 1:3, cols = 2, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowCumsums works", { .check_formals("rowCumsums") mg_res_def_1 <- rowCumsums(x = mat) ms_res_def_1 <- matrixStats::rowCumsums(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowCumsums(x = mat, rows = NULL, cols = NULL, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::rowCumsums(x = mat, rows = NULL, cols = NULL, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowCumsums(x = mat, rows = 1:3, cols = 2, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::rowCumsums(x = mat, rows = 1:3, cols = 2, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowDiffs works", { .check_formals("rowDiffs") mg_res_def_1 <- rowDiffs(x = mat) ms_res_def_1 <- matrixStats::rowDiffs(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowDiffs(x = mat, rows = NULL, cols = NULL, lag = 1, differences = 1, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::rowDiffs(x = mat, rows = NULL, cols = NULL, lag = 1, differences = 1, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowDiffs(x = mat, rows = 1:3, cols = 2, lag = 3, differences = 2, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::rowDiffs(x = mat, rows = 1:3, cols = 2, lag = 3, differences = 2, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowIQRDiffs works", { .check_formals("rowIQRDiffs") mg_res_def_1 <- rowIQRDiffs(x = mat) ms_res_def_1 <- matrixStats::rowIQRDiffs(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowIQRDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0, useNames = TRUE) ms_res_1 <- matrixStats::rowIQRDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0, useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowIQRDiffs(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, diff = 2, trim = 0.333333333333333, useNames = FALSE) ms_res_2 <- matrixStats::rowIQRDiffs(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, diff = 2, trim = 0.333333333333333, useNames = FALSE) expect_equal(mg_res_2, ms_res_2) mg_res_3 <- rowIQRDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0.5, useNames = TRUE) ms_res_3 <- matrixStats::rowIQRDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0.5, useNames = TRUE) expect_equal(mg_res_3, ms_res_3) }) test_that("rowIQRs works", { .check_formals("rowIQRs") mg_res_def_1 <- rowIQRs(x = mat) ms_res_def_1 <- matrixStats::rowIQRs(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowIQRs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, useNames = TRUE) ms_res_1 <- matrixStats::rowIQRs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowIQRs(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, useNames = FALSE) ms_res_2 <- matrixStats::rowIQRs(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowLogSumExps works", { .check_formals("rowLogSumExps") mg_res_def_1 <- rowLogSumExps(lx = mat) ms_res_def_1 <- matrixStats::rowLogSumExps(lx = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowLogSumExps(lx = mat, rows = NULL, cols = NULL, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::rowLogSumExps(lx = mat, rows = NULL, cols = NULL, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowLogSumExps(lx = mat, rows = 1:3, cols = 2, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::rowLogSumExps(lx = mat, rows = 1:3, cols = 2, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowMadDiffs works", { .check_formals("rowMadDiffs") mg_res_def_1 <- rowMadDiffs(x = mat) ms_res_def_1 <- matrixStats::rowMadDiffs(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowMadDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0, useNames = TRUE) ms_res_1 <- matrixStats::rowMadDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0, useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowMadDiffs(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, diff = 2, trim = 0.333333333333333, useNames = FALSE) ms_res_2 <- matrixStats::rowMadDiffs(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, diff = 2, trim = 0.333333333333333, useNames = FALSE) expect_equal(mg_res_2, ms_res_2) mg_res_3 <- rowMadDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0.5, useNames = TRUE) ms_res_3 <- matrixStats::rowMadDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0.5, useNames = TRUE) expect_equal(mg_res_3, ms_res_3) }) test_that("rowMads works", { .check_formals("rowMads") mg_res_def_1 <- rowMads(x = mat) ms_res_def_1 <- matrixStats::rowMads(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowMads(x = mat, rows = NULL, cols = NULL, center = rowMeans2(mat, na.rm=TRUE), constant = 1.4826, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::rowMads(x = mat, rows = NULL, cols = NULL, center = rowMeans2(mat, na.rm=TRUE), constant = 1.4826, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowMads(x = mat, rows = 1:3, cols = 2, center = NULL, constant = 5, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::rowMads(x = mat, rows = 1:3, cols = 2, center = NULL, constant = 5, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowMaxs works", { .check_formals("rowMaxs") mg_res_def_1 <- rowMaxs(x = mat) ms_res_def_1 <- matrixStats::rowMaxs(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowMaxs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::rowMaxs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowMaxs(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::rowMaxs(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowMeans2 works", { .check_formals("rowMeans2") mg_res_def_1 <- rowMeans2(x = mat) ms_res_def_1 <- matrixStats::rowMeans2(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowMeans2(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, refine = , dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::rowMeans2(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, refine = , dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowMeans2(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, refine = , dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::rowMeans2(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, refine = , dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowMedians works", { .check_formals("rowMedians") mg_res_def_1 <- rowMedians(x = mat) ms_res_def_1 <- matrixStats::rowMedians(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowMedians(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::rowMedians(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowMedians(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::rowMedians(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowMins works", { .check_formals("rowMins") mg_res_def_1 <- rowMins(x = mat) ms_res_def_1 <- matrixStats::rowMins(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowMins(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::rowMins(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowMins(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::rowMins(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowOrderStats works", { .check_formals("rowOrderStats") mat[is.na(mat)] <- 4.1 mg_res_def_1 <- rowOrderStats(x = mat, which = 2) ms_res_def_1 <- matrixStats::rowOrderStats(x = mat, which = 2) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_def_2 <- rowOrderStats(x = mat, which = 1) ms_res_def_2 <- matrixStats::rowOrderStats(x = mat, which = 1) expect_equal(mg_res_def_2, ms_res_def_2) mg_res_1 <- rowOrderStats(x = mat, rows = NULL, cols = NULL, which = 2, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::rowOrderStats(x = mat, rows = NULL, cols = NULL, which = 2, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowOrderStats(x = mat, rows = 1:3, cols = 2, which = 1, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::rowOrderStats(x = mat, rows = 1:3, cols = 2, which = 1, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowProds works", { .check_formals("rowProds") mg_res_def_1 <- rowProds(x = mat) ms_res_def_1 <- matrixStats::rowProds(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowProds(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, method = 'direct', useNames = TRUE) ms_res_1 <- matrixStats::rowProds(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, method = 'direct', useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowProds(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, method = 'expSumLog', useNames = FALSE) ms_res_2 <- matrixStats::rowProds(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, method = 'expSumLog', useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowQuantiles works", { .check_formals("rowQuantiles") mg_res_def_1 <- rowQuantiles(x = mat) ms_res_def_1 <- matrixStats::rowQuantiles(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowQuantiles(x = mat, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = TRUE, type = 7, digits = 7, useNames = TRUE, drop = TRUE) ms_res_1 <- matrixStats::rowQuantiles(x = mat, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1, by = 0.25), na.rm = TRUE, type = 7, digits = 7, useNames = TRUE, drop = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowQuantiles(x = mat, rows = 1:3, cols = 2, probs = 0.1, na.rm = FALSE, type = 3, digits = 7, useNames = FALSE, drop = FALSE) ms_res_2 <- matrixStats::rowQuantiles(x = mat, rows = 1:3, cols = 2, probs = 0.1, na.rm = FALSE, type = 3, digits = 7, useNames = FALSE, drop = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowRanges works", { .check_formals("rowRanges") mg_res_def_1 <- rowRanges(x = mat) ms_res_def_1 <- matrixStats::rowRanges(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowRanges(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::rowRanges(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowRanges(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::rowRanges(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowRanks works", { .check_formals("rowRanks") mg_res_def_1 <- rowRanks(x = mat) ms_res_def_1 <- matrixStats::rowRanks(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowRanks(x = mat, rows = NULL, cols = NULL, ties.method = 'max', dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::rowRanks(x = mat, rows = NULL, cols = NULL, ties.method = 'max', dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowRanks(x = mat, rows = 1:3, cols = 2, ties.method = 'first', dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::rowRanks(x = mat, rows = 1:3, cols = 2, ties.method = 'first', dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) mg_res_3 <- rowRanks(x = mat, rows = NULL, cols = NULL, ties.method = 'dense', dim. = dim(mat), useNames = TRUE) ms_res_3 <- matrixStats::rowRanks(x = mat, rows = NULL, cols = NULL, ties.method = 'dense', dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_3, ms_res_3) }) test_that("rowSdDiffs works", { .check_formals("rowSdDiffs") mg_res_def_1 <- rowSdDiffs(x = mat) ms_res_def_1 <- matrixStats::rowSdDiffs(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowSdDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0, useNames = TRUE) ms_res_1 <- matrixStats::rowSdDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0, useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowSdDiffs(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, diff = 2, trim = 0.333333333333333, useNames = FALSE) ms_res_2 <- matrixStats::rowSdDiffs(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, diff = 2, trim = 0.333333333333333, useNames = FALSE) expect_equal(mg_res_2, ms_res_2) mg_res_3 <- rowSdDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0.5, useNames = TRUE) ms_res_3 <- matrixStats::rowSdDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0.5, useNames = TRUE) expect_equal(mg_res_3, ms_res_3) }) test_that("rowSds works", { .check_formals("rowSds") mg_res_def_1 <- rowSds(x = mat) ms_res_def_1 <- matrixStats::rowSds(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowSds(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, refine = , center = rowMeans2(mat, na.rm=TRUE), dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::rowSds(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, refine = , center = rowMeans2(mat, na.rm=TRUE), dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowSds(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, refine = , center = NULL, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::rowSds(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, refine = , center = NULL, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowSums2 works", { .check_formals("rowSums2") mg_res_def_1 <- rowSums2(x = mat) ms_res_def_1 <- matrixStats::rowSums2(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowSums2(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::rowSums2(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowSums2(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::rowSums2(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowTabulates works", { .check_formals("rowTabulates") mat <- array(suppressWarnings(as.integer(mat)), dim(mat)) mg_res_def_1 <- rowTabulates(x = mat) ms_res_def_1 <- matrixStats::rowTabulates(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowTabulates(x = mat, rows = NULL, cols = NULL, values = 0, useNames = TRUE) ms_res_1 <- matrixStats::rowTabulates(x = mat, rows = NULL, cols = NULL, values = 0, useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowTabulates(x = mat, rows = 1:3, cols = 2, values = c(0, 1), useNames = FALSE) ms_res_2 <- matrixStats::rowTabulates(x = mat, rows = 1:3, cols = 2, values = c(0, 1), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowVarDiffs works", { .check_formals("rowVarDiffs") mg_res_def_1 <- rowVarDiffs(x = mat) ms_res_def_1 <- matrixStats::rowVarDiffs(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowVarDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0, useNames = TRUE) ms_res_1 <- matrixStats::rowVarDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0, useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowVarDiffs(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, diff = 2, trim = 0.333333333333333, useNames = FALSE) ms_res_2 <- matrixStats::rowVarDiffs(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, diff = 2, trim = 0.333333333333333, useNames = FALSE) expect_equal(mg_res_2, ms_res_2) mg_res_3 <- rowVarDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0.5, useNames = TRUE) ms_res_3 <- matrixStats::rowVarDiffs(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, diff = 1, trim = 0.5, useNames = TRUE) expect_equal(mg_res_3, ms_res_3) }) test_that("rowVars works", { .check_formals("rowVars") mg_res_def_1 <- rowVars(x = mat) ms_res_def_1 <- matrixStats::rowVars(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowVars(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, refine = , center = rowMeans2(mat, na.rm=TRUE), dim. = dim(mat), useNames = TRUE) ms_res_1 <- matrixStats::rowVars(x = mat, rows = NULL, cols = NULL, na.rm = TRUE, refine = , center = rowMeans2(mat, na.rm=TRUE), dim. = dim(mat), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowVars(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, refine = , center = NULL, dim. = c(12L, 8L), useNames = FALSE) ms_res_2 <- matrixStats::rowVars(x = mat, rows = 1:3, cols = 2, na.rm = FALSE, refine = , center = NULL, dim. = c(12L, 8L), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowWeightedMads works", { .check_formals("rowWeightedMads") mat <- array(mat, dim(t(mat))) mg_res_def_1 <- rowWeightedMads(x = mat) ms_res_def_1 <- matrixStats::rowWeightedMads(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowWeightedMads(x = mat, w = 1:16, rows = NULL, cols = NULL, na.rm = TRUE, constant = 1.4826, center = rowMeans2(mat, na.rm=TRUE), useNames = TRUE) ms_res_1 <- matrixStats::rowWeightedMads(x = mat, w = 1:16, rows = NULL, cols = NULL, na.rm = TRUE, constant = 1.4826, center = rowMeans2(mat, na.rm=TRUE), useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowWeightedMads(x = mat, w = NULL, rows = 1:3, cols = 2, na.rm = FALSE, constant = 5, center = rep(6, nrow(mat)), useNames = FALSE) ms_res_2 <- matrixStats::rowWeightedMads(x = mat, w = NULL, rows = 1:3, cols = 2, na.rm = FALSE, constant = 5, center = rep(6, nrow(mat)), useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowWeightedMeans works", { .check_formals("rowWeightedMeans") mat <- array(mat, dim(t(mat))) mg_res_def_1 <- rowWeightedMeans(x = mat) ms_res_def_1 <- matrixStats::rowWeightedMeans(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowWeightedMeans(x = mat, w = 1:16, rows = NULL, cols = NULL, na.rm = TRUE, useNames = TRUE) ms_res_1 <- matrixStats::rowWeightedMeans(x = mat, w = 1:16, rows = NULL, cols = NULL, na.rm = TRUE, useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowWeightedMeans(x = mat, w = NULL, rows = 1:3, cols = 2, na.rm = FALSE, useNames = FALSE) ms_res_2 <- matrixStats::rowWeightedMeans(x = mat, w = NULL, rows = 1:3, cols = 2, na.rm = FALSE, useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowWeightedMedians works", { .check_formals("rowWeightedMedians") mat <- array(mat, dim(t(mat))) mg_res_def_1 <- rowWeightedMedians(x = mat) ms_res_def_1 <- matrixStats::rowWeightedMedians(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowWeightedMedians(x = mat, w = 1:16, rows = NULL, cols = NULL, na.rm = TRUE, useNames = TRUE) ms_res_1 <- matrixStats::rowWeightedMedians(x = mat, w = 1:16, rows = NULL, cols = NULL, na.rm = TRUE, useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowWeightedMedians(x = mat, w = NULL, rows = 1:3, cols = 2, na.rm = FALSE, useNames = FALSE) ms_res_2 <- matrixStats::rowWeightedMedians(x = mat, w = NULL, rows = 1:3, cols = 2, na.rm = FALSE, useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowWeightedSds works", { .check_formals("rowWeightedSds") mat <- array(mat, dim(t(mat))) mg_res_def_1 <- rowWeightedSds(x = mat) ms_res_def_1 <- matrixStats::rowWeightedSds(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowWeightedSds(x = mat, w = 1:16, rows = NULL, cols = NULL, na.rm = TRUE, useNames = TRUE) ms_res_1 <- matrixStats::rowWeightedSds(x = mat, w = 1:16, rows = NULL, cols = NULL, na.rm = TRUE, useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowWeightedSds(x = mat, w = NULL, rows = 1:3, cols = 2, na.rm = FALSE, useNames = FALSE) ms_res_2 <- matrixStats::rowWeightedSds(x = mat, w = NULL, rows = 1:3, cols = 2, na.rm = FALSE, useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) test_that("rowWeightedVars works", { .check_formals("rowWeightedVars") mat <- array(mat, dim(t(mat))) mg_res_def_1 <- rowWeightedVars(x = mat) ms_res_def_1 <- matrixStats::rowWeightedVars(x = mat) expect_equal(mg_res_def_1, ms_res_def_1) mg_res_1 <- rowWeightedVars(x = mat, w = 1:16, rows = NULL, cols = NULL, na.rm = TRUE, useNames = TRUE) ms_res_1 <- matrixStats::rowWeightedVars(x = mat, w = 1:16, rows = NULL, cols = NULL, na.rm = TRUE, useNames = TRUE) expect_equal(mg_res_1, ms_res_1) mg_res_2 <- rowWeightedVars(x = mat, w = NULL, rows = 1:3, cols = 2, na.rm = FALSE, useNames = FALSE) ms_res_2 <- matrixStats::rowWeightedVars(x = mat, w = NULL, rows = 1:3, cols = 2, na.rm = FALSE, useNames = FALSE) expect_equal(mg_res_2, ms_res_2) }) MatrixGenerics/tests/testthat/test-dynamic_implementation_loading.R0000644000175200017520000000117314710235307027054 0ustar00biocbuildbiocbuild test_that("sparse matrices trigger loading of sparseMatrixStats", { if (requireNamespace("Matrix", quietly = TRUE)) { # Make a matrix with different features mat <- matrix(rnorm(16 * 6), nrow = 16, ncol = 6) sp_mat <- as(mat, "dgCMatrix") expect_equal(colLogSumExps(sp_mat), colLogSumExps(mat)) } }) test_that("sparse matrices trigger loading of sparseMatrixStats", { if (requireNamespace("Matrix", quietly = TRUE)) { # Make a matrix with different features mat <- matrix(rnorm(16 * 6), nrow = 16, ncol = 6) sp_mat <- as(mat, "dgCMatrix") expect_equal(colVars(sp_mat), colVars(mat)) } })