| get_local_maximum | R Documentation |
Returns the index of the maximum value of y within a symmetric
window of half-width window.size centred at x0.
get_local_maximum(y, x0, window.size = 50)
y |
Numeric vector. Values to search (e.g., |
x0 |
Integer. Centre index of the search window. |
window.size |
Integer. Half-width of the search window. The search
covers indices |
This function is used by ras_detect
after the sliding-window loop to snap each accepted changepoint index to
the nearest local peak in the -\log_{10}(p) profile. Snapping to
the peak ensures that reported positions correspond to the most significant
SNP in the association region rather than to the mathematical breakpoint
of the piecewise linear fit, which may be slightly offset.
Integer. The index (into y) of the local maximum within the window
centred at x0. If multiple positions tie for the maximum,
which.max returns the first.
ras_detect which calls this
function to refine detected changepoint positions.
y <- c(1, 3, 7, 5, 2, 8, 4, 1)
## Peak within a window of half-width 2 centred at index 3
get_local_maximum(y, x0 = 3, window.size = 2) # returns 3 (value = 7)
## Peak within a window of half-width 3 centred at index 3
## covers indices 1:6; max is at index 6 (value = 8)
get_local_maximum(y, x0 = 3, window.size = 3) # returns 6
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.