library("LOLA")
library("GenomicRanges")
library("Hmisc")
library("pheatmap")
MHB="BED/Adrenal_MHB.bed"
# MHB regions
background="BED/MHB_Cat.bed"
mhb=readBed(MHB)
# Universe_Sets Background
universe_set=readBed(background)
# Overlaped Regions
states=loadRegionDB("BED/hg19_test")
# Runing LOLA
locResults = runLOLA(mhb, universe_set, states, cores=5)
constant = 17
locResults$qValue = (10^(-locResults$pValueLog)) * (constant / locResults$rnkPV)
head(locResults);dim(locResults)
# mask non-significant results
log=locResults$qValue>0.05
locResults$rnkPV[log]<-NA
result=locResults[,c('rnkPV','filename')];result
Result=read.table("BED/Result_H3K27ac.txt",sep="\t",header = T)
colnames(Result)=(sapply(strsplit(colnames(Result), "\\."), function(z) z[1]))
colnames(Result)=capitalize(colnames(Result))
rownames(Result)=Result$Filename
Result=Result[,-1]
rownames(Result)=capitalize(rownames(Result))
colnames(Result)=(sapply(strsplit(colnames(Result), "\\_"), function(z) z[1]))
head(Result)
options(repr.plot.width = 8, repr.plot.height=6)
pheatmap(Result,
show_rownames=T,main="H3K27ac Enrichment rnkPV",
cluster_cols= F,angle_col=45,fontsize_row=11,cellwidth=21,
cluster_rows=F,cellheight=18,fontsize_col=12,
how_colnames = T,
legend_breaks = c(1,17),legend_labels = c("1","17"),
scale = "none",border_color = "grey90", display_numbers = matrix(ifelse(Result > 1, "", "*"),
nrow = nrow(Result)),
color = colorRampPalette(colors = c("#F71E35", "#FCD271","#fcebb6","white"))(50))