R/adjust_library_size.R

Defines functions adjust_library_size

Documented in adjust_library_size

#' Adjust count matrix by library size
#' 
#' Simple tool for adjusting raw count matrix by total library size. Library
#' size is calculated as column sums and columns are scaled to the median total
#' library size.
#' 
#' @param x Read count matrix with genes in rows and samples in columns.
#' @returns Matrix of adjusted read counts
#' @importFrom stats median
#' @export

adjust_library_size <- function(x) {
  cs <- colSums(x)
  a <- cs / median(cs)
  t(t(x) / a)
}

Try the cellGeometry package in your browser

Any scripts or data that you put into this service are public.

cellGeometry documentation built on April 20, 2026, 1:06 a.m.