R/add_intron.R

Defines functions add_intron

Documented in add_intron

#' add_intron
#' 
#' modifies a plot to display the regions of a chromosome that are intronic
#' @param plot The ggplot object that will be modified
#' @param introns Data Frame of the regions of the genome that are intronic
#' @return The modified ggplot object
#' @import ggplot2
#' @export

add_intron <- function(plot, introns) {
  
  #interating through the intervals that aren't exons, therefore must be introns
  for (i in 1:nrow(introns)) {
    if (introns[i, 1] < introns[i, 2]) {
      plot <- plot + geom_rect(data=NULL, aes(xmin=introns[i, 1], xmax=introns[i, 2], ymin=-Inf, ymax=Inf),
                               fill="orangered1")
    }
  }
  
  return(plot)
}
cheejus2/Intron_Vis documentation built on Dec. 8, 2019, 10:35 a.m.