注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

wangyufeng的博客

祝愿BB 健康开心快乐每一天

 
 
 

日志

 
 

Plotting differentially methylated bases on an ideogram  

2012-07-19 16:20:55|  分类: R、SVG&GNUPlot画 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

Ideogram is a popular way to show genomic features in relation to chromosome sizes and chromosomal location in bulk. Recently, we have shown differentially methylated CpGs on a chromosomal ideogram in our PLoS Genetics paper. Although it doesn't always make sense to show differentially methylated bases on an ideogram, I'm describing a function below that does a similar job.

The function can be used to plot ideograms for differentially methylated CpGs. The function requires methylKit, GenomicRanges and ggbio packages. GenomicRanges and ggbio are available from bioconductor

ideoDMC <- function(methylDiff.obj, chrom.length, difference = 25,      qvalue = 0.01, circos = FALSE, title = "test", hyper.col = "magenta",      hypo.col = "green") {     require(methylKit)     require(GenomicRanges)     require(ggbio)      # chrom.length     myIdeo <- GRanges(seqnames = names(chrom.length), ranges = IRanges(start = 1,          width = chrom.length))     seqlevels(myIdeo) = names(chrom.length)     seqlengths(myIdeo) = (chrom.length)       hypo = get.methylDiff(methylDiff.obj, difference = difference, qvalue = qvalue,          type = "hypo")     hyper = get.methylDiff(methylDiff.obj, difference = difference, qvalue = qvalue,          type = "hyper")      g.per = as(hyper, "GRanges")     g.per = keepSeqlevels(g.per, names(chrom.length))      g.po = as(hypo, "GRanges")     g.po = keepSeqlevels(g.po, names(chrom.length))     values(g.po)$id = "hypo"     values(g.per)$id = "hyper"      if (circos) {          p <- ggplot() + layout_circle(myIdeo, geom = "ideo", fill = "gray70",              radius = 39, trackWidth = 2)           p <- p + layout_circle(c(g.po, g.per), geom = "point",                   size = 1, aes(x = midpoint,              y = meth.diff, color = id), radius = 25, trackWidth = 30) +                           scale_colour_manual(values = c(hyper.col, hypo.col))         p + layout_circle(myIdeo, geom = "text", aes(label = seqnames),              vjust = 0, radius = 55, trackWidth = 7) + opts(title = title)      } else {          p <- ggplot() + layout_karyogram(myIdeo, cytoband = FALSE)         p + layout_karyogram(c(g.po, g.per), geom = "point", size = 1,           aes(x = midpoint,              y = meth.diff, color = id)) + scale_colour_manual(values = c(hyper.col,              hypo.col)) + opts(title = title)      } } 

First, we need to get chromosome lengths that are needed to define chromosome boundaries. I used BSgenome.Hsapiens.UCSC.hg18 package from Bioconductor to get the chromosome lengths of hg18 assembly.

library(BSgenome) library("BSgenome.Hsapiens.UCSC.hg18") chr.len = seqlengths(Hsapiens)  # get chromosome lengths # remove X,Y,M and random chromosomes chr.len = chr.len[grep("_|M|X|Y", names(chr.len), invert = T)]  

Now, we need to download a methlyDiff object to be plotted. This can be any methylDiff object from methylKit.

 download.file("http://methylkit.googlecode.com/files/myDiff.rda",      destfile = "myDiff.rda") load("myDiff.rda") 

Next, we plot the ideogram using the chromosome length and methylDiff object. “difference” is the percent methylation difference threshold and “qvalue” is the qvalue threshold, both used to define differentially methylated bases in the function. The differentially methylated bases satisfying “difference” and “qvalue” thresholds are plotted in a color coded manner in the ideogram.

ideoDMC(myDiff, chrom.length = chr.len, difference = 25, qvalue = 0.01,      circos = FALSE, title = "test", hyper.col = "magenta", hypo.col = "green") 
Plotting differentially methylated bases on an ideogram - 喜欢吃桃子 - wangyufeng的博客
 

We can also plot a circular ideogram similar to circos plots using the same function.

ideoDMC(myDiff, chrom.length = chr.len, difference = 25, qvalue = 0.01, circos = TRUE, title = "test", hyper.col = "magenta", hypo.col = "green")
Plotting differentially methylated bases on an ideogram - 喜欢吃桃子 - wangyufeng的博客
 more information by :http://zvfak.blogspot.de/search/label/R
  评论这张
 
阅读(1905)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017