[Bioc-devel] bug in GRanges show method

Hahne, Florian florian.hahne at novartis.com
Wed Apr 25 09:12:07 CEST 2012


I found a little bug in the GRanges show method when using non-standard
names in the elementMetadata DataFrame:
foo <- GRanges(seqnames=rep("a", 3), ranges=IRanges(start=c(1,100, 1000),
width=10))
ds <- DataFrame("450-2"=1:3, "test"=5:7)
values(foo) <- ds
foo
GRanges with 3 ranges and 2 elementMetadata cols:
Error: identical(colnames(classinfo), colnames(out)) is not TRUE

The problem is that in the .makeNakedMatFromGenomicRanges function a
data.frame is being created without check.names=FALSE, so the


non-standard colnames are converted and do not match the original colnames
of the DataFrame anymore. The fix is trivial:

.makeNakedMatFromGenomicRanges <- function(x)
{
    lx <- length(x)
    nc <- ncol(elementMetadata(x))
    ans <- cbind(seqnames=as.character(seqnames(x)),
                 ranges=IRanges:::showAsCell(ranges(x)),
                 strand=as.character(strand(x)))
    if (nc > 0L) {
        tmp <- do.call(data.frame, c(lapply(elementMetadata(x),
                                          IRanges:::showAsCell),
check.names=FALSE))
        ans <- cbind(ans, `|`=rep.int("|", lx), as.matrix(tmp))
    }
    ans
}

Would be great if someone could fix that.

Florian

R Under development (unstable) (2012-04-16 r59045)
Platform: x86_64-unknown-linux-gnu/x86_64 (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=C                 LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

other attached packages:
[1] GenomicRanges_1.9.7 IRanges_1.15.4      BiocGenerics_0.3.0
[4] BiocInstaller_1.5.7

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






Florian Hahne
Novartis Institute For Biomedical Research
Translational Sciences / Preclinical Safety / PCS Informatics
Expert Data Integration and Modeling Bioinformatics
CHBS, WKL-135.2.26
Novartis Institute For Biomedical Research, Werk Klybeck
Klybeckstrasse 141
CH-4057 Basel
Switzerland
Phone: +41 61 6967127
Email : florian.hahne at novartis.com



More information about the Bioc-devel mailing list