cosineNorm {scran} | R Documentation

## Cosine normalize

### Description

Perform cosine-normalization on the column vectors of an expression matrix.

### Usage

    cosineNorm(X, mode=c("matrix", "all", "l2norm"))

### Arguments

`X` | A gene expression matrix with cells as columns and genes as rows.
`mode` | A string specifying the output to be returned.

### Details

While the default is to directly return the cosine-normalized matrix, it may occasionally be desirable to obtain the L2 norm, e.g., to apply an equivalent normalization to other matrices. This can be achieved by setting `mode` accordingly.

### Value

If `mode="matrix"`, a double-precision matrix of the same dimensions as `X` is returned, containing cosine-normalized values.

If `mode="l2norm"`, a double-precision vector is returned containing the L2 norm for each cell.

If `mode="all"`, a named list is returned containing the fields `"matrix"` and `"l2norm"`, which are as described above.

### Author(s)

Aaron Lun

### See Also

`mnnCorrect`, `fastMNN`

### Examples

    A <- matrix(rnorm(1000), nrow=10)
    str(cosineNorm(A))
    str(cosineNorm(A, mode="l2norm"))

[Package scran version 1.10.2 Index]