| ras_memory | R Documentation |
Detects the current machine's RAM and CPU configuration, computes per-stage peak memory estimates for the RAS pipeline, and issues a go / no-go verdict.
ras_memory(
n_total,
n_train,
n_holdout,
n_snps,
bytes_per_element = 8,
abort = FALSE
)
n_total |
Integer. Total number of samples (rows of |
n_train |
Integer. Number of training-split samples (typically
|
n_holdout |
Integer. Number of hold-out samples (rows of
|
n_snps |
Integer. Number of variants (columns of |
bytes_per_element |
Numeric. Bytes per matrix element. Default
|
abort |
Logical. If |
Peak memory is estimated for three pipeline stages:
compute_gwas_weightsHolds the full
geno matrix plus a small N \times 4 coefficient matrix.
Peak \approx geno_mb + coefmat_mb.
compute_pgs_matrixWorst-case holds two
copies of geno (R copy-on-modify triggered by
geno[is.na(geno)] <- 0) plus the output pgs.mat.
Peak \approx 2 * geno_mb + pgsmat_mb.
screen_forward_max_regionHolds
geno and pgs.mat simultaneously.
Peak \approx geno_mb + pgsmat_mb.
The overall estimated peak is the maximum across the three stages.
Available RAM is queried via wmic on Windows and
/proc/meminfo on Linux; the function degrades gracefully (prints a
caution message and returns can_proceed = TRUE) if the query fails.
The function prints a formatted report to the console and invisibly returns the numeric estimates for programmatic use.
Invisibly returns a named list with two elements:
memoryNamed numeric vector with elements
geno_mb, pgsmat_mb, coefmat_mb,
stage1_peak_mb, stage2_peak_mb, stage3_peak_mb,
overall_peak_mb, available_mb, total_mb.
systemNamed list with elements cores_physical,
cores_logical, r_version, platform, and
can_proceed (logical: TRUE if RAM is sufficient or
cannot be measured).
ras_scan, ras for the
functions whose memory use is being estimated.
release_memory to reclaim heap memory after each repetition.
## Check feasibility for 5,000 samples and 500,000 SNPs
ras_memory(
n_total = 5000,
n_train = 2500,
n_holdout = 2500,
n_snps = 500000
)
## Abort if memory is insufficient (wrapped in try() so the example runs)
try(ras_memory(
n_total = 100000,
n_train = 50000,
n_holdout = 50000,
n_snps = 1000000,
abort = TRUE
))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.