Run term frequency inverse document frequency (TF-IDF) normalization on a matrix.

RunTFIDF(object, ...)

# Default S3 method
RunTFIDF(
  object,
  assay = NULL,
  method = 1,
  scale.factor = 10000,
  idf = NULL,
  verbose = TRUE,
  ...
)

# S3 method for class 'Assay'
RunTFIDF(
  object,
  assay = NULL,
  method = 1,
  scale.factor = 10000,
  idf = NULL,
  verbose = TRUE,
  ...
)

# S3 method for class 'StdAssay'
RunTFIDF(
  object,
  assay = NULL,
  method = 1,
  scale.factor = 10000,
  idf = NULL,
  verbose = TRUE,
  ...
)

# S3 method for class 'Seurat'
RunTFIDF(
  object,
  assay = NULL,
  method = 1,
  scale.factor = 10000,
  idf = NULL,
  verbose = TRUE,
  ...
)

Arguments

object

A Seurat object

...

Arguments passed to other methods

assay

Name of assay to use

method

Which TF-IDF implementation to use. Choice of:

  • 1: The TF-IDF implementation used by Stuart & Butler et al. 2019 (doi:10.1101/460147 ). This computes log(TF×IDF).

  • 2: The TF-IDF implementation used by Cusanovich & Hill et al. 2018 (doi:10.1016/j.cell.2018.06.052 ). This computes TF×(log(IDF)).

  • 3: The log-TF method used by Andrew Hill. This computes log(TF)×log(IDF).

  • 4: The 10x Genomics method (no TF normalization). This computes IDF.

scale.factor

Which scale factor to use. Default is 10000.

idf

A precomputed IDF vector to use. If NULL, compute based on the input data matrix.

verbose

Print progress

Value

Returns a Seurat object

Details

Four different TF-IDF methods are implemented. We recommend using method 1 (the default).

Examples

mat <- matrix(data = rbinom(n = 25, size = 5, prob = 0.2), nrow = 5)
RunTFIDF(object = mat)
#> Performing TF-IDF normalization
#> 5 x 5 sparse Matrix of class "dgCMatrix"
#>                                                  
#> [1,] .        8.047510 .        .        8.335112
#> [2,] .        6.949537 .        8.112028 8.335112
#> [3,] 8.335112 8.047510 7.642204 .        7.236979
#> [4,] 8.047510 7.759934 .        8.229778 6.949537
#> [5,] .        .        9.433564 .        .       
RunTFIDF(atac_small[['peaks']])
#> Performing TF-IDF normalization
#> ChromatinAssay data with 323 features for 100 cells
#> Variable features: 323 
#> Genome: hg19 
#> Annotation present: TRUE 
#> Motifs present: TRUE 
#> Fragment files: 0 
RunTFIDF(atac_small[['peaks']])
#> Performing TF-IDF normalization
#> ChromatinAssay data with 323 features for 100 cells
#> Variable features: 323 
#> Genome: hg19 
#> Annotation present: TRUE 
#> Motifs present: TRUE 
#> Fragment files: 0 
RunTFIDF(object = atac_small)
#> Performing TF-IDF normalization
#> An object of class Seurat 
#> 1323 features across 100 samples within 3 assays 
#> Active assay: peaks (323 features, 323 variable features)
#>  2 layers present: counts, data
#>  2 other assays present: bins, RNA
#>  2 dimensional reductions calculated: lsi, umap