library(rGREAT)
library("org.Hs.eg.db")
library(pheatmap)
options(warn=-1)
gr=read.table("colon_MHB.bed")
colnames(gr)=c("chr","start","end")
gr=GRanges(gr)
start(gr) = start(gr) + 1
head(gr)
# loading tissue-specific genes
TS = readRDS("tissueSpecificGenes.RDS")
ls(TS)
# colon-specific genes
example = as.character(TS[[8]][,1])
head(example)
SR = unique(mapIds(org.Hs.eg.db, example, 'ENTREZID', 'SYMBOL'))
SR = SR[!is.na(SR)]
gs = list(example = SR)
res = great(gr, gs, "hg19", verbose = FALSE)
tb = getEnrichmentTable(res)
# enrichment of colon-specific genes in colon MHBs with high significance
tb
test=tb[,c('id','p_adjust')]
test$rnkPV=rownames(test)
log=test$p_adjust>0.05
test$rnkPV[log]<-NA
test
result=read.table("Exp.txt",sep="\t",header = T, row.names = 1)
head(result)
# mask non-significant ones
result_input=result
result_input[is.na(result_input)] <- 14
head(result_input)
options(repr.plot.width = 8, repr.plot.height=6, repr.plot.res = 150)
pheatmap(result_input,
show_rownames=T,main="Tissue-specific gene",
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,14),legend_labels = c("1","14"),
scale = "none",border_color = "grey90", display_numbers = matrix(ifelse(result_input > 1, "", "*"), nrow = nrow(result_input)),
color = colorRampPalette(colors = c("#F71E35", "#FCD271","#fcebb6","white"))(50))