inverse cell frequency: max

idf_m(expr, features = NULL, thres = 0)

Arguments

expr

a matrix, features in row and cells in column

features

vector, feature names or indexes to compute

thres

numeric, cell only counts when expr > threshold, default 0

Value

a matrix of inverse cell frequency score for each feature

Details

$$\mathbf{IDF_{i,j}} = log(\frac{max_{\{i^{'}\in j\}}(n_{i^{'}})}{n_i+1})$$ where \(i\) is the feature \(i\) and \(i^{'}\) is the feature except \(i\), \(n_i\) is the number of cells containing feature i, and \(n_{i^{'}}\) is the number of cells containing feature \(i^{'}\).

Examples

data <- matrix(rpois(100, 2), 10, dimnames = list(1:10))
smartid:::idf_m(data)
#>           [,1]        [,2]        [,3]        [,4]        [,5]        [,6]
#> 1  -0.09531018 -0.09531018 -0.09531018 -0.09531018 -0.09531018 -0.09531018
#> 2   0.22314355  0.22314355  0.22314355  0.22314355  0.22314355  0.22314355
#> 3   0.10536052  0.10536052  0.10536052  0.10536052  0.10536052  0.10536052
#> 4   0.00000000  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000
#> 5   0.22314355  0.22314355  0.22314355  0.22314355  0.22314355  0.22314355
#> 6  -0.09531018 -0.09531018 -0.09531018 -0.09531018 -0.09531018 -0.09531018
#> 7   0.00000000  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000
#> 8   0.10536052  0.10536052  0.10536052  0.10536052  0.10536052  0.10536052
#> 9   0.35667494  0.35667494  0.35667494  0.35667494  0.35667494  0.35667494
#> 10 -0.09531018 -0.09531018 -0.09531018 -0.09531018 -0.09531018 -0.09531018
#>           [,7]        [,8]        [,9]       [,10]
#> 1  -0.09531018 -0.09531018 -0.09531018 -0.09531018
#> 2   0.22314355  0.22314355  0.22314355  0.22314355
#> 3   0.10536052  0.10536052  0.10536052  0.10536052
#> 4   0.00000000  0.00000000  0.00000000  0.00000000
#> 5   0.22314355  0.22314355  0.22314355  0.22314355
#> 6  -0.09531018 -0.09531018 -0.09531018 -0.09531018
#> 7   0.00000000  0.00000000  0.00000000  0.00000000
#> 8   0.10536052  0.10536052  0.10536052  0.10536052
#> 9   0.35667494  0.35667494  0.35667494  0.35667494
#> 10 -0.09531018 -0.09531018 -0.09531018 -0.09531018