R/SparseDeltas.R

Defines functions SparseDeltas

Documented in SparseDeltas

SparseDeltas <-
  function(x, maxdiff)
  {
    n <- length(x)
    i <- seq(n)
    xout <- x + maxdiff
    j <- floor(approx(x = x, y = i, xout = xout, rule = 2)$y)
    
    s <- (j > i)
    i <- i[s]
    j <- j[s]
    
    d <- j - i
    ii <- rep(i, d)
    jj <- ii + unlist(lapply(d, seq))
    
    dx <- x[jj] - x[ii]
    triples <- cbind(i = ii, j = jj, dx = dx)

    triples
  }

Try the DMRcate package in your browser

Any scripts or data that you put into this service are public.

DMRcate documentation built on Jan. 17, 2021, 2 a.m.