Normalize count data to relative counts per cell by dividing by the total per cell. Optionally use a scale factor, e.g. for counts per million (CPM) use scale.factor = 1e6.

RelativeCounts(data, scale.factor = 1, verbose = TRUE)

Arguments

data

Matrix with the raw count data

scale.factor

Scale the result. Default is 1

verbose

Print progress

Value

Returns a matrix with the relative counts

Examples

mat <- matrix(data = rbinom(n = 25, size = 5, prob = 0.2), nrow = 5)
mat
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    0    2    0    1    2
#> [2,]    1    3    0    1    0
#> [3,]    1    1    1    3    1
#> [4,]    2    1    1    1    0
#> [5,]    0    0    2    2    0
mat_norm <- RelativeCounts(data = mat)
mat_norm
#> 5 x 5 sparse Matrix of class "dgCMatrix"
#>                                         
#> [1,] .    0.2857143 .    0.125 0.6666667
#> [2,] 0.25 0.4285714 .    0.125 .        
#> [3,] 0.25 0.1428571 0.25 0.375 0.3333333
#> [4,] 0.50 0.1428571 0.25 0.125 .        
#> [5,] .    .         0.50 0.250 .