我有这样的granges对象(显示了四个对象中的两个):
> upmd_Hf3a
GRanges object with 398117 ranges and 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 from an unspecified genome
> upmd_Hf3b
GRanges object with 334247 ranges and 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 from an unspecified genome我已经使用MethylSeekR创建(预测部分甲基化域-PMD)这些GRanges对象。我想为所有这些GRanges对象的PMD (列“类型”)区域绘制维恩图,以显示重叠。有谁能帮我一下吗?提前谢谢你
发布于 2016-08-02 23:57:52
如果你有单独的GRanges,这会更容易:
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"))但是,如果您将它们作为按type元数据分层的单个GRanges,则可以将其设置为GRangesList,并像这样绘制它:
peaks1$type<-"TF1"
peaks2$type<-"TF2"
peaks3$type<-"TF3"
gr <- c(peaks1, peaks2, peaks3) # like your data
grl <- splitAsList(gr, gr$type)
res <- makeVennDiagram(Peaks=grl, NameOfPeaks=names(grl))如果你想要一个漂亮和多彩的维恩图,那么可以查看https://github.com/js229/Vennerable/blob/master/README.md来安装Venerable (我无法从Rforge获得它),然后这样做:
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)https://stackoverflow.com/questions/38095607
复制相似问题