R/getFeatureCounts.R

Defines functions getFeatureCounts

Documented in getFeatureCounts

#' utility fn for getComplexity and preseqR 
#'
#' @param x   the thing to count features in (usually a GRanges)
#'
#' @return    an array of feature frequencies
#' 
#' @import    GenomicRanges
#' 
#' @export
getFeatureCounts <- function(x) {
  
  if (!is(x, 'GRanges')) x <- as(x, 'GRanges')
  ends <- paste(start(x), end(x), sep=':')
  freqs <- data.frame(seen=as(table(ends), 'matrix')[,1])
  freqs[ rev(order(freqs$seen)), , drop=FALSE] ## descending order 
  
}
biobenkj/complexion documentation built on June 25, 2020, 12:02 a.m.