在R中循环GRanges列表的对象

时间:2016-12-01 18:46:13

标签: r iranges

我在循环GRanges列表时遇到问题。

我的feature包含一个对象列表:

feature file:

...

$Pol3
GRanges object with 205 ranges and 0 metadata columns:
      seqnames                 ranges strand
         <Rle>              <IRanges>  <Rle>
    1     chr1 [ 16545569,  16546385]      *
    2     chr1 [ 16678151,  16678447]      *
    3     chr1 [ 93847201,  93848017]      *
    4     chr1 [146039330, 146039547]      *
    5     chr1 [146038406, 146038434]      *
  ...      ...                    ...    ...
  180     chr8 [ 66112999,  66114487]      *
  181     chr8 [ 95269339,  95270155]      *
  182     chr8 [123157081, 123157461]      *
  183     chrX [ 18674543,  18675359]      *
  184     chrX [137437934, 137438750]      *
  -------
  seqinfo: 17 sequences from an unspecified genome; no seqlengths

$FOS
GRanges object with 14383 ranges and 0 metadata columns:
          seqnames                 ranges strand
             <Rle>              <IRanges>  <Rle>
      [1]     chr1     [ 778602,  778872]      *
      [2]     chr1     [ 966089,  966373]      *
      [3]     chr1     [1000738, 1001022]      *
      [4]     chr1     [1064238, 1064508]      *
      [5]     chr1     [1080197, 1080467]      *
      ...      ...                    ...    ...
  [14379]     chrX [155026485, 155026769]      *
  [14380]     chrX [155068168, 155068452]      *
  [14381]     chrX [155216229, 155216464]      *
  [14382]     chrX [155881129, 155881399]      *
  [14383]     chrX [155888227, 155888497]      *
  -------
  seqinfo: 23 sequences from an unspecified genome; no seqlengths

...

和我的interval就像:

GRanges object with 6 ranges and 1 metadata column:
      seqnames               ranges strand |          id
         <Rle>            <IRanges>  <Rle> | <character>
  [1]     chr1 [ 8409137,  8409637]      * |   region1
  [2]     chr1 [ 8789220,  8789720]      * |   region1
  [3]     chr1 [ 9615503,  9616003]      * |   region1
  [4]     chr1 [10960926, 10961426]      * |   region1
  [5]     chr1 [11797718, 11798218]      * |   region1
  [6]     chr1 [12434198, 12434698]      * |   region1
  -------
  seqinfo: 23 sequences from an unspecified genome; no seqlengths

对于要素文件中的每个对象(例如$ FOS)我能够做到

mtch = findOverlaps(interval, feature$FOS)
myRanges = ranges(mtch,ranges(interval),ranges(feature$FOS))

每个对象的一切都很好,但是当我尝试使用lapply时,第二步不起作用

mtch <- lapply(feature, function(x) findOverlaps(x, interval)) 

myRanges = ranges(mtch,ranges(currmySegm),ranges(feature))

我明白了:

Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function 'ranges' for signature '"list"'

OR

   myRanges = ranges(mtch,ranges(interval),lapply(feature, function(x) ranges(x)))
Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function 'ranges' for signature '"list"'

非常感谢帮助我

1 个答案:

答案 0 :(得分:0)

第二步应该是这样的,假设您想从匹配和原始GRange对象中获取范围:

<a>