R/plotCountVsLength.R

Defines functions plotCountVsLength

Documented in plotCountVsLength

#' Plot transcript count vs. length
#'
#' Plots the number of reads vs. transcript width for capped, uncapped, and total libraries.
#'
#' @param dat a data.table containing results of a CoPRO experiment
#'
#' @return a ggplot object
#' @export
plotCountVsLength <- function(dat) {
  lens <- dat[, list(sumC = sum(C), sumU = sum(U), sumR = as.numeric(sum(R))) , by = "width"]
  toPlot <- melt(lens, id.vars = "width", measure.vars = c("sumC", "sumU", "sumR"), variable.name = "status", value.name = "count")
  a <- ggplot(data = toPlot, mapping = aes(x = width, y = count, col = status)) + geom_line(lwd = 1.2)
  return(a)
}
Timothy-Barry/coproanalysis documentation built on Feb. 12, 2020, 7:33 a.m.