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
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.
Now, we need to download a methlyDiff object to be plotted. This can be any methylDiff object from methylKit.
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)]
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.
download.file("http://methylkit.googlecode.com/files/myDiff.rda", destfile = "myDiff.rda") load("myDiff.rda")
ideoDMC(myDiff, chrom.length = chr.len, difference = 25, qvalue = 0.01, circos = FALSE, title = "test", hyper.col = "magenta", hypo.col = "green")
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")