Question: Selecting columns form a list of grange objects
0
gravatar for g.k
14 months ago by
g.k0
g.k0 wrote:

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"))

granges R grange • 406 views
ADD COMMENTlink modified 14 months ago • written 14 months ago by g.k0
Answer: Selecting columns form a list of grange objects
0
gravatar for Michael Lawrence
14 months ago by
United States
Michael Lawrence11k wrote:

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

ADD COMMENTlink written 14 months ago by Michael Lawrence11k

It is giving me incorrect number of dimensions 

ADD REPLYlink written 14 months ago by g.k0

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

ADD REPLYlink written 14 months ago by Michael Lawrence11k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 220 users visited in the last hour