# NOT RUN {
# Load the XGR package and specify the location of built-in data
library(XGR)
RData.location <- "http://galahad.well.ox.ac.uk/bigdata/"
data(Haploid_regulators)
## only IRF1 positive regulators
data <- subset(Haploid_regulators, Phenotype=='IRF1' &
MI<0)[,c('Gene')]
# 1) KEGGenvironmental
eTerm <- xEnricherGenes(data, ontology="KEGGenvironmental",
size.range=c(10,2000), min.overlap=5, RData.location=RData.location)
gp_ladder <- xEnrichLadder(eTerm)
# 2) PSG
eTerm <- xEnricherGenes(data,
ontology=c("PSG","Approved","GWAS","CGL")[1], size.range=c(1,20000),
min.overlap=0, RData.location=RData.location)
gp_ladder <- xEnrichLadder(eTerm, sortBy="none", top_num="auto",
FDR.cutoff=1)
gp_ladder+ coord_flip()
# 3) save into the file "xEnrichLadder.pdf"
mat <- xSparseMatrix(gp_ladder$data)
pdf("xEnrichLadder.pdf", width=2+ncol(mat)*0.075,
height=2+nrow(mat)*0.1, compress=T)
print(gp_ladder)
dev.off()
# 4) SIFTS2GOMF
## df_fpocket
SIFTS_fpocket <-
xRDataLoader(RData='SIFTS_fpocket',RData.location=RData.location)
df_fpocket <- as.data.frame(SIFTS_fpocket %>%
dplyr::filter(druggable=='Y') %>% dplyr::group_by(Symbol,PDB_code)
%>% dplyr::summarise(num_pockets=n()) %>%
dplyr::arrange(Symbol,desc(num_pockets),PDB_code))
df_fpocket <- df_fpocket[!duplicated(df_fpocket$Symbol), ]
## mat_fpocket
mat_fpocket <- df_fpocket %>% tidyr::spread(Symbol, num_pockets)
rownames(mat_fpocket) <- mat_fpocket[,1]
mat_fpocket <- mat_fpocket[,-1]
## gp_ladder
set.seed(825)
data <- as.character(sample(unique(df_fpocket$Symbol), 100))
eTerm <- xEnricherGenes(data=data, ontology="SIFTS2GOMF",
RData.location=RData.location)
gp_ladder <- xEnrichLadder(eTerm, sortBy="none", top_num=5,
FDR.cutoff=0.01, x.rotate=90)
#gp_ladder + coord_flip()
## data_matrix
ind <- match(colnames(gp_ladder$matrix), colnames(mat_fpocket))
data_matrix <- mat_fpocket[,ind[!is.na(ind)]]
ind <- which(apply(!is.na(data_matrix), 1, sum)!=0)
data_matrix <- data_matrix[ind,]
ind <- match(data, colnames(data_matrix))
data_matrix <- data_matrix[,ind[!is.na(ind)]]
## gp_pdb
gp_pdb <- xHeatmap(t(data_matrix), reorder="row", colormap="jet.top",
x.rotate=90, shape=19, size=1, x.text.size=6,y.text.size=5,
na.color='transparent', legend.title='# pockets')
#gp_pdb + coord_flip()
## plot_combined
#plot_combined <- cowplot::plot_grid(gp_ladder, gp_pdb, align="h", ncol=1, rel_heights=c(2,3))
## enrichment analysis
SIFTS_fpocket <-
xRDataLoader(RData='SIFTS_fpocket',RData.location=RData.location)
annotation.file <- SIFTS_fpocket[!duplicated(SIFTS_fpocket$Symbol),
c('Symbol','druggable')]
### 100 randomly chosen human genes
org.Hs.eg <- xRDataLoader(RData='org.Hs.eg',
RData.location=RData.location)
set.seed(825)
data <- as.character(sample(org.Hs.eg$gene_info$Symbol, 100))
### optionally, provide the test background (if not provided, all human genes)
background <- as.character(org.Hs.eg$gene_info$Symbol)
### perform enrichment analysis
eTerm <- xEnricherYours(data.file=data,
annotation.file=annotation.file, background.file=background,
size.range=c(10,20000))
# }
Run the code above in your browser using DataLab