R/organismDB_mod.R

Defines functions organismDB_mod

Documented in organismDB_mod

#' organismDB_mod
#' 
#' modifies the Gene model output from an OrganismDb object so that the intron intronic regions can be visualized on the plot
#' @param gene1 One of the gene symbols of interest that will be displayed
#' @param gene2 One of the gene symbols of interest that will be displayed
#' @param introns Data Frame of the regions of the genome that are intronic
#' @return object that specifies which are the genes of interest
#' @import ggbio
#' @import ggplot2
#' @import Homo.sapiens
#' @export
#' @references Based off of the ggbio documentation available on bioconductor: 
#' http://bioconductor.org/packages/release/bioc/vignettes/ggbio/inst/doc/ggbio.pdf
#' Original Author: Tengfei Yin


organismDB_mod <- function(gene1, gene2, introns) {
  data(genesymbol, package = "biovizBase")
  
  # input should be "BRCA1" and "NBR1" to test
  wh <- genesymbol[c(gene1, gene2)]
  wh <- range(wh, ignore.strand = TRUE)
  
  #plotting our genes of interest
  p <- ggbio::autoplot(Homo.sapiens, which = wh)
  print(p)
  
  #modifying the plot's appearance
  p2 <- ggbio::autoplot(Homo.sapiens, which = wh, 
                 gap.geom = "chevron")
  print(p2)
  
  p3 <- ggbio::autoplot(Homo.sapiens, which = wh, 
                 label.color = "black", color = "brown", fill = "brown")
  print(p3)
  
  p4 <- ggbio::autoplot(Homo.sapiens, which = wh, 
                 columns = c("GENENAME", "GO"), names.expr = "GENENAME::GO")
  print(p4)
  
  #printing out modified plots with introns displayed
  p_1 <- add_intron(p, introns)
  print(p_1)
  
  p_2 <- add_intron(p2, introns)
  print(p_2)
  
  p_3 <- add_intron(p3, introns)
  print(p_3)
  
  p_4 <- add_intron(p4, introns)
  print(p_4)
  
  return(p)
}
cheejus2/Intron_Vis documentation built on Dec. 8, 2019, 10:35 a.m.