
Identify HVGs
find_hvg_sc.RdThis is a helper function to identify highly variable genes for SingleCells
(using the Rust-based streaming of data) or MetaCells.
Small cell selections (up to 10% of the stored cells and at most 100k
cells, e.g. most SingleCellsSubset objects) are read from the cell-major
file into memory rather than sweeping the whole gene-major file, which makes
the cost follow the selection instead of the store.
Usage
find_hvg_sc(
object,
hvg_no = 2000L,
hvg_params = params_sc_hvg(),
streaming = NULL,
.verbose = TRUE
)Arguments
- object
SingleCells,MetaCells(or potentially other) class.- hvg_no
Integer. Number of highly variable genes to include. Defaults to
2000L.- hvg_params
List, see
params_sc_hvg(). This list containsmethod - Which method to use. One of
c("vst", "meanvarbin", "dispersion", "scran", "residual")loess_span - The span for the loess function to standardise the variance (
"vst"), or of the lowess trend ("scran")num_bin - Integer. Not yet implemented.
bin_method - String. One of
c("equal_width", "equal_freq"). Not implemented yet.mean_filter, min_mean, transform, use_min_width, min_width, min_window_count - The
"scran"trend parameters, seeparams_hvg_scran_defaults()
- streaming
Optional Boolean. Shall the data be streamed in. Useful for larger data sets where you wish to avoid loading in the whole data. If
NULL, will automatically detect. Not used forMetaCells.- .verbose
Boolean or integer. Controls verbosity and returns run times.
FALSE-> quiet,TRUEor1L-> normal verbosity,2L-> detailed verbosity.
Value
It will add the per-gene HVG statistics to the var table: mean,
var, var_exp and var_std for "vst"; mean, dispersion,
dispersion_scaled and bin for "meanvarbin" and "dispersion";
scran_mean, scran_var, scran_fitted and scran_residual (log2 scale)
for "scran".
Examples
# the twenty most variable genes by the vst method
sc <- demo_single_cells(prepped = FALSE)
sc <- find_hvg_sc(sc, hvg_no = 20L, .verbose = FALSE)
length(get_hvg(sc))
#> [1] 20
unlink(sc@dir_data, recursive = TRUE, force = TRUE)