View source: R/sparse_matrix_functions.R
to_frac | R Documentation |
Divides the elements of a matrix by their corresponding row or column totals. This is useful, for example, when converting a gene expression count matrix to transcripts per million (TPM).
to_frac(mat, MARGIN = 2)
mat |
A matrix. May be sparse (i.e. of class |
MARGIN |
The subscript to apply over. Possible values are |
A matrix of the same size and class as mat
.
mat <- matrix(round(runif(100, max = 100)), 10, 10)
to_frac(mat)
to_frac(mat, MARGIN = 1)
mat[sample(1:100, 80)] <- 0
mat <- as(mat, 'dgCMatrix')
to_frac(mat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.