cosineNorm {scran} | R Documentation |
Perform cosine-normalization on the column vectors of an expression matrix.
cosineNorm(X, mode=c("matrix", "all", "l2norm"))
X |
A gene expression matrix with cells as columns and genes as rows. |
mode |
A string specifying the output to be returned. |
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.
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.
Aaron Lun
A <- matrix(rnorm(1000), nrow=10) str(cosineNorm(A)) str(cosineNorm(A, mode="l2norm"))