scripts/adjacent_ranges.R

# find sets of peptides that were generated by a common cleavage event
# R.XXXXEXXXXR. -> R.XXXXE.XXXXR.
# [AB] -> [A]+[B]
# spanning, neoN, neoC
# formal range ensembl
# neoC.neoN range duo
# find the non-overlapping nearest neigbors on a specific side
# find adjacent intervals
# test object
test <- IRanges(start = c(1,5,10), end = c(3,8,15))
precede(x = test) # problem: can be any non overlapping distance
distanceToNearest(x = test) # why do only get selfhits?
plotRanges(sort(rl[[n]])

# manual
i <- (end(rl[[n]])+1) %in% start(rl[[n]])) #basic operation to find views that follow at zero distance
i <- match(end(rl[[n]])+1, start(rl[[n]]))
rl[[n]][na.omit(i)]

#----------------------------
# finding adjacent neoC-neoN pairs
adjacent.ranges <- function(x){
  # x should be instance of IRanges
  # functions returns IRanges that are adjacent
  f <- x[(end(x)+1) %in% start(x)]
  s <- x[(start(x)-1) %in% end(x)]
  return(c(f, s))
}
rl[[n]]
adjacent(rl[[n]])
adjacent.meta(rl[[n]])
test <- IRanges(start = c(1,5,10), end = c(4,8,15))
elementMetadata(test) <- data.frame(nterm.label = c("free", "label", "free"))
adjacent(test)
adjacent.meta(test)
tobiasko/posprot documentation built on May 26, 2019, 5:33 a.m.