[Bioc-sig-seq] GRangesList with duplicate names - WORKAROUND

Cook, Malcolm MEC at stowers.org
Wed Aug 3 18:23:44 CEST 2011


Hi,

re: https://stat.ethz.ch/pipermail/bioc-sig-sequencing/2011-February/001867.html

It appears that the requirement that names of a GRangesList must be unique has won the day.

I'm not sure I agree with this result, as there are many operations that are optimized for GRangesList that have use cases that do not depend upon such uniqueness.

However, I find that such operations can proceed after setting the names to NULL,, as is demonstrated in the R session following my signature, in which I am creating a GRanges list with entirely duplicate (unnamed) elements.

I hope this workaround proves useful to others...

Malcolm Cook
Computational Biology - Stowers Institute for Medical Research



Example:

> grl=GRangesList(a=GRanges(c(10,20,30),c(15,25,35)),b=GRanges(c(100,200,300),c(150,250,350)))
> grl
GRangesList of length 2
$a 
GRanges with 3 ranges and 0 elementMetadata values
    seqnames    ranges strand |
       <Rle> <IRanges>  <Rle> |
[1]       10  [15, 15]      * |
[2]       20  [25, 25]      * |
[3]       30  [35, 35]      * |

$b 
GRanges with 3 ranges and 0 elementMetadata values
    seqnames     ranges strand |
       <Rle>  <IRanges>  <Rle> |
[1]      100 [150, 150]      * |
[2]      200 [250, 250]      * |
[3]      300 [350, 350]      * |


seqlengths
  10  20  30 100 200 300
  NA  NA  NA  NA  NA  NA
> grl[rep(1,2)]
Error in `rownames<-`(`*tmp*`, value = c("a", "a")) : 
  duplicate rownames not allowed
> names(grl)=NULL
> grl[rep(1,2)]
GRangesList of length 2
[[1]] 
GRanges with 3 ranges and 0 elementMetadata values
    seqnames    ranges strand |
       <Rle> <IRanges>  <Rle> |
[1]       10  [15, 15]      * |
[2]       20  [25, 25]      * |
[3]       30  [35, 35]      * |

[[2]] 
GRanges with 3 ranges and 0 elementMetadata values
    seqnames    ranges strand |
       <Rle> <IRanges>  <Rle> |
[1]       10  [15, 15]      * |
[2]       20  [25, 25]      * |
[3]       30  [35, 35]      * |


seqlengths
  10  20  30 100 200 300
  NA  NA  NA  NA  NA  NA
>



More information about the Bioc-sig-sequencing mailing list