# 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)
# c1) manhattan plot of the best
best <- bLD$best
best$value <- best$score
gp <- xGRmanhattan(best, top=length(best))
gp
# c2) manhattan plot of all LD block
grl_block <- bLD$block
gr_block <- BiocGenerics::unlist(grl_block,use.names=F)
gr_block$value <- gr_block$score
top.label.query <- names(gr_block)[!is.na(gr_block$pval)]
#gr_block <- gr_block[as.character(GenomicRanges::seqnames(gr_block)) %in% c('chr1','chr2')]
gp <- xGRmanhattan(gr_block, top=length(gr_block),
top.label.query=top.label.query)
# c3) karyogram plot of the best
kp <- xGRkaryogram(gr=best,cytoband=T,label=T,
RData.location=RData.location)
kp
# c4) circle plot of the best
library(ggbio)
gr_ideo <- xRDataLoader(RData.customised="hg19_ideogram",
RData.location=RData.location)$ideogram
#cp <- ggbio() + circle(kp$gr, geom="rect", color="steelblue", size=0.5)
cp <- ggbio() + circle(kp$gr, aes(x=start, y=num), geom="point",
color="steelblue", size=0.5)
cp <- cp + circle(gr_ideo, geom="ideo", fill="gray70") +
circle(gr_ideo, geom="scale", size=1.5) + circle(gr_ideo, geom="text",
aes(label=seqnames), vjust=0, size=3)
cp
# d) track plot of 1st LD block
gr_block <- bLD$block[[1]]
cnames <- c('score','maf','cadd')
ls_gr <- lapply(cnames, function(x) gr_block[,x])
names(ls_gr) <- cnames
ls_gr$score$Label <- names(gr_block)
ls_gr$score$Label[is.na(gr_block$pval)] <-''
GR.score.customised <- ls_gr
## cse.query
df_block <- as.data.frame(gr_block)
chr <- unique(df_block$seqnames)
xlim <- range(df_block$start)
cse.query <- paste0(chr,':',xlim[1],'-',xlim[2])
#cse.query <- paste0(chr,':',xlim[1]-1e4,'-',xlim[2]+1e4)
## xGRtrack
tks <- xGRtrack(cse.query=cse.query, GR.score="RecombinationRate",
GR.score.customised=GR.score.customised, RData.location=RData.location)
tks
###############
# Advanced use: get LD block (based on customised LD and SNP data)
###############
LD.customised <- xRDataLoader('LDblock_EUR',
RData.location=RData.location)
GR.SNP <- xRDataLoader('LDblock_GR', RData.location=RData.location)
bLD <- xLDblock(data, LD.customised=LD.customised, LD.r2=0.8,
GR.SNP=GR.SNP, RData.location=RData.location)
# }
Run the code above in your browser using DataLab