findBestNpvs {ramwas} | R Documentation |
Finding top, say, 100 p-values out of millions can be slow.
This function does it much faster than the usual application of
order(pv)[1:N]
.
findBestNpvs(pv, n)
pv |
Vector of p-values. |
n |
Number of best p-values to select. |
The function is a faster analog of sort(order(pv)[1:N])
Return a vector of positions of the smallest N
p-values in pv
.
Andrey A Shabalin andrey.shabalin@gmail.com
See order
.
pv = runif(1000)^10 n = 100 # Faster version topSites1 = findBestNpvs(pv, n) # Slow alternative topSites2 = sort(order(pv)[1:n]) # The results must match stopifnot(all( topSites1 == topSites2 ))