From f870c30eac12582073850835ca4bb9597abcf01b Mon Sep 17 00:00:00 2001 From: Jeremy Miller Date: Thu, 2 Sep 2021 16:21:33 -0700 Subject: [PATCH] Allow for vector input into rowMedians --- R/markerGenesAndMapping.r | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/R/markerGenesAndMapping.r b/R/markerGenesAndMapping.r index a4759b7..f83847b 100644 --- a/R/markerGenesAndMapping.r +++ b/R/markerGenesAndMapping.r @@ -1774,3 +1774,19 @@ getBetaScore <- function(propExpr, scoreRank <- rank(-betaScore) scoreRank } + + +#' Calculate row medians +#' +#' This is a wrapper for matrixStats::rowMedians that doesn't crash if a vector is provided as input +#' +#' @param x a matrix or vector of values +#' +#' @return if the input is a matrix, return row medians. If a vector, it returns the inputted vector +#' +#' @export +rowMedians <- function(x,...) { + require(matrixStats) + if(is.matrix(x)) return(matrixStats::rowMedians(x,...)) + x +}