r - Venn Diagram from GRanges -
i have granges objects these( showing 2 of four):
> upmd_hf3a granges object 398117 ranges , 2 metadata columns: seqnames ranges strand | type ncg <rle> <iranges> <rle> | <character> <integer> [1] chr1 [ 1, 714170] * | pmd 280 [2] chr1 [714171, 732041] * | notpmd 103 [3] chr1 [732042, 762741] * | pmd 109 [4] chr1 [762742, 796127] * | notpmd 264 [5] chr1 [796128, 859047] * | pmd 829 ... ... ... ... . ... ... [398113] chr9 [140133051, 140174235] * | notpmd 1725 [398114] chr9 [140174236, 140176229] * | pmd 187 [398115] chr9 [140176230, 140187041] * | notpmd 219 [398116] chr9 [140967724, 140973103] * | notpmd 152 [398117] chr9 [140973104, 141042747] * | pmd 1145 seqinfo: 93 sequences unspecified genome > upmd_hf3b granges object 334247 ranges , 2 metadata columns: seqnames ranges strand | type ncg <rle> <iranges> <rle> | <character> <integer> [1] chr1 [ 1, 712661] * | pmd 274 [2] chr1 [712662, 734889] * | notpmd 116 [3] chr1 [734890, 770103] * | pmd 152 [4] chr1 [770104, 794246] * | notpmd 163 [5] chr1 [794247, 859587] * | pmd 855 ... ... ... ... . ... ... [334243] chr9 [137315552, 137325053] * | notpmd 265 [334244] chr9 [138776843, 138782261] * | pmd 119 [334245] chr9 [138782262, 138854249] * | notpmd 1899 [334246] chr9 [139633630, 139648757] * | pmd 391 [334247] chr9 [140835156, 140917488] * | pmd 1169 ------- seqinfo: 93 sequences unspecified genome
i have used methylseekr create (predict paritally methylated domains-pmds) these granges objects. want plot venn diagram pmd (for column "type") regions these granges objects show overlap. can please me ? lot in advance
it easier if have granges
separately:
library(chippeakanno) peaks1 <- granges("chr1", iranges(seq(1, 100, 5), width=2), "+") peaks2 <- granges("chr1", iranges(seq(2, 20, 3), width=2), "+") peaks3 <- granges("chr1", iranges(seq(10, 50, 4), width=2), "+") res <- makevenndiagram(peaks=list(peaks1, peaks2, peaks3), nameofpeaks=c("tf1", "tf2", "tf3"))
but if have them single granges
stratified type
metadata, make grangeslist
, plot this:
peaks1$type<-"tf1" peaks2$type<-"tf2" peaks3$type<-"tf3" gr <- c(peaks1, peaks2, peaks3) # data grl <- splitaslist(gr, gr$type) res <- makevenndiagram(peaks=grl, nameofpeaks=names(grl))
if want nice , colorful venn diagram, check https://github.com/js229/vennerable/blob/master/readme.md install venerable (i not rforge) , this:
library(vennerable) venn_cnt2venn <- function(venn_cnt){ n <- which(colnames(venn_cnt)=="counts") - 1 setnames=colnames(venn_cnt)[1:n] weight=venn_cnt[,"counts"] names(weight) <- apply(venn_cnt[,1:n], 1, paste, collapse="") venn(setnames=setnames, weight=weight) } v <- venn_cnt2venn(res$venncounts) plot(v)
Comments
Post a Comment