rebuildIndex: Rebuild the index

View source: R/rebuildIndices.R

rebuildIndexR Documentation

Rebuild the index

Description

Rebuild the index (or indices), typically after restarting the R session. This is because the indices are held in external memory and are not serialized correctly by R.

Usage

rebuildIndex(trained, num.threads = 1)

Arguments

trained

List containing the output of trainSingleR, possibly after some operations that invalidate the indices.

num.threads

Integer specifying the number of threads to use for training.

Value

trained is returned with valid indices. If it already had valid indices, this function is a no-op.

Author(s)

Aaron Lun

Examples

# Making up the training set.
ref <- .mockRefData()
ref <- scuttle::logNormCounts(ref)
trained <- trainSingleR(ref, ref$label)
trained$built # a valid address

# Saving and reloading the index.
tmp <- tempfile(fileext=".rds")
saveRDS(trained, file=tmp)
reloaded <- readRDS(tmp)
reloaded$built # not valid anymore

rebuilt <- rebuildIndex(reloaded)
rebuilt$built # back to validity


LTLA/SingleR documentation built on Feb. 28, 2024, 2:05 a.m.