| ras | R Documentation |
Detect significant association regions in GWAS data.
Returns an object of class "ras".
ras(
geno,
phenotype,
covariates,
covariate_cols,
is_continuous,
num_rep = 5,
skip1 = 10,
skip2 = 20,
chrom = 1,
save_dir = file.path(tempdir(), "RAS"),
min_window_size = 5,
max_window_size = 100,
scan_test = c("glm", "score"),
cp_p_threshold = 0.01,
cp_window_size = 3000,
cp_min_length = 10,
cp_slope_check_window = 30,
cp_slope_left = 1e-10,
cp_slope_right = 1e-20,
second_window_size = 50,
second_p_threshold = 1e-10,
min_signal = 2.5,
run_plots = TRUE,
plot_device = "pdf",
plot_p_threshold = 8,
plot_y_cap = NULL
)
geno |
Matrix of genotype dosages ( |
phenotype |
Numeric vector of length |
covariates |
Data frame with |
covariate_cols |
Character vector of column names in covariates to include in the regression models. |
is_continuous |
Logical. |
num_rep |
Integer. Number of independent 50/50 splits to average over.
Default |
skip1 |
Integer. Step size for the primary SNP position grid
( |
skip2 |
Integer. Sub-step used to grow the scan window at each grid
position. Default |
chrom |
Integer. Chromosome number used in saved file names.
Default |
save_dir |
Character. Directory for intermediate |
min_window_size |
Integer. Minimum scan window half-size passed to
|
max_window_size |
Integer. Maximum scan window half-size passed to
|
scan_test |
Character. Per-window test for binary traits, passed to
|
cp_p_threshold |
Numeric. Davies test p-value threshold for
first-pass candidate changepoints. Default |
cp_window_size |
Integer. Sliding window width for first-pass
detection. Default |
cp_min_length |
Integer. Minimum segment length before and after a
candidate changepoint. Default |
cp_slope_check_window |
Integer. Half-width of the local window used
to verify slope direction around each candidate. Default |
cp_slope_left |
Numeric. One-tailed p-value threshold for the
left-side slope test (tests that the slope to the left of the candidate
is significantly positive). Default |
cp_slope_right |
Numeric. One-tailed p-value threshold for the
right-side slope test (tests that the slope to the right is
significantly negative). Default |
second_window_size |
Integer. Half-window size for second-pass local
Davies tests. Default |
second_p_threshold |
Numeric. Davies test p-value threshold for
second-pass validation. Default |
min_signal |
Numeric. Minimum |
run_plots |
Logical. If |
plot_device |
Character. Output device for plots: |
plot_p_threshold |
Numeric. Significance reference line drawn on plots
(on the |
plot_y_cap |
Numeric or |
For a stage-by-stage description of the pipeline see RAS.
Invisibly returns a named list with two elements:
scanA list with elements:
xInteger vector. SNP position index grid
seq(1, N, by = skip1).
yNumeric vector (same length as x). Averaged
-\log_{10}(p)-value profile across all repetitions.
detectionA list returned by ras_validate
with elements:
tau_hatsInteger vector. Validated changepoint positions (re-mapped to genomic coordinates via this.start and this.skip).
all.changepointsInteger vector. All candidate positions examined during the first pass, re-mapped to genomic coordinates.
all.p.valuesNumeric vector. -\log_{10}(p) Davies
test values for every candidate in all.changepoints.
left.slopesNumeric vector. Estimated left-side slopes at each validated changepoint.
right.slopesNumeric vector. Estimated right-side slopes at each validated changepoint.
Plot files (if run_plots = TRUE) are written to save_dir
with names chr-<chrom>-cp-plot.<ext>,
chr-<chrom>-cp-p-values-plot.<ext>, and
chr-<chrom>-zoom.<ext>.
## one call does everything
result <- ras(geno, phenotype, covariates,
covariate_cols = c("age", "sex", paste0("pc", 1:10)),
is_continuous = TRUE,
chrom = 1, save_dir = "results/")
print(result) # detected changepoint positions
plot(result) # full-chromosome scan profile
plot(result, zoom = TRUE) # zoomed view around each changepoint
For step-by-step control see ras_scan,
ras_detect, ras_validate.
ras_scan for the scan-only step (useful when tuning
changepoint parameters separately).
ras_detect,
ras_validate for the changepoint detection steps.
plot.ras for the plotting step.
ras_memory to check memory requirements before
loading large genotype data.
set.seed(42)
n_samp <- 80; n_snp <- 60
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)
pheno <- rnorm(n_samp)
cov_df <- data.frame(age = rnorm(n_samp), sex = rbinom(n_samp, 1, 0.5))
cov_df$age_squared <- cov_df$age^2
cov_df$age_sex <- cov_df$age * cov_df$sex
for (i in 1:10) cov_df[[paste0("pc", i)]] <- rnorm(n_samp)
result <- ras(
geno = geno,
phenotype = pheno,
covariates = cov_df,
covariate_cols = c("age", "sex", "age_squared", "age_sex",
paste0("pc", 1:10)),
is_continuous = TRUE,
num_rep = 2,
skip1 = 5,
skip2 = 5,
min_window_size = 2,
max_window_size = 10,
chrom = 1,
save_dir = tempdir(),
run_plots = TRUE,
plot_device = "png"
)
cat("Detected changepoints:", result$detection$tau_hats, "\n")
plot(result$scan$x, result$scan$y, type = "l",
xlab = "SNP index", ylab = expression(-log[10](p)),
main = "RAS scan profile")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.