knitr::opts_chunk$set(tidy=FALSE, cache=TRUE,
                      dev="png",
                      message=FALSE, error=FALSE, warning=TRUE)
options(width=100)

HOCOMOCO v11

tfbsDB includes functions to read TFBS from bgzip'd and tabix'd BED file, and plot using ggbio.

library(GenomicRanges)
library(tfbsDB)

# range of TFBS to be loaded from file
grQuery = GRanges("chr1", IRanges(34000,35000))

# example data from package
bedFile = file.path(system.file("extdata/", package = "tfbsDB"), "hocomocov11_hg19_example.bed.gz")

# read from file
gr = readTFBSdb( grQuery, bedFile )

# show TFBS locations
plotTFBSdb( gr, tf_text_size=3 )

# color locations by p-value of motif match
plotTFBSdb( gr, colorByP=TRUE, tf_text_size=3)

Plot genes and TFBS

library(ggbio)
library(tfbsDB)
library(EnsDb.Hsapiens.v75)
edb <- EnsDb.Hsapiens.v75

wh <- GRanges("chr1", IRanges(34000,35000))
xlim = c(start(wh), end(wh))

# plot Genes
wh2 <- wh
seqlevelsStyle(wh2) <- "NCBI"
p.txdb = autoplot(edb, which=wh2, names.expr = "gene_name") + theme_bw(20) 

# plot TFBS
# bedFile = '~/data/tfbsDB/motifs_fimo_search_small.bed.gz'
bedFile = file.path(system.file("extdata/", package = "tfbsDB"), "hocomocov11_hg19_example.bed.gz")

gr = readTFBSdb( wh, bedFile )
figHOCO = plotTFBSdb( gr, xlim, colorByP=FALSE, tf_text_size=3) 

# Combine
tracks( Genes = p.txdb, HOCOMOCO = figHOCO, label.bg.fill="navy", label.text.color="white", 
  heights=c( 1, .4), padding = unit(-1.9, "lines"), label.width = unit(1.5, "lines"), 
  xlab.height = unit(1, "lines"), xlim=xlim)  + theme(axis.text.x =element_text(size=9)) +  scale_x_sequnit("bp")

plot JASPAR TFBS

# range of TFBS to be loaded from file
grQuery = GRanges("chr1", IRanges(34000,35000))

# example data from package
bedFile = file.path(system.file("extdata/", package = "tfbsDB"), "JASPAR2018_hg19_example.bed.gz")

# read from file
gr = readJaspar( grQuery, bedFile ) 

# show TFBS locations
fitJASPAR = plotTFBSdb( gr, xlim, colorByP=FALSE, tf_text_size=3) 

# Combine
tracks( Genes = p.txdb, HOCOMOCO = figHOCO, JASPAR = fitJASPAR, label.bg.fill="navy", label.text.color="white", 
  heights=c( 1, 0.5, 0.4), padding = unit(-1.9, "lines"), label.width = unit(1.5, "lines"), 
  xlab.height = unit(1, "lines"), xlim=xlim)  + theme(axis.text.x =element_text(size=9)) +  scale_x_sequnit("bp")

Jaspar BED file is available from http://expdata.cmmt.ubc.ca/JASPAR/downloads/UCSC_tracks/2018/

HOCOMOCO files are described in package README

Session info

sessionInfo()


GabrielHoffman/tfbsDB documentation built on June 23, 2020, 5:29 a.m.