1

我有像这样的农庄对象(显示四个中的两个):

> 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(对于“类型”列)区域绘制维恩图以显示重叠。谁能帮我解决这个问题?非常感谢提前

4

1 回答 1

0

如果你有你的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"))

但是,如果您将它们作为一个GRangestype元数据分层的单一分层,您可以制作它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)
于 2016-08-02T15:57:52.237 回答