PolyGenius
Contents

PolyGenius-backends

Persistence formats for PolyGenius objects

savePolyGenius() and loadPolyGenius() write and read one kind of file: a saveRDS() of a version-stamped plain payload, suffix .pgd, whose class field is what the load side dispatches on. Five classes persist this way -- PolyGeniusStudy, PGSLibrary, PGS, PolyGeniusAssociation and PolyGeniusEvaluation -- and this topic collects what holds across all five, so each class's own page need not restate it.

Details

Every class is rebuilt on load through its own real constructor. No live R6 object is ever serialized: doing so writes each method's body verbatim while recording its namespace parent by name, so a later build reads back the old bodies bound to the new namespace. Saving aborts rather than write a payload with a function or environment reachable from it. A file is self-contained and portable -- it never points into a resource store, and nothing about a loaded object refers back to the file it came from.

What a file carries, and what it drops

A model library round-trips in full: the variant dictionary's identities, every weight column, the registry, both column planes, the attached annotation sources and the study-invariant model-pair definitions. The dictionary holds identity alone, so a rebuilt one is complete once its identities are back. Genotypes are stored as pointers, never as genotype data: each GenotypeSource's name, path, files, format, build, extra fields and full sample table (FID, IID and the working-set flag). A load rebuilds each source from that record without touching its files or PLINK, so a study whose genotype files are not on this machine still loads and subsets. Only a method that reads genotypes fails, when it is called. loadPolyGenius(path, genotypes = ) points a fileset at a new directory. A loaded PolyGeniusStudy keeps the provenance record it was saved with, so provenance(study)$version reports the version that made the study; the file's own package.version records what wrote the file.

Loading

A load reads and validates the whole payload before it returns, so a corrupt or truncated file surfaces at the load call rather than on first access, and the returned object is fully resident in memory.

Narrowing

A PolyGeniusStudy, PGSLibrary or PGS writes exactly the variant identities its retained models reference. A model-subset object therefore carries no dictionary row its own models do not use, and $fingerprint on the loaded object is a fresh computation over the loaded content rather than a copy of the original backbone's value.

See Also