Selecting columns form a list of grange objects
1
0
Entering edit mode
g.k • 0
@gk-13275
Last seen 5.9 years ago

I have a list having granges as follows:

    $
    File1.bed
    
    
    GRanges object with 3 ranges and 2 metadata columns:
    
          seqnames    ranges strand |        name
    
             <Rle> <IRanges>  <Rle> | <character>
    
      [1]    chr1   [ 4,  6]      + |         TF1
    
      [2]     chr1  [ 9,  9]      + |         TF1
    
      [3]     chr1  [11, 12]      - |         TF1
    
      -------
    
      seqinfo: 2 sequences from an unspecified genome; no seqlengths
    
    $
    File1.bed
    
    
    GRanges object with 3 ranges and 2 metadata columns:
    
          seqnames    ranges strand |        name     score
    
             <Rle> <IRanges>  <Rle> | <character> <numeric>
    
      [1]    chr2   [ 5, 60]      + |         TF4         0
    
      [2]     chr1  [21, 90]      + |         TF4         0
    
      [3]     chr2  [23, 30]      - |         TF4         0
    
      -------
    
      seqinfo: 3 sequences from an unspecified genome; no seqlengths

I would like to make these lists one list, to concatenate them into one.
I am using 

    data_bed = unlist(as(data_bed, "GRangesList"))

But it is giving me an error since the grange objects have different columns and so cannot be concatenated into one. Is there a way to subselect the columns I need inorder to create a list from the columns I want?

Any thoughts?

 

Input data:

structure(list(`C:/Users/Documents/test_data/File1.bed` = <S4 object of class structure("GRanges", package = "GenomicRanges")>, 
    `C:/Users/Documents/test_data/File2.bed` = <S4 object of class structure("GRanges", package = "GenomicRanges")>), .Names = c("C:/Users/Documents/test_data/File1.bed", 
"C:/Users/Documents/test_data/File2.bed"))

r granges grange • 2.9k views
ADD COMMENT
0
Entering edit mode
@michael-lawrence-3846
Last seen 2.9 years ago
United States

On a single GRanges, you could do something like x[,"name"]. Just do that over the whole list.

ADD COMMENT
0
Entering edit mode

It is giving me incorrect number of dimensions 

ADD REPLY
0
Entering edit mode

Are you looping over the list? Like GRangesList(lapply(data_bed, function(x) x[,"name"]))?

ADD REPLY

Login before adding your answer.

Traffic: 669 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6