This function computes the leverage scores for a given object It uses the concept of sketching and random projections. The function provides an approximation to the leverage scores using a scalable method suitable for large matrices.

LeverageScore(object, ...)

# S3 method for default
LeverageScore(
  object,
  nsketch = 5000L,
  ndims = NULL,
  method = CountSketch,
  eps = 0.5,
  seed = 123L,
  verbose = TRUE,
  ...
)

# S3 method for StdAssay
LeverageScore(
  object,
  nsketch = 5000L,
  ndims = NULL,
  method = CountSketch,
  vf.method = NULL,
  layer = "data",
  eps = 0.5,
  seed = 123L,
  verbose = TRUE,
  ...
)

# S3 method for Assay
LeverageScore(
  object,
  nsketch = 5000L,
  ndims = NULL,
  method = CountSketch,
  vf.method = NULL,
  layer = "data",
  eps = 0.5,
  seed = 123L,
  verbose = TRUE,
  ...
)

# S3 method for Seurat
LeverageScore(
  object,
  assay = NULL,
  nsketch = 5000L,
  ndims = NULL,
  var.name = "leverage.score",
  over.write = FALSE,
  method = CountSketch,
  vf.method = NULL,
  layer = "data",
  eps = 0.5,
  seed = 123L,
  verbose = TRUE,
  ...
)

Arguments

object

A matrix-like object

...

Arguments passed to other methods

nsketch

A positive integer. The number of sketches to be used in the approximation. Default is 5000.

ndims

A positive integer or NULL. The number of dimensions to use. If NULL, the number of dimensions will default to the number of columns in the object.

method

The sketching method to use, defaults to CountSketch.

eps

A numeric. The error tolerance for the approximation in Johnson–Lindenstrauss embeddings, defaults to 0.5.

seed

A positive integer. The seed for the random number generator, defaults to 123.

verbose

Print progress and diagnostic messages

vf.method

VariableFeatures method

layer

layer to use

assay

assay to use

var.name

name of slot to store leverage scores

over.write

whether to overwrite slot that currently stores leverage scores. Defaults to FALSE, in which case the 'var.name' is modified if it already exists in the object

References

Clarkson, K. L. & Woodruff, D. P. Low-rank approximation and regression in input sparsity time. JACM 63, 1–45 (2017). https://dl.acm.org/doi/10.1145/3019134;