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"))
It is giving me incorrect number of dimensions
Are you looping over the list? Like
GRangesList(lapply(data_bed, function(x) x[,"name"]))
?