PolyGenius
Contents

workspace$setup

Install and resolve the external tools PolyGenius drives

Downloads, registers and resolves the tools the pipeline shells out to: PLINK2, GCTB, the PRS-CS Python environment and the bigsnpr R stack. Nothing here has to be run up front — any step that needs a tool resolves it through the same cache on demand — but install() makes the download explicit and check() shows what is already in place.

Usage

workspace$setup$install(...)

workspace$setup$status()

workspace$setup$check()

workspace$setup$get(name)

workspace$setup$print(...)

Arguments

ArgumentDescription
...For install(), the stacks to act on. An unnamed character argument (or character vector) names a stack to download; a named argument registers one already installed, taking the path to an executable file for plink and gctb, and a list with venv and/or source directories for prscs. An unknown stack name aborts, as does a named bigsnpr. For print(), unused.
nameOne of "plink", "gctb", "prscs". Stack for get() to resolve; only the first element is used, and an unknown name aborts.

Value

  • install(): NULL, invisibly. Called for the downloads and registrations described above; with no argument it does nothing.
  • status(): a data.frame with one row per stack and columns stack, status and detail. status is "ok", "partial" (a PRS-CS registration with only a venv or only a source), "missing" (a cached path no longer on disk) or "not installed", and detail is the resolved path or the call that would install it. Prints nothing and installs nothing.
  • check(): the same data.frame, invisibly, after printing one line per stack.
  • get(): for "plink" and "gctb", the character path to the binary; for "prscs", a named list of python (the venv interpreter) and source (the clone directory). Downloads or creates the stack first when it is not cached, so a first call can take minutes and needs the network.
  • print(): the setup object, invisibly. Called for check()'s console output.

Details

The four stack names are "plink", "gctb", "prscs" and "bigsnpr", matched case-insensitively. install() either downloads a stack (unnamed argument) or registers one already present on the machine (named argument); get() returns the resolved location of one, creating it first if it is absent; status() and check() report on all four and install nothing.

Everything except bigsnpr is cached under file.path(workspace$config$root, "setup.<stack>", "<id>"), so a repeated install() or get() reuses it rather than fetching again. A PLINK or GCTB binary deleted from the cache is detected on the next call and re-downloaded.

What install() fetches

install("plink") and install("gctb") download the platform-matched prebuilt binary named in the packaged manifest (inst/extdata/manifest.plink.csv, inst/extdata/manifest.gctb.csv), verify its SHA-256 when the manifest carries one, and copy the executable into the stack's cache directory. GCTB is published as a Linux x86_64 binary only; on macOS or ARM, compile it and register the result with install(gctb = "/path/to/gctb").

install("prscs") requires python3 3.8 or later on PATH. It creates a virtual environment in venv/ under the stack's cache directory, pip-installs numpy<2, scipy and h5py into it, installs the R package hdf5r if absent, and git-clones https://github.com/getian107/PRScs into source/ beside the venv.

install("bigsnpr") is the one stack not cached under root: it calls utils::install.packages() for whichever of bigsnpr, bigsparser and RhpcBLASctl are missing, installing them into .libPaths()[1]. It is also the one stack that cannot be registered by name.

Examples

# What is installed, as a table and as printed output
workspace$setup$status()
workspace$setup$check()


```r

# Download and cache PLINK2 under workspace$config$root
workspace$setup$install("plink")

# Register tools already present on this machine
workspace$setup$install(plink = "/usr/local/bin/plink2")
workspace$setup$install(prscs = list(venv = "~/prscs-venv", source = "~/PRScs"))

# Resolve a location, installing on demand
plink.binary <- workspace$setup$get("plink")
prscs <- workspace$setup$get("prscs")
prscs$python

See Also

workspace for the object this hangs off, and workspace$config$root for where the cache lives.

Aliases: workspace_setup, workspace$setup, workspace$setup$install, workspace$setup$status, workspace$setup$check, workspace$setup$get, workspace$setup$print