[BioC] GRanges, strange behavior when chromosomes don't match

Cei Abreu-Goodger cei at ebi.ac.uk
Thu Jul 8 18:22:15 CEST 2010


Hello all,

When you have two GRanges objects which don't have the same seqnames 
factor, you can get very unexpected behavior.

Would it be possible to get an error/warning when this is attempted? I 
don't know how many functions are affected, perhaps the functions 
mentioned below can be modified to produce a more obvious result...

Many thanks,

Cei


Code example / sessionInfo:

library(GenomicRanges)
gr1 <- GRanges(seqnames = c("chr1", "chr2", "chr3", "chr4"),
           ranges = IRanges(1:4, width = 10),
           strand = c("-", "+", "+", "+"))
gr2 <- GRanges(seqnames = c("chr1", "chr2", "chr5", "chr6"),
           ranges = IRanges(1:4, width = 10),
           strand = c("-", "+", "+", "+"))

union(gr1,gr2)
# gives expected result, all 6 ranges

intersect(gr1,gr2)
# includes ranges from the missing gr2 chromosomes

setdiff(gr1,gr2)
# includes 3 copies of the ranges from the missing gr2 chromosomes


sessionInfo()
R version 2.11.0 (2010-04-22)
i386-apple-darwin9.8.0

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base

other attached packages:
[1] GenomicRanges_1.0.5 IRanges_1.6.8       Biobase_2.8.0

loaded via a namespace (and not attached):
[1] tools_2.11.0



More information about the Bioconductor mailing list