| compute_pgs_matrix | R Documentation |
Multiplies each hold-out individual's genotype dosages by the per-SNP PGS weights to produce a matrix of weighted dosage contributions used in the forward scan.
compute_pgs_matrix(geno, this.leftout, pgs.weights)
geno |
Matrix of genotype dosages ( |
this.leftout |
Integer vector. Row indices of the hold-out split in
|
pgs.weights |
Numeric vector of length |
Missing genotype values (NA) in geno are imputed to zero
before computing the product. This is a simple mean-imputation equivalent
under a centred dosage scale and is sufficient for the forward scan, where
the primary goal is to aggregate regional signals rather than obtain
individual-level accuracy.
The caller's geno object is not modified: the
NA-replacement assignment triggers R's copy-on-modify semantics, so a
local copy of geno is made inside the function. Callers working with
very large genotype matrices should be aware that this temporarily doubles
the memory footprint of geno during the call; use
ras_memory to check feasibility before running.
A numeric matrix of dimensions
|\texttt{this.leftout}| \times N, where entry
[i, j] is the weighted dosage contribution of SNP j for
hold-out individual i (i.e., geno[this.leftout[i], j] *
pgs.weights[j]).
compute_gwas_weights for the step that produces
pgs.weights.
screen_forward_max_region for the step that consumes this
matrix.
ras_memory for pre-flight memory estimation.
set.seed(2)
geno <- matrix(sample(0:2, 50 * 20, replace = TRUE), nrow = 50, ncol = 20)
weights <- rnorm(20)
leftout <- 1:15
pgs_mat <- compute_pgs_matrix(geno, leftout, weights)
dim(pgs_mat) # 15 x 20
## Entry [i, j] equals geno[leftout[i], j] * weights[j]
stopifnot(pgs_mat[1, 1] == geno[leftout[1], 1] * weights[1])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.