| ras_validate | R Documentation |
Validates candidate changepoints from
ras_detect by re-running local
Davies tests in windows around each candidate.
ras_validate(
this.result,
x,
y,
this.start = 1,
this.skip = 30,
second_window_size = 50,
p.value.threshold = 1e-10,
min_signal = 2.5
)
this.result |
List. Output from
|
x |
Numeric vector. Predictor sequence used in the original scan. |
y |
Numeric vector. Response sequence used in the original scan. |
this.start |
Integer. Genomic start position for index re-mapping to
chromosome coordinates. Default |
this.skip |
Integer. Step size used in the original scan
( |
second_window_size |
Integer. Half-window size for local Davies test
re-validation. Default |
p.value.threshold |
Numeric. Davies test p-value threshold for
second-pass acceptance. A candidate is retained if either the
right-side or left-side local Davies test passes. Default |
min_signal |
Numeric. Minimum |
For each candidate \hat{\tau} in this.result$tau_hats the
function fits two local linear models and applies the Davies test to each:
one on the window
[\hat{\tau},\; \min(\hat{\tau} + \texttt{second\_window\_size},\, n)]
and one on
[\max(\hat{\tau} - \texttt{second\_window\_size},\, 1),\; \hat{\tau}].
If either Davies p-value is below p.value.threshold, the candidate
is accepted; otherwise its all.p.values entry is set to zero to
suppress it in downstream plots.
Windows with fewer than four observations are not tested (Davies test
requires at least four points) and their p-value is set to 1.0.
After filtering, any remaining candidate with
y[tau_hat] <= min_signal is removed, as such positions are below
the minimum signal threshold.
Accepted changepoint indices and all candidate indices are re-mapped from
the scan grid to genomic coordinates via
\texttt{this.start} + (\text{index} - 1) \times \texttt{this.skip}.
A named list with five elements:
tau_hatsInteger vector. Validated changepoint positions, re-mapped to genomic coordinates.
all.changepointsInteger vector. All candidate positions examined, re-mapped to genomic coordinates.
all.p.valuesNumeric vector. -\log_{10}(p) Davies
values for each candidate; set to 0 for rejected candidates.
left.slopesNumeric vector. Left-side slopes at accepted changepoints (carried over from first-pass output).
right.slopesNumeric vector. Right-side slopes at accepted changepoints.
ras_detect for the first-pass
detection step whose output this function takes as input.
plot.ras for visualising the validated changepoints.
ras for the recommended end-to-end entry point.
set.seed(42)
x <- 1:300
y <- c(seq(0, 8, length.out = 150),
seq(8, 1, length.out = 150)) + rnorm(300, sd = 0.5)
cp_result <- ras_detect(
x, y,
window_size = 150,
slope_check_window_size = 20,
slope.p.values.threshold.left = 1e-3,
slope.p.values.threshold.right = 1e-3
)
final <- ras_validate(
cp_result, x = x, y = y,
this.skip = 1,
second_window_size = 30,
p.value.threshold = 1e-3
)
cat("Validated changepoints:", final$tau_hats, "\n")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.