# 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"
# }
# NOT RUN {
# a) provide the seed SNPs with the significance info
## load ImmunoBase
data(ImmunoBase)
## get lead SNPs reported in AS GWAS and their significance info (p-values)
gr <- ImmunoBase$AS$variant
data <- GenomicRanges::mcols(gr)[,c('Variant','Pvalue')]
# b) get LD block (EUR population)
bLD <- xLDblock(data, include.LD="EUR", LD.r2=0.8,
RData.location=RData.location)
## c) perform enrichment analysis using FANTOM expressed enhancers
eTerm <- xLDenricher(bLD, GR.annotation="ReMap_Encode_mergedTFBS",
RData.location=RData.location)
## d) view enrichment results for the top significant terms
xEnrichViewer(eTerm)
## e) barplot of enriched terms
bp <- xEnrichBarplot(eTerm, top_num='auto', displayBy="fdr")
bp
## f) forest plot of enrichment results
gp <- xEnrichForest(eTerm, FDR.cutoff=0.01)
## g) save enrichment results to the file called 'LD_enrichments.txt'
output <- xEnrichViewer(eTerm, top_num=length(eTerm$adjp),
sortBy="adjp", details=TRUE)
utils::write.table(output, file="LD_enrichments.txt", sep="\t",
row.names=FALSE)
## h) compare boundary and exact
GR.SNP <- xRDataLoader("dbSNP_GWAS", RData.location=RData.location)
GR.annotation <- xRDataLoader("FANTOM5_CAT_Cell",
RData.location=RData.location)
eTerm_boundary <- xLDenricher(bLD, GR.SNP=GR.SNP,
GR.annotation=GR.annotation, num.samples=20000, preserve="boundary",
RData.location=RData.location)
eTerm_exact <- xLDenricher(bLD, GR.SNP=GR.SNP,
GR.annotation=GR.annotation, num.samples=20000, preserve="exact",
RData.location=RData.location)
ls_eTerm <- list(boundary=eTerm_boundary, exact=eTerm_exact)
### barplot
bp <- xEnrichCompare(ls_eTerm, displayBy="zscore")
### forest plot
eTerm_boundary$group <- 'boundary'
eTerm_exact$group <- 'exact'
df <- rbind(eTerm_boundary, eTerm_exact)
gp <- xEnrichForest(df, FDR.cutoff=0.01)
# }
Run the code above in your browser using DataLab