Skip to contents

[Experimental] Calculates highly variable genes for MetaCells or more generally speaking sparse data. This is happening in-memory compared to the (usually much) larger single cell data sets. "meanvarbin" and "dispersion" compute the same statistics; they differ only in how the R side selects from them.

Usage

rs_mc_hvg(
  sparse_data,
  hvg_method,
  loess_span,
  binning,
  n_bins,
  clip_max,
  scran_params,
  verbose
)

Arguments

sparse_data

A named list that needs to have data, indptr, indices, nrow, ncol and cs_type. Shape is (metacells, genes). Pass raw counts for "vst" and log1p-normalised counts otherwise.

hvg_method

String. Which HVG detection method to use. Options are c("vst", "meanvarbin", "dispersion", "scran").

loess_span

Numeric. The span parameter for the loess function ("vst") or the lowess trend ("scran").

binning

String. The binning strategy for the meanvarbin and dispersion methods. One of c("equal_width", "equal_freq").

n_bins

Integer. Number of bins for the meanvarbin and dispersion methods.

clip_max

Optional clipping number. Defaults to sqrt(no_cells) if not provided (only used for "vst").

scran_params

List. Trend parameters for "scran", see params_hvg_scran_defaults(). Missing elements fall back to the scrapper defaults. The span is taken from loess_span.

verbose

Integer. 0L - quiet; 1L - normal verbosity; 2L - detailed verbosity.

Value

A list with the HVG statistics. If hvg_method == "vst":

  • mean - The average expression of the gene.

  • var - The variance of the gene.

  • var_exp - The expected variance of the gene.

  • var_std - The standardised variance of the gene.

If hvg_method == "scran", all on the log2 scale:

  • scran_mean - The mean log-expression of the gene.

  • scran_var - The variance of the log-expression of the gene.

  • scran_fitted - The variance the trend expects at the gene's mean.

  • scran_residual - scran_var - scran_fitted. Genes are ranked on this.

For "meanvarbin" and "dispersion":

  • mean - The average expression of the gene.

  • dispersion - The dispersion of the gene.

  • dispersion_scaled - The scaled dispersion per bin per gene.

  • bin - The bin of the gene.