Skip to contents

Serializes the DLBCLone model list and its associated uwot UMAP object to disk. Optionally computes and stores reference embeddings to enable future integrity checks with DLBCLone_load_optimized().

Usage

DLBCLone_save_optimized(
  DLBCLone_model,
  base_path = "./",
  name_prefix = "DLBCLone",
  include_tests = FALSE,
  overwrite = FALSE
)

Arguments

DLBCLone_model

List. The model object to save. It must contain a trained UMAP model at $model created with uwot.

base_path

Character scalar. Directory to write output files. Defaults to "./".

name_prefix

Character scalar. Prefix for the saved files. Files will be named <name_prefix>_model.rds and <name_prefix>_umap.uwot. Defaults to "DLBCLone".

include_tests

Logical. If TRUE, compute and embed two reference embeddings (batch and iterative modes) from the training data and store them in the saved model list as embedding_batch and embedding_iterative. Defaults to FALSE.

overwrite

Logical. If FALSE (default), an error is thrown if either target file already exists. Set TRUE to replace existing files.

Value

Invisibly, the paths of the two written files (invisibly). Called for its side effect of writing .rds and .uwot files.

Details

The UMAP model is stored separately using uwot::save_uwot() and then removed from the list prior to writing the .rds, to avoid duplication. When include_tests = TRUE, the function calls make_and_annotate_umap() twice to create reproducible embeddings that can be verified later with check_integrity = TRUE in DLBCLone_load_optimized().

Examples

if (FALSE) { # \dontrun{
# Save a trained model; error if files exist
DLBCLone_save_optimized(
  DLBCLone_model = trained_model,
  base_path = "save_optimized/trial_folder",
  name_prefix = "test_A"
)
} # }
if (FALSE) { # \dontrun{
# Save with embedded test embeddings, overwriting if present
DLBCLone_save_optimized(
  DLBCLone_model = trained_model,
  base_path = "save_optimized/trial_folder",
  name_prefix = "test_A",
  include_tests = TRUE,
  overwrite = TRUE
)
} # }