[Bioc-sig-seq] Local Context

James Bullard bullard at stat.berkeley.edu
Tue Jun 22 01:36:26 CEST 2010


Hi,

This must be readily doable and I am just missing the obvious -- I am
trying, for a long sequence, to classify each position as coming from a
particular context. Something like running nucleotide table. The function
I have now is in R and it looks like this:

.computeContext <- function(v, windowSize = 2, windowOffset = 0, fx =   
function(a) paste(a, collapse = "")) {

  ## r should always be the same length as v. it will correspond to
  ## the class of v as well, but some of that is how 'fx' is written.
  r <- vector(mode = mode(v), length = length(v))

  for (i in (1 + windowOffset):length(r)) {
    r[i] <- fx(v[ i:(i + windowSize - 1) - windowOffset ])
  }
  return(r)
}



More information about the Bioc-sig-sequencing mailing list