1

かなり単純な操作を実行しようとしていますが、わかりません。R にインポートした特定の BED ファイルのすべての間隔の平均間隔長を取得しようとしています。この BED ファイルには重複する間隔は含まれていません。ファイルは次のようになります。

GRanges object with 12917252 ranges and 3 metadata columns:
         seqnames               ranges strand |                 name     score                thick
            <Rle>            <IRanges>  <Rle> |          <character> <numeric>            <IRanges>
     [1]     chr1       [10524, 10551]      + |        1:10524-10551       122       [10538, 10538]
     [2]     chr1       [11236, 11258]      + |        1:11236-11258        43       [11247, 11247]
     [3]     chr1       [11456, 11474]      + |        1:11456-11474        47       [11465, 11465]
     [4]     chr1       [12054, 12099]      + |        1:12054-12099       206       [12077, 12077]
     [5]     chr1       [12276, 12330]      + |        1:12276-12330       249       [12303, 12303]

任意の操作がranges列に適用されます

4

1 に答える 1

4

IRanges::width() の使用:

library(GenomicRanges) #loads IRanges, too.

#dummy data
gr = GRanges("chr1",IRanges(
  start = c(11236, 11456, 12054, 12276),
  end = c(11258, 11474, 12099, 12330)))

#get mean of ranges' "lengths" using width(), then take the mean().
mean(width(gr))
# [1] 35.75

?width

width(x): 各範囲の整数値の数。これは、x と同じ長さの負でない整数のベクトルです。

于 2016-09-13T09:38:42.057 に答える