Get a normalized TFIDF matrix from peak-by-cell matrix from single cell profiles.

tfidf(bmat, mat_binary = TRUE, TF = TRUE, log_TF = TRUE, scale_factor = 1e+05)

Arguments

bmat

a sparse/dense matrix or dataframe indicating count matrix (peak-by-cell matrix).

mat_binary

a logic value to indicate if input bmat is spare matrix or not. bmat will be converted into a sparse matrix.

TF

a logic value to indicate if term frequency (TF) normalization is performed.

log_TF

a logic value to indicate if natural logarithm values of the TF are calculated and used.

scale_factor

a scale factor used to multiple the resulting TF-IDF matrix.

Value

a sparse matrix of normalized TFIDF matrix.

Examples

SE_pbmc5k <- example_data(name="pbmc5k_SE.rda")
peak_by_cell_mat <- SummarizedExperiment::assay(SE_pbmc5k)
#### Downsample to speed up example ####
peak_by_cell_mat <- peak_by_cell_mat[seq_len(500), seq_len(100)]
tfidf_mat <- tfidf(bmat=peak_by_cell_mat)
#> [info] binarize matrix
#> [info] calculate tf
#> [info] calculate idf
#> [info] fast log tf-idf