[Bioc-devel] SummarizedExperiment: structure loss, when mixing matrix and data.frame data
Felix Ernst
felix.ernst at ulb.ac.be
Sun Nov 26 13:09:21 CET 2017
Hi all,
I got different results constructing a SummarizedExperiment in 3.6 and 3.7. My question is, whether this is intentional or a bug.
library(GenomicRanges)
library(SummarizedExperiment)
nrows <- 200; ncols <- 6
counts <- matrix(runif(nrows * ncols, 1, 1e4), nrows)
colnames(counts) <- LETTERS[1:6]
rownames(counts) <- 1:nrows
counts2 <- counts-floor(counts)
rowRanges <- GRanges(rep(c("chr1", "chr2"), c(50, 150)),
IRanges(floor(runif(200, 1e5, 1e6)), width=100),
strand=sample(c("+", "-"), 200, TRUE),
feature_id=sprintf("ID%03d", 1:200))
colData <- DataFrame(Treatment=rep(c("ChIP", "Input"), 3),
row.names=LETTERS[1:6])
se <- SummarizedExperiment(assays=list(counts=counts),
rowRanges=rowRanges,
colData=colData)
str(assays(se)$counts)
assays(se)$counts2 <- as.data.frame(counts2)
str(assays(se)$counts)
On a Windows 10 R3.4.2 Bioc 3.6 this produces:
num [1:200, 1:6] 8815 6314 1945 6185 5935 ...
- attr(*, "dimnames")=List of 2
..$ : chr [1:200] "1" "2" "3" "4" ...
..$ : chr [1:6] "A" "B" "C" "D" ...
num [1:200, 1:6] 8815 6314 1945 6185 5935 ...
- attr(*, "dimnames")=List of 2
..$ : chr [1:200] "1" "2" "3" "4" ...
..$ : chr [1:6] "A" "B" "C" "D" ...
On Ubuntu 17.10 R-devel r73779 Bioc3.7 this produces
num [1:200, 1:6] 8636 7040 9275 4821 2475 ...
- attr(*, "dimnames")=List of 2
..$ : chr [1:200] "1" "2" "3" "4" ...
..$ : chr [1:6] "A" "B" "C" "D" ...
num [1:1200] 8636 7040 9275 4821 2475 ...
Somehow the structure is lost.
This happens, if I mix matrix and data.frame data, and doesn’t, if I use only matrices. The man page defines matrix-like objects,
which a data.frame is (isn’t it?) and the behavior is different from Bioc3.6 to Bioc3.7.
I can rule out that this is a Windows/Linux thing, because the Travis build error, which pointed to an difference in the first place,
didn‘t occur with bioc-release, just with bioc-devel.
Thanks for any advice and suggestions.
Felix
[[alternative HTML version deleted]]
More information about the Bioc-devel
mailing list