R/bam_mod.R

Defines functions bam_mod

Documented in bam_mod

#' bam_mod
#' 
#' modifies the Gene model output from a BAM file so that the intron intronic regions can be visualized on the plot
#' @param wh The genes of interest for this model
#' @param chr The single chromosome whose coverage you want to measure
#' @param bai The BAM index file that quantifies that coverage
#' @param bam The BAM file that quantifies that coverage
#' @param introns Data Frame of the regions of the genome that are intronic
#' @return object that specifies what the the genes of interest are
#' @import Rsamtools
#' @import ggplot2
#' @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


bam_mod <- function(gene1, gene2, chr, bai, bam, introns) {
  
  # input should be "BRCA1" and "NBR1" to test
  wh <- genesymbol[c(gene1, gene2)]
  wh <- range(wh, ignore.strand = TRUE)
  
  # to test use "chr17"
  wh <- keepSeqlevels(wh, chr)
  
  # to test use "example2.bam" and "example2.bam.bai"
  b <- BamFile(file = bam, index = bai)
  p <- autoplot(b, which = wh)
  print(p)
  
  #printing out modified plots with introns displayed
  p <- add_intron(p, introns)
  print(p)
  
  return(p)
}
cheejus2/Intron_Vis documentation built on Dec. 8, 2019, 10:35 a.m.