Region-set enrichment analysis using LOLA

In [ ]:
library("LOLA")
library("GenomicRanges")
library("Hmisc")
library("pheatmap")

An example using MHBs from adrenal gland

In [ ]:
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)
In [58]:
constant = 17
locResults$qValue = (10^(-locResults$pValueLog)) * (constant / locResults$rnkPV)
head(locResults);dim(locResults)
A data.table: 6 × 23
userSetdbSetcollectionpValueLogoddsRatiosupportrnkPVrnkORrnkSupmaxRnk⋯ddescriptioncellTypetissueantibodytreatmentdataSourcefilenamesizeqValue
<int><int><chr><dbl><dbl><int><int><int><int><int>⋯<int><chr><chr><chr><chr><chr><chr><chr><dbl><dbl>
1 2ucsc_example210.1912532.185228352911 1 1⋯69405ucsc_exampleNANANANANAAdrenal_H3K27ac.bed1585661.094450e-209
110ucsc_example 58.5647471.5378882500221111⋯75085ucsc_exampleNANANANANAOvary_H3K27ac.bed 194882 2.315642e-58
1 1ucsc_example 10.9630681.1880532707331010⋯66551ucsc_exampleNANANANANAAdipose_H3K27ac.bed123493 6.169644e-11
113ucsc_example 10.0925721.174367316744 4 4⋯59554ucsc_exampleNANANANANASpleen_H3K27ac.bed 130465 3.434132e-10
114ucsc_example 8.2111831.153098345455 2 5⋯54817ucsc_exampleNANANANANAStomach_H3K27ac.bed135084 2.090721e-08
117ucsc_example 6.6730841.135736312466 5 6⋯59348ucsc_exampleNANANANANAThyroid_H3K27ac.bed142299 6.014693e-07
  1. 17
  2. 23
In [56]:
# mask non-significant results
log=locResults$qValue>0.05
locResults$rnkPV[log]<-NA
result=locResults[,c('rnkPV','filename')];result
A data.table: 17 × 2
rnkPVfilename
<int><chr>
1Adrenal_H3K27ac.bed
2Ovary_H3K27ac.bed
3Adipose_H3K27ac.bed
4Spleen_H3K27ac.bed
5Stomach_H3K27ac.bed
6Thyroid_H3K27ac.bed
7Lung_H3K27ac.bed
8Heart_H3K27ac.bed
9Liver_H3K27ac.bed
NAEsophagus_H3K27ac.bed
NAPancreas_H3K27ac.bed
NAColon_H3K27ac.bed
NAThymus_H3K27ac.bed
NABreast_H3K27ac.bed
NAPlacenta_H3K27ac.bed
NABcell_H3K27ac.bed
NATcell_H3K27ac.bed

Enrichment of MHBs in H3K27ac ChIP-seq peaks

In [9]:
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)
A data.frame: 6 × 17
AdiposeAdrenalBBreastColonEsophagusHeartLiverLungOvaryPancreasPlacentaSpleenStomachTThymusThyroid
<int><int><int><int><int><int><int><int><int><int><int><int><int><int><int><int><int>
Adipose 2 3 9 417 9 117 6 51717 817 71717
Adrenal gland 5 114171717 21713 31717 617151717
B-cell1317 217 2171717 8171717 217 2 217
Breast1717 4 1 9 61717111717171717 51717
Colon 6171117 1101717 3171717 7 3 61717
Esophagus 91710 2 5 11717 717171717 5111717

Heatmap

In [34]:
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))
In [ ]: