Contents
loadPolyGenius
Load a PolyGenius object saved by [savePolyGenius()](/reference/savepolygenius/)
Reads a .pgd file and rebuilds the object it holds through real constructors, never by
readRDS()-ing a live R6 object. The payload's own class field decides which constructors
run; see ?PolyGenius-backends for the concepts shared across the five supported kinds.
Usage
loadPolyGenius(path, genotypes = NULL)Arguments
| Argument | Description |
|---|---|
path | Character scalar. Path to a .pgd file written by [savePolyGenius()](/reference/savepolygenius/); the extension is checked case-insensitively. |
genotypes | Named character vector or NULL (default). Maps a fileset name, as in study$genotypes[[i]]$name, to the directory that now holds its files; file stems are unchanged. Filesets not named keep their recorded path. Valid only for a PolyGeniusStudy file. |
Value
The object the file holds: a PolyGeniusStudy, PGSLibrary, PGS,
PolyGeniusAssociation, or PolyGeniusEvaluation.
Details
Loading aborts when path does not end in .pgd, does not exist, is not a readable payload
this function recognizes, names a class this version does not know, or was written in a
different payload format version.
A study's genotype pointers are restored without reading the genotype files or resolving PLINK.
A study whose files are not on this machine therefore loads, subsets, and runs every analysis
that works from its scores and sample tables. A method that reads genotypes, such as
compute$scores(), aborts when called.
genotypes = moves filesets to a new directory. Each named fileset is rebuilt there through
GenotypeSource() with its recorded file stems, format, build and working set, so the files are
read once with PLINK. The load aborts when a name matches no fileset, when the file holds
anything other than a PolyGeniusStudy, when the directory or a file is missing, or when the
files do not hold exactly the recorded samples in the recorded order. The order matters because
the study's sample axis and samples table are row-aligned to it. FIDs are read from the new
files.
Examples
data2 <- loadPolyGenius("cohort1.pgd")
# The genotype files of fileset "cohort" were copied to a new directory.
data3 <- loadPolyGenius("cohort1.pgd", genotypes = c(cohort = "/new/dir"))