View source: R/screening_original.R
| screen_forward_max_region_original | R Documentation |
This is the pure-R, in-memory implementation that RAS 1.0.x shipped under
the plain name. Since 1.1.0 the plain name (screen_forward_max_region) is the
compiled, disk-backed implementation; this function is kept for reference
and gives the same results.
Slides an expanding window across the genome, accumulating weighted
genotype contributions and testing association with the hold-out phenotype
at each position.
screen_forward_max_region_original(
geno,
pgs.mat,
this.df,
num_signals,
start.point = 1,
save.directory = tempdir(),
this.chrome = 1,
min_window_size = 5,
max_window_size = 100,
isSimulation = TRUE,
this.repetition = 1,
screening_round = 1,
isPlot = FALSE,
skip1 = 100,
skip2 = 5,
is_continuous,
covariate_formula = NULL,
scan_test = c("glm", "score"),
signal.starts = NULL,
signal.window.size = NULL
)
geno |
Matrix of genotype dosages ( |
pgs.mat |
Matrix of pre-computed per-variant PGS contributions
( |
this.df |
Data frame containing the hold-out phenotype in a column
named |
num_signals |
Integer. Number of true signals; used only for
simulation plots ( |
start.point |
Integer. Starting SNP index for the scan.
Default |
save.directory |
Character. Directory for optional PDF plots (only used
when |
this.chrome |
Integer. Chromosome number for non-simulation plot
filenames. Default |
min_window_size |
Integer. Minimum scan window half-size.
Default |
max_window_size |
Integer. Maximum scan window half-size.
Default |
isSimulation |
Logical. If |
this.repetition |
Integer. Repetition index used in plot filenames.
Default |
screening_round |
Integer. Number of forward screening rounds. Only a
single round is implemented; values other than |
isPlot |
Logical. If |
skip1 |
Integer. Step size for the primary SNP position grid.
Default |
skip2 |
Integer. Step size for growing the window within each grid
position. Default |
is_continuous |
Logical. If |
covariate_formula |
Character. Right-hand side covariates (without
the PGS term |
scan_test |
Character. Test used for the binary branch
( |
signal.starts |
Integer vector. True signal start positions for
simulation reference lines. Default |
signal.window.size |
Integer. Width of each true signal window for
simulation reference lines. Default |
At each grid position j \in \{1, 1 + \texttt{skip1}, \ldots, N\}
the function builds a polygenic score (PGS) by accumulating columns of
pgs.mat from a growing symmetric window
[j - w + 1,\; j + w - 1] for
w \in \{0, \texttt{min\_window\_size}, \ldots, \texttt{max\_window\_size}\}.
The accumulation is incremental: only the newly added columns are summed
at each step, avoiding redundant computation.
At window size w = 0, only column j of pgs.mat is
used (the single-SNP PGS). For each window size the PGS is tested
against phenotype2 via lm (continuous) or
glm(family = binomial()) (binary). The minimum p-value over all
window sizes is stored for position j.
The final return value is -\log_{10} of these per-position minimum
p-values.
Numeric vector of length \lceil N / \texttt{skip1} \rceil.
Each element is the -\log_{10}(p)-value at the corresponding grid
position, where the p-value is the minimum over all tested window sizes.
compute_pgs_matrix for the step that produces
pgs.mat.
ras_scan_original for the recommended high-level entry point that
calls this function automatically for each repetition.
set.seed(3)
n_samp <- 80; n_snp <- 50
geno <- matrix(sample(0:2, n_samp * n_snp, replace = TRUE,
prob = c(0.6, 0.3, 0.1)),
nrow = n_samp, ncol = n_snp)
weights <- rnorm(n_snp)
leftout <- 31:80
pgs_mat <- compute_pgs_matrix(geno, leftout, weights)
scan_df <- data.frame(matrix(rnorm(50 * 12), 50, 12))
colnames(scan_df) <- c("age", "sex", "age_squared", "age_sex",
paste0("pc", 1:8))
scan_df$phenotype2 <- rnorm(50)
p_vec <- screen_forward_max_region_original(
geno = geno,
pgs.mat = pgs_mat,
this.df = scan_df,
num_signals = -1,
is_continuous = TRUE,
covariate_formula = paste(c("age", "sex"), collapse = " + "),
skip1 = 5,
skip2 = 5,
min_window_size = 2,
max_window_size = 8,
isPlot = FALSE
)
plot(seq(1, n_snp, by = 5), p_vec, type = "l",
xlab = "SNP index", ylab = expression(-log[10](p)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.