Chapter 6 Enhancer conservation across tissues grouped by SE/Ehn-stableCBS/Enh-specificCBS
6.1 Description
Compare the tissue-specificity for enhancers: SEs, enhancer with stable CBS, enhancer with specific CBS
6.2 Get overlap for three enhancer sets
## Section: get the overlap: three tissues
##################################################
<- list.files('data/peakfiles/Enhancer-groupby-CBS/', full.names = T, pattern = "specific")
f.ls <- f.ls[c(2,3,1)]
f.ls f.ls
## [1] "data/peakfiles/Enhancer-groupby-CBS//Hep.with.specificCBS.bed"
## [2] "data/peakfiles/Enhancer-groupby-CBS//Myocyte.with.specificCBS.bed"
## [3] "data/peakfiles/Enhancer-groupby-CBS//Bcell.with.specificCBS.bed"
<- lapply(f.ls, function(f){
gr.ls <- fread(f)
mat <- mat[,1:3]
mat names(mat) <- c('chr', 'start', 'end')
<- makeGRangesFromDataFrame(mat)
gr return(gr)
})
<- function(gr.ls){
getOvlp <- gr.ls[[1]]
a <- gr.ls[[2]]
b <- gr.ls[[3]]
c
<- unique(queryHits(findOverlaps(a,b)))
comm.ab <- unique(queryHits(findOverlaps(a,c)))
comm.ac <- unique(queryHits(findOverlaps(b,c)))
comm.bc <- intersect(comm.ab, comm.ac)
abc
return(c(length(a), length(b), length(c), length(comm.ab),
length(comm.ac), length(comm.bc), length(abc)))
}
<- getOvlp(gr.ls) n.ls
6.3 Venn diagram
## Section: triple venn plot
##################################################
<- brewer.pal(3, "Pastel2")
myCol <- function(n.ls){
getVen draw.triple.venn(n.ls[1], n.ls[2], n.ls[3], n.ls[4], n.ls[5],n.ls[6], n.ls[7],
# Circles
lwd = 2,
lty = 'blank',
fill = myCol,
# Numbers
cex = .6,
fontface = "bold",
fontfamily = "sans",
# Set names
cat.cex = 0.6,
cat.fontface = "bold",
cat.default.pos = "outer",
cat.pos = c(-27, 27, 135),
cat.dist = c(0.055, 0.055, 0.085),
cat.fontfamily = "sans",
rotation = 1,
category = c('Bcell','hep', 'myocyte'))
}
getVen(n.ls)
## (polygon[GRID.polygon.1], polygon[GRID.polygon.2], polygon[GRID.polygon.3], polygon[GRID.polygon.4], polygon[GRID.polygon.5], polygon[GRID.polygon.6], text[GRID.text.7], text[GRID.text.8], text[GRID.text.9], text[GRID.text.10], text[GRID.text.11], text[GRID.text.12])
## Section: triple venn plot
##################################################
pdf('results/Features/N6-Human-enhancer-conservation-AllEnh-withspecificCBS-vennplot.pdf', width = 2, height = 2)
getVen(n.ls)
dev.off()