我有 2 个基因组范围
g1<-GRanges(c("chr1:0-14","chr1:15-29"), score=c(20.2,10.4));g1
GRanges object with 2 ranges and 1 metadata column:
seqnames ranges strand | score
<Rle> <IRanges> <Rle> | <numeric>
[1] chr1 0-14 * | 20.2
[2] chr1 15-29 * | 10.4
g2<-GRanges(c("chr1:0-9","chr1:10-19","chr1:20-29"), state=c('E1','E2','E1'));g2
GRanges object with 3 ranges and 1 metadata column:
seqnames ranges strand | state
<Rle> <IRanges> <Rle> | <character>
[1] chr1 0-9 * | E1
[2] chr1 10-19 * | E2
[3] chr1 20-29 * | E1
我想让它们具有可比性。首先我将它们组合起来,然后我使用了 disjoin:
g3<-(c(g1,g2)); g3
GRanges object with 5 ranges and 2 metadata columns:
seqnames ranges strand | score state
<Rle> <IRanges> <Rle> | <numeric> <character>
[1] chr1 0-14 * | 20.2 <NA>
[2] chr1 15-29 * | 10.4 <NA>
[3] chr1 0-9 * | <NA> E1
[4] chr1 10-19 * | <NA> E2
[5] chr1 20-29 * | <NA> E1
disjoin(g3)
GRanges object with 4 ranges and 0 metadata columns:
seqnames ranges strand
<Rle> <IRanges> <Rle>
[1] chr1 0-9 *
[2] chr1 10-14 *
[3] chr1 15-19 *
[4] chr1 20-29 *
所以, disjoin 正在做我想要的拆分,但不幸的是没有保留元数据。有没有办法像这样保留元数据并获得 GRange?
GRanges object with 5 ranges and 2 metadata columns:
seqnames ranges strand | score state
<Rle> <IRanges> <Rle> | <numeric> <character>
[1] chr1 0-9 *| 20.2 E1
[2] chr1 10-14 *| 20.2 E2
[3] chr1 15-19 *| 10.4 E2
[4] chr1 20-29 *| 10.4 E1
谢谢