
Identify HVGs without mutating object state
get_hvg_data_sc.RdLike find_hvg_sc() but does not mutate object. Returns a data.table
with per-gene HVG statistics plus is_hvg/hvg_rank for the top hvg_no
genes. Useful for computing HVGs on a subset of cells (e.g. a specific
cell type) for downstream methods like NMF, without overwriting the HVGs
stored on the object.
Usage
get_hvg_data_sc(
object,
cell_ids = NULL,
hvg_no = 3000L,
hvg_params = params_sc_hvg(),
streaming = NULL,
.verbose = TRUE
)Arguments
- object
SingleCellsorMetaCellsclass.- cell_ids
Optional character. Cell ids (or meta cell ids) to restrict the HVG calculation to. If
NULL, usesget_cells_to_keep()forSingleCellsand all meta cells forMetaCells.- hvg_no
Integer. Number of top HVGs to flag. Defaults to
3000L.- hvg_params
List, see
params_sc_hvg().- streaming
Optional Boolean. Stream the data. Ignored for
MetaCells.- .verbose
Boolean or integer. Verbosity.
Value
data.table with gene_idx, gene_id, the HVG statistics returned
by the Rust HVG function, an is_hvg boolean and an hvg_rank integer
(NA for non-HVGs).
Examples
# HVG statistics without touching the object
sc <- demo_single_cells(prepped = FALSE)
dt <- get_hvg_data_sc(sc, hvg_no = 20L, .verbose = FALSE)
head(dt[(is_hvg), c("gene_id", "hvg_rank")], 3)
#> gene_id hvg_rank
#> <char> <int>
#> 1: gene_04 20
#> 2: gene_05 3
#> 3: gene_07 19
unlink(sc@dir_data, recursive = TRUE, force = TRUE)