# normCounts: Normalise a counts matrix to the median library size In Oshlack/speckle: Statistical methods for analysing single cell RNA-seq data

 normCounts R Documentation

## Normalise a counts matrix to the median library size

### Description

This function takes a `DGEList` object or matrix of counts and normalises the counts to the median library size. This puts the normalised counts on a similar scale to the original counts.

### Usage

```normCounts(x, log = FALSE, prior.count = 0.5, lib.size = NULL)
```

### Arguments

 `x` a `DGEList` object or matrix of counts. `log` logical, indicates whether the output should be on the log2 scale or counts scale. Default is FALSE. `prior.count` The prior count to add if the data is log2 normalised. Default is a small count of 0.5. `lib.size` a vector of library sizes to be used during the normalisation step. Default is NULL and will be computed from the counts matrix.

### Details

If the input is a DGEList object, the normalisation factors in `norm.factors` are taken into account in the normalisation. The prior counts are added proportionally to the library size

### Value

a matrix of normalised counts

Belinda Phipson

### Examples

```# Simulate some data from a negative binomial distribution with mean equal
# to 100 and dispersion set to 1. Simulate 1000 genes and 6 samples.
y <- matrix(rnbinom(6000, mu = 100, size = 1), ncol = 6)

# Normalise the counts
norm.y <- normCounts(y)

# Return log2 normalised counts
lnorm.y <- normCounts(y, log=TRUE)

# Return log2 normalised counts with prior.count = 2
lnorm.y2 <- normCounts(y, log=TRUE, prior.count=2)

par(mfrow=c(1,2))
boxplot(norm.y, main="Normalised counts")
boxplot(lnorm.y, main="Log2-normalised counts")

```

Oshlack/speckle documentation built on Oct. 16, 2022, 9:39 a.m.