View source: R/io_immundata_read.R
| read_immundata | R Documentation |
Reconstructs an ImmunData object from files previously saved to a directory
by write_immundata() or the internal saving step of read_repertoires().
It reads the annotations.parquet file for the main data and metadata.json
to retrieve the necessary receptor and repertoire schemas.
read_immundata(
path,
tag = NULL,
version = NULL,
prudence = "stingy",
verbose = TRUE
)
path |
Character(1). Path to the directory containing the saved
|
tag |
Character(1) or |
version |
Integer(1) or |
prudence |
Character(1). Controls strictness of type inference when
reading the Parquet file, passed to |
verbose |
Logical(1). If |
This function expects a directory structure created by write_immundata(),
containing at least:
annotations.parquet: The main annotation data table.
metadata.json: Contains package version, receptor/repertoire schema,
current snapshot_id, lineage events, and provenance paths.
The loading process involves:
Checking that the specified path is a directory and contains the
required annotations.parquet and metadata.json files.
Reading metadata.json using jsonlite::read_json().
Reading annotations.parquet using duckplyr::read_parquet_duckdb() with
the specified prudence level.
Extracting the receptor_schema and repertoire_schema from the loaded
metadata.
Instantiating a new ImmunData object using the loaded annotations data
and the receptor_schema.
If a non-empty repertoire_schema was found in the metadata, it calls
agg_repertoires() on the newly created object to recalculate and
attach repertoire-level information based on that schema.
A new ImmunData object reconstructed from the saved files. If
repertoire information was saved, it will be recalculated and included.
write_immundata() for saving ImmunData objects,
read_repertoires() for the primary data loading pipeline, ImmunData class,
agg_repertoires() for repertoire definition.
## Not run:
# Assume 'my_idata' is an ImmunData object created previously
# my_idata <- read_repertoires(...)
# Define a temporary directory for saving
save_dir <- tempfile("saved_immundata_")
# Save the ImmunData object
write_immundata(my_idata, save_dir)
# --- Later, in a new session or script ---
# Load the ImmunData object back from the directory
loaded_idata <- read_immundata(save_dir)
# Verify the loaded object
print(loaded_idata)
# compare_methods(my_idata$annotations, loaded_idata$annotations) # If available
# Clean up
unlink(save_dir, recursive = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.