0

何千ものスコア列を持つ GRanges オブジェクト ( tomap ) と、関心領域がありメタデータがない ( roi ) オブジェクトがあります。tomapの各列の最大スコアをroiの対応する間隔にマップしようとしています。

また、スコア列の名前も保持したいと思います (私の実際のデータでは、これらは意味のある名前であり、score1、score2 などのように一般化できません)。特定の列に対して行うことはできますが、すべての列に一般化するのに苦労しています。

これが私がこれまでに得たものです:

library(GenomicRanges)
tomap <- GRanges(
    seqnames = Rle(c("chr1"), c(10)),
    ranges = IRanges(1:10*10, end = 1:10*10+5),
    score1 = runif(10),score2=runif(10),score3=runif(10),score4=runif(10),score5=runif(10))

roi <- GRanges(
    seqnames = Rle(c("chr1"), c(5)),
    ranges = IRanges(1:5*20 + floor(runif(5)*4), width = 10))

hits <- findOverlaps(roi, tomap, ignore.strand = TRUE)

ans<-roi
mcols(ans) <- aggregate(tomap, hits, score1=max(score1), score2= max(score2))

ans
#GRanges object with 5 ranges and 3 metadata columns:
#      seqnames    ranges strand |             grouping            score1            score2
#         <Rle> <IRanges>  <Rle> | <ManyToManyGrouping>         <numeric>         <numeric>
#  [1]     chr1     22-31      * |                  2,3 0.326366489753127 0.925836584065109
#  [2]     chr1     42-51      * |                  4,5  0.92806151532568 0.897841389290988
#  [3]     chr1     62-71      * |                  6,7 0.980487102875486 0.940743445185944
#  [4]     chr1     83-92      * |                  8,9 0.798293181695044 0.381754550151527
#  [5]     chr1   101-110      * |                   10 0.872806148370728 0.953412540955469






ご覧のとおり、各スコア列を個別に指定するとこれが機能しますが、何千もの列に対してこれを行うにはどうすればよいでしょうか?

4

0 に答える 0